Merge pull request #6230 from joshuaconner/bugfix_nova_computer_partial_server_name_match
nova_compute: fix for partial match b/w params['name'] and an existing name
This commit is contained in:
commit
e68f1a0273
1 changed files with 6 additions and 1 deletions
|
@ -193,7 +193,12 @@ def _get_server_state(module, nova):
|
||||||
try:
|
try:
|
||||||
servers = nova.servers.list(True, {'name': module.params['name']})
|
servers = nova.servers.list(True, {'name': module.params['name']})
|
||||||
if servers:
|
if servers:
|
||||||
server = [x for x in servers if x.name == module.params['name']][0]
|
# the {'name': module.params['name']} will also return servers
|
||||||
|
# with names that partially match the server name, so we have to
|
||||||
|
# strictly filter here
|
||||||
|
servers = [x for x in servers if x.name == module.params['name']]
|
||||||
|
if servers:
|
||||||
|
server = servers[0]
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
module.fail_json(msg = "Error in getting the server list: %s" % e.message)
|
module.fail_json(msg = "Error in getting the server list: %s" % e.message)
|
||||||
if server and module.params['state'] == 'present':
|
if server and module.params['state'] == 'present':
|
||||||
|
|
Loading…
Reference in a new issue