Add "--all" option to vm reaper.
In case we need to quickly delete all known VMs. Change-Id: Ic2bfc8b5ed9512ecf56ebf1278a6d31e7d7fade9
This commit is contained in:
@@ -35,9 +35,15 @@ CLOUD_SERVERS_API_KEY = os.environ['CLOUD_SERVERS_API_KEY']
|
||||
|
||||
db = vmdatabase.VMDatabase()
|
||||
|
||||
if '--all' in sys.argv:
|
||||
print "Reaping all known machines"
|
||||
REAP_ALL = True
|
||||
else:
|
||||
REAP_ALL = False
|
||||
|
||||
print 'Known machines (start):'
|
||||
for machine in db.getMachines():
|
||||
print machine
|
||||
print machine
|
||||
|
||||
if CLOUD_SERVERS_DRIVER == 'rackspace':
|
||||
Driver = get_driver(Provider.RACKSPACE)
|
||||
@@ -55,11 +61,11 @@ def delete(machine):
|
||||
|
||||
now = time.time()
|
||||
for machine in db.getMachines():
|
||||
if now-machine['created'] > 24*60*60:
|
||||
if REAP_ALL or (now-machine['created'] > 24*60*60):
|
||||
print 'Deleting', machine['name']
|
||||
delete(machine)
|
||||
|
||||
print
|
||||
print 'Known machines (end):'
|
||||
for machine in db.getMachines():
|
||||
print machine
|
||||
print machine
|
||||
|
||||
Reference in New Issue
Block a user