Keep minionswarm temporary files/dirs. Refs #1964.

* Provide an option to the parer which allows not to delete temporary files/directories created for the minionswarm.
This commit is contained in:
Pedro Algarvio 2012-09-05 12:01:48 +01:00
parent 145197b48b
commit fc3070c3bb

View file

@ -50,6 +50,11 @@ def parse():
action='store_true',
help=('Run the minions with debug output of the swarm going to '
'the terminal'))
parser.add_option('--no-clean',
action='store_true',
default=False,
help='Don\'t cleanup temporary files/directories'
)
options, args = parser.parse_args()
@ -147,7 +152,8 @@ class Swarm(object):
#os.remove(path)
if os.path.exists(pidfile):
os.remove(pidfile)
shutil.rmtree(path)
if not self.opts['no_clean']:
shutil.rmtree(path)
except (OSError, IOError):
pass
@ -174,8 +180,9 @@ class Swarm(object):
"kill -KILL $(ps aux | grep python | grep \"salt-minion\" | awk '{print $2}')",
shell=True
)
print('Remove ALL related temp files/directories')
subprocess.call('rm -rf /tmp/mswarm*', shell=True)
if not self.opts['no_clean']:
print('Remove ALL related temp files/directories')
subprocess.call('rm -rf /tmp/mswarm*', shell=True)
print('Done')
if __name__ == '__main__':