summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo <pablo@compugenic.com>2015-09-17 17:06:23 -0700
committerPablo <pablo@compugenic.com>2015-09-17 17:06:23 -0700
commitb1e60b3236190140c5b77eac0d179bdfec4782ee (patch)
treeeff6cff3ca1520bc29a87a8f742820588562df24
parent54b360a6eccfe955537c6d614b599a7c6f1a91c2 (diff)
downloadopenstack-ansible-modules-b1e60b3236190140c5b77eac0d179bdfec4782ee.tar.gz
bugfix: was using the first available FIP regardless of tenant
-rw-r--r--neutron_floating_ip8
1 files changed, 7 insertions, 1 deletions
diff --git a/neutron_floating_ip b/neutron_floating_ip
index 544b723..9c27f10 100644
--- a/neutron_floating_ip
+++ b/neutron_floating_ip
@@ -178,6 +178,11 @@ def _get_floating_ip(module, neutron, fixed_ip_address):
return None, None
return ips['floatingips'][0]['id'], ips['floatingips'][0]['floating_ip_address']
+def _get_tenant_id(module):
+ tenants = _get_ksclient(module, {}).tenants.list()
+ tenant = next((t for t in tenants if t.name == module.params.get('login_tenant_name')), None)
+ return tenant.id
+
def _assign_floating_ip(neutron, module, port_id, net_id):
kwargs = {
'floating_network_id': net_id
@@ -187,7 +192,8 @@ def _assign_floating_ip(neutron, module, port_id, net_id):
except Exception as e:
module.fail_json(msg = "error in fetching the floatingips's %s" % e.message)
- fip = next((fip for fip in ips['floatingips'] if fip['port_id'] is None), None)
+ tenant_id = _get_tenant_id(module)
+ fip = next((fip for fip in ips['floatingips'] if fip['port_id'] is None and fip['tenant_id'] == tenant_id), None)
if fip is None:
_create_floating_ip(neutron, module, port_id, net_id)