Revision 3956cee1 lib/backend.py
b/lib/backend.py | ||
---|---|---|
48 | 48 |
return ssh.SshRunner() |
49 | 49 |
|
50 | 50 |
|
51 |
def _CleanDirectory(path): |
|
52 |
if not os.path.isdir(path): |
|
53 |
return |
|
54 |
for rel_name in utils.ListVisibleFiles(path): |
|
55 |
full_name = os.path.join(path, rel_name) |
|
56 |
if os.path.isfile(full_name) and not os.path.islink(full_name): |
|
57 |
utils.RemoveFile(full_name) |
|
58 |
|
|
59 |
|
|
51 | 60 |
def _GetMasterInfo(): |
52 | 61 |
"""Return the master ip and netdev. |
53 | 62 |
|
... | ... | |
169 | 178 |
"""Cleans up the current node and prepares it to be removed from the cluster. |
170 | 179 |
|
171 | 180 |
""" |
172 |
def _CleanDirectory(path): |
|
173 |
if not os.path.isdir(path): |
|
174 |
return |
|
175 |
for rel_name in utils.ListVisibleFiles(path): |
|
176 |
full_name = os.path.join(path, rel_name) |
|
177 |
if os.path.isfile(full_name) and not os.path.islink(full_name): |
|
178 |
utils.RemoveFile(full_name) |
|
179 |
|
|
180 | 181 |
_CleanDirectory(constants.DATA_DIR) |
181 | 182 |
|
182 |
# Remove job queue files and archived jobs |
|
183 |
_CleanDirectory(constants.QUEUE_DIR) |
|
184 |
_CleanDirectory(constants.JOB_QUEUE_ARCHIVE_DIR) |
|
183 |
JobQueuePurge() |
|
185 | 184 |
|
186 | 185 |
try: |
187 | 186 |
priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS) |
... | ... | |
1659 | 1658 |
return result |
1660 | 1659 |
|
1661 | 1660 |
|
1661 |
def JobQueuePurge(): |
|
1662 |
"""Removes job queue files and archived jobs |
|
1663 |
|
|
1664 |
""" |
|
1665 |
_CleanDirectory(constants.QUEUE_DIR) |
|
1666 |
_CleanDirectory(constants.JOB_QUEUE_ARCHIVE_DIR) |
|
1667 |
|
|
1668 |
|
|
1662 | 1669 |
def CloseBlockDevices(disks): |
1663 | 1670 |
"""Closes the given block devices. |
1664 | 1671 |
|
Also available in: Unified diff