From 40565ef2361629511d2cecff768f8172361e5b6d Mon Sep 17 00:00:00 2001 From: bennojoy Date: Thu, 10 Oct 2013 11:44:30 +0530 Subject: [PATCH] nova compute fix regex in instance name --- library/cloud/nova_compute | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/cloud/nova_compute b/library/cloud/nova_compute index 5b43115fbd..643d685ac9 100644 --- a/library/cloud/nova_compute +++ b/library/cloud/nova_compute @@ -128,9 +128,12 @@ EXAMPLES = ''' def _delete_server(module, nova): name = None + server_list = None try: - server = nova.servers.list(True, {'name': module.params['name']}).pop() - nova.servers.delete(server) + server_list = nova.servers.list(True, {'name': module.params['name']}) + if server_list: + server = [x for x in server_list if x.name == module.params['name']] + nova.servers.delete(server.pop()) except Exception as e: module.fail_json( msg = "Error in deleting vm: %s" % e.message) if module.params['wait'] == 'no': @@ -187,7 +190,7 @@ def _get_server_state(module, nova): try: servers = nova.servers.list(True, {'name': module.params['name']}) if servers: - server = servers.pop() + server = [x for x in servers if x.name == module.params['name']] except Exception as e: module.fail_json(msg = "Error in getting the server list: %s" % e.message) if server and module.params['state'] == 'present':