Merge pull request #4065 from CharlesBlonde/nova_wait_for_bug

Nova_compute wait_for fixes
pull/4058/merge
Michael DeHaan 11 years ago
commit 59099b7607

@ -135,7 +135,7 @@ def _delete_server(module, nova):
module.fail_json( msg = "Error in deleting vm: %s" % e.message) module.fail_json( msg = "Error in deleting vm: %s" % e.message)
if module.params['wait'] == 'no': if module.params['wait'] == 'no':
module.exit_json(changed = True, result = "deleted") module.exit_json(changed = True, result = "deleted")
expire = time.time() + module.params['wait_for'] expire = time.time() + int(module.params['wait_for'])
while time.time() < expire: while time.time() < expire:
name = nova.servers.list(True, {'name': module.params['name']}) name = nova.servers.list(True, {'name': module.params['name']})
if not name: if not name:
@ -160,7 +160,7 @@ def _create_server(module, nova):
except Exception as e: except Exception as e:
module.fail_json( msg = "Error in creating instance: %s " % e.message) module.fail_json( msg = "Error in creating instance: %s " % e.message)
if module.params['wait'] == 'yes': if module.params['wait'] == 'yes':
expire = time.time() + module.params['wait_for'] expire = time.time() + int(module.params['wait_for'])
while time.time() < expire: while time.time() < expire:
try: try:
server = nova.servers.get(server.id) server = nova.servers.get(server.id)
@ -220,7 +220,7 @@ def main():
nics = dict(default=None), nics = dict(default=None),
meta = dict(default=None), meta = dict(default=None),
wait = dict(default='yes', choices=['yes', 'no']), wait = dict(default='yes', choices=['yes', 'no']),
wait_for = dict(default=120), wait_for = dict(default=180),
state = dict(default='present', choices=['absent', 'present']) state = dict(default='present', choices=['absent', 'present'])
), ),
) )

Loading…
Cancel
Save