summaryrefslogtreecommitdiff
path: root/neutron_floating_ip
diff options
context:
space:
mode:
authorLorin Hochstein <lorinh@gmail.com>2015-04-21 17:30:12 -0400
committerLorin Hochstein <lorinh@gmail.com>2015-04-21 17:30:12 -0400
commit01bb3c3d31ce53be576cc2f21ceed2af2495b5cc (patch)
treeb1397801d3cc16f50f68dea7546a99e2cc4d4d27 /neutron_floating_ip
parentd46ec30eb268648172f818489446982916dc90e9 (diff)
parent0a1a8de0f1f45579a7d440bcd389a613307b3203 (diff)
downloadopenstack-ansible-modules-01bb3c3d31ce53be576cc2f21ceed2af2495b5cc.tar.gz
Merge pull request #44 from dguerri/master
Few enhancements for neutron_* modules
Diffstat (limited to 'neutron_floating_ip')
-rw-r--r--neutron_floating_ip24
1 files changed, 13 insertions, 11 deletions
diff --git a/neutron_floating_ip b/neutron_floating_ip
index 4c14102..fbece6c 100644
--- a/neutron_floating_ip
+++ b/neutron_floating_ip
@@ -89,10 +89,12 @@ EXAMPLES = '''
def _get_ksclient(module, kwargs):
try:
- kclient = ksclient.Client(username=kwargs.get('login_username'),
- password=kwargs.get('login_password'),
- tenant_name=kwargs.get('login_tenant_name'),
- auth_url=kwargs.get('auth_url'))
+ kclient = ksclient.Client(
+ username=module.params.get('login_username'),
+ password=module.params.get('login_password'),
+ tenant_name=module.params.get('login_tenant_name'),
+ auth_url=module.params.get('auth_url'),
+ region_name=module.params.get('region_name'))
except Exception as e:
module.fail_json(msg = "Error authenticating to the keystone: %s " % e.message)
global _os_keystone
@@ -136,7 +138,7 @@ def _get_server_state(module, nova):
except Exception as e:
module.fail_json(msg = "Error in getting the server list: %s" % e.message)
return server_info, server
-
+
def _get_port_info(neutron, module, instance_id):
if module.params['port_network_name'] is None:
kwargs = {
@@ -158,7 +160,7 @@ def _get_port_info(neutron, module, instance_id):
if not ports['ports']:
return None, None
return ports['ports'][0]['fixed_ips'][0]['ip_address'], ports['ports'][0]['id']
-
+
def _get_floating_ip(module, neutron, fixed_ip_address):
kwargs = {
'fixed_ip_address': fixed_ip_address
@@ -222,7 +224,7 @@ def _update_floating_ip(neutron, module, port_id, floating_ip_id):
def main():
-
+
module = AnsibleModule(
argument_spec = dict(
login_username = dict(default='admin'),
@@ -236,14 +238,15 @@ def main():
state = dict(default='present', choices=['absent', 'present'])
),
)
-
+
try:
nova = nova_client.Client(module.params['login_username'], module.params['login_password'],
- module.params['login_tenant_name'], module.params['auth_url'], service_type='compute')
+ module.params['login_tenant_name'], module.params['auth_url'], service_type='compute',
+ region_name=module.params.get('region_name'))
neutron = _get_neutron_client(module, module.params)
except Exception as e:
module.fail_json(msg="Error in authenticating to nova: %s" % e.message)
-
+
server_info, server_obj = _get_server_state(module, nova)
if not server_info:
module.fail_json(msg="The instance name provided cannot be found")
@@ -271,4 +274,3 @@ def main():
from ansible.module_utils.basic import *
main()
-