diff options
author | spisarski <s.pisarski@cablelabs.com> | 2017-07-28 10:40:49 -0600 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2017-07-28 10:40:49 -0600 |
commit | 84c4e791b6ea4e6d488acf29491ef8c901011aa3 (patch) | |
tree | cbbca9a455f63fa78c11025b17e90854e3a934be /snaps/openstack/utils | |
parent | ca276f452540f68c08cb3df9049e9e7876364dac (diff) |
Removed floating IP list from OpenStackVmInstance.
There was a list and dict both holding the same floating IP
objects which has been problematic especially when trying
to initialize the object with a VM instance that already
exists.
JIRA: SNAPS-149
Change-Id: If4af6dfef04a40b9c8cd7a8add484c9ec03f1ef8
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/utils')
-rw-r--r-- | snaps/openstack/utils/neutron_utils.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/snaps/openstack/utils/neutron_utils.py b/snaps/openstack/utils/neutron_utils.py index 2f8ef7e..19325a8 100644 --- a/snaps/openstack/utils/neutron_utils.py +++ b/snaps/openstack/utils/neutron_utils.py @@ -448,17 +448,31 @@ def get_external_networks(neutron): return out -def get_floating_ips(neutron): +def get_floating_ips(neutron, ports=None): """ Returns all of the floating IPs + When ports is not None, FIPs returned must be associated with one of the + ports in the list and a tuple 2 where the first element being the port's + name and the second being the FloatingIp SNAPS-OO domain object. + When ports is None, all known FloatingIp SNAPS-OO domain objects will be + returned in a list :param neutron: the Neutron client - :return: a list of SNAPS FloatingIp objects + :param ports: a list of SNAPS-OO Port objects to join + :return: a list of tuple 2 (port_name, SNAPS FloatingIp) objects when ports + is not None else a list of Port objects """ out = list() fips = neutron.list_floatingips() for fip in fips['floatingips']: - out.append(FloatingIp(inst_id=fip['id'], - ip=fip['floating_ip_address'])) + if ports: + for port_name, port in ports: + if fip['port_id'] == port.id: + out.append((port.name, FloatingIp( + inst_id=fip['id'], ip=fip['floating_ip_address']))) + break + else: + out.append(FloatingIp(inst_id=fip['id'], + ip=fip['floating_ip_address'])) return out |