Merge pull request #3809 from mscherer/fix_openstack_folsom

Fix traceback when openstack do not have OS-EXT-IPS:type attached to add...
pull/3805/merge
Michael DeHaan 11 years ago
commit cd7971e0d4

@ -167,8 +167,8 @@ def _create_server(module, nova):
except Exception as e: except Exception as e:
module.fail_json( msg = "Error in getting info from instance: %s " % e.message) module.fail_json( msg = "Error in getting info from instance: %s " % e.message)
if server.status == 'ACTIVE': if server.status == 'ACTIVE':
private = [ x['addr'] for x in getattr(server, 'addresses').itervalues().next() if x['OS-EXT-IPS:type'] == 'fixed'] private = [ x['addr'] for x in getattr(server, 'addresses').itervalues().next() if 'OS-EXT-IPS:type' in x and x['OS-EXT-IPS:type'] == 'fixed']
public = [ x['addr'] for x in getattr(server, 'addresses').itervalues().next() if x['OS-EXT-IPS:type'] == 'floating'] public = [ x['addr'] for x in getattr(server, 'addresses').itervalues().next() if 'OS-EXT-IPS:type' in x and x['OS-EXT-IPS:type'] == 'floating']
module.exit_json(changed = True, id = server.id, private_ip=''.join(private), public_ip=''.join(public), status = server.status, info = server._info) module.exit_json(changed = True, id = server.id, private_ip=''.join(private), public_ip=''.join(public), status = server.status, info = server._info)
if server.status == 'ERROR': if server.status == 'ERROR':
module.fail_json(msg = "Error in creating the server, please check logs") module.fail_json(msg = "Error in creating the server, please check logs")
@ -193,8 +193,8 @@ def _get_server_state(module, nova):
if server and module.params['state'] == 'present': if server and module.params['state'] == 'present':
if server.status != 'ACTIVE': if server.status != 'ACTIVE':
module.fail_json( msg="The VM is available but not Active. state:" + server.status) module.fail_json( msg="The VM is available but not Active. state:" + server.status)
private = [ x['addr'] for x in getattr(server, 'addresses').itervalues().next() if x['OS-EXT-IPS:type'] == 'fixed'] private = [ x['addr'] for x in getattr(server, 'addresses').itervalues().next() if 'OS-EXT-IPS:type' in x and x['OS-EXT-IPS:type'] == 'fixed']
public = [ x['addr'] for x in getattr(server, 'addresses').itervalues().next() if x['OS-EXT-IPS:type'] == 'floating'] public = [ x['addr'] for x in getattr(server, 'addresses').itervalues().next() if 'OS-EXT-IPS:type' in x and x['OS-EXT-IPS:type'] == 'floating']
module.exit_json(changed = False, id = server.id, public_ip = ''.join(public), private_ip = ''.join(private), info = server._info) module.exit_json(changed = False, id = server.id, public_ip = ''.join(public), private_ip = ''.join(private), info = server._info)
if server and module.params['state'] == 'absent': if server and module.params['state'] == 'absent':
return True return True

Loading…
Cancel
Save