github.com/greenplum-db/gpbackup@v0.0.0-20240517212602-89daab1885b3/ci/scripts/clean-ddboost.py (about)

     1  #!/usr/bin/python3
     2  
     3  from time import sleep
     4  import os
     5  import pexpect
     6  
     7  targetIPAddrPass = {
     8      os.getenv("DD_SOURCE_HOST", ""): os.getenv("DD_SYSADMIN_PW", ""),
     9      os.getenv("DD_DEST_HOST", ""): os.getenv("DD_SYSADMIN_PW", ""),
    10  }
    11  
    12  for ipaddr in targetIPAddrPass:
    13      pw = targetIPAddrPass.get(ipaddr, "NONE")
    14      target = "ssh sysadmin@{}".format(ipaddr)
    15  
    16      command = "{} 'ddboost storage-unit delete GPDB'".format(target)
    17      print "%s" % command
    18      child = pexpect.spawn(command, timeout=1200)
    19  
    20      # in the case of first-time connection, handle key fingerprint prompt
    21      resp = child.expect(["continue connecting","Password:"])
    22      if resp == 0:
    23          print "Encountered fingerprint prompt"
    24          child.sendline("yes")
    25          sleep(2)
    26          child.expect("Password:")
    27          child.sendline(pw)
    28  
    29      else:
    30          print "Did not encounter fingerprint prompt"
    31          child.sendline(pw)
    32      print "%s" % child.before + child.after
    33      sleep(3)
    34  
    35      command = "{} 'ddboost storage-unit delete gpdb_boostfs'".format(target)
    36      print "%s" % command
    37      child = pexpect.spawn(command, timeout=1200)
    38      child.expect("Password:")
    39      child.sendline(pw)
    40      print "%s" % child.before + child.after
    41      sleep(5)  # give it a chance to process before cleaning
    42  
    43      command = "{} 'filesys clean start'".format(target)
    44      print "%s" % command
    45      child = pexpect.spawn(command, timeout=1200)
    46      child.expect("Password:")
    47      child.sendline(pw)
    48      print "%s" % child.before + child.after
    49      sleep(5)  # give it a chance to start cleaning
    50  
    51      command = "{} 'filesys clean watch'".format(target)
    52      print "%s" % command
    53      child = pexpect.spawn(command, timeout=1200)
    54      child.expect("Password:")
    55      child.sendline(pw)
    56      child.expect(pexpect.EOF)
    57      sleep(3)
    58  
    59      command = "{} 'ddboost storage-unit create GPDB user gpadmin'".format(target)
    60      print "%s" % command
    61      child = pexpect.spawn(command, timeout=1200)
    62      child.expect("Password:")
    63      child.sendline(pw)
    64      print "%s" % child.before + child.after
    65      sleep(3)
    66  
    67      command = "{} 'ddboost storage-unit create gpdb_boostfs user gpadmin'".format(
    68          target
    69      )
    70      print "%s" % command
    71      child = pexpect.spawn(command, timeout=1200)
    72      child.expect("Password:")
    73      child.sendline(pw)
    74      print "%s" % child.before + child.after
    75      sleep(3)
    76  
    77      print "Finished cleaning: %s" % ipaddr