return ssh.SshRunner()
+def _CleanDirectory(path):
+ if not os.path.isdir(path):
+ return
+ for rel_name in utils.ListVisibleFiles(path):
+ full_name = os.path.join(path, rel_name)
+ if os.path.isfile(full_name) and not os.path.islink(full_name):
+ utils.RemoveFile(full_name)
+
+
def _GetMasterInfo():
"""Return the master ip and netdev.
"""Cleans up the current node and prepares it to be removed from the cluster.
"""
- def _CleanDirectory(path):
- if not os.path.isdir(path):
- return
- for rel_name in utils.ListVisibleFiles(path):
- full_name = os.path.join(path, rel_name)
- if os.path.isfile(full_name) and not os.path.islink(full_name):
- utils.RemoveFile(full_name)
-
_CleanDirectory(constants.DATA_DIR)
- # Remove job queue files and archived jobs
- _CleanDirectory(constants.QUEUE_DIR)
- _CleanDirectory(constants.JOB_QUEUE_ARCHIVE_DIR)
+ JobQueuePurge()
try:
priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS)
return result
+def JobQueuePurge():
+ """Removes job queue files and archived jobs
+
+ """
+ _CleanDirectory(constants.QUEUE_DIR)
+ _CleanDirectory(constants.JOB_QUEUE_ARCHIVE_DIR)
+
+
def CloseBlockDevices(disks):
"""Closes the given block devices.