summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/create_instance.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-07-12 11:14:57 -0600
committerspisarski <s.pisarski@cablelabs.com>2017-07-13 08:05:14 -0600
commite6326cd5e826d19e4dd2b096c17aff35da1757b3 (patch)
treef86cbf32d0660cddc802b7cd381afe264ee78033 /snaps/openstack/create_instance.py
parentf5f0f1cbcb757a9229a92c3a7f4ea400db11dd07 (diff)
Created domain class for ports.
Create Port domain class so neutron_utils.py functions returning port objects will not be leaking out implementation details as each API version can change these data structures and this should all be handled by the SNAPS neutron utility. JIRA: SNAPS-118 Change-Id: If031a094a9da284e2838691c3b3490359f710c61 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/create_instance.py')
-rw-r--r--snaps/openstack/create_instance.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/snaps/openstack/create_instance.py b/snaps/openstack/create_instance.py
index 99ab87c..c970a31 100644
--- a/snaps/openstack/create_instance.py
+++ b/snaps/openstack/create_instance.py
@@ -298,13 +298,13 @@ class OpenStackVmInstance:
if subnet:
# Take IP of subnet if there is one configured on which to place
# the floating IP
- for fixed_ip in port['port']['fixed_ips']:
+ for fixed_ip in port.fixed_ips:
if fixed_ip['subnet_id'] == subnet['subnet']['id']:
ip = fixed_ip['ip_address']
break
else:
# Simply take the first
- ip = port['port']['fixed_ips'][0]['ip_address']
+ ip = port.ips[0]['ip_address']
if ip:
count = timeout / poll_interval
@@ -363,7 +363,6 @@ class OpenStackVmInstance:
"""
port = self.get_port_by_name(port_name)
if port:
- port_dict = port['port']
if subnet_name:
subnet = neutron_utils.get_subnet_by_name(self.__neutron,
subnet_name)
@@ -372,13 +371,12 @@ class OpenStackVmInstance:
'not be located with name - %s',
subnet_name)
return None
- for fixed_ip in port_dict['fixed_ips']:
+ for fixed_ip in port.ips:
if fixed_ip['subnet_id'] == subnet['subnet']['id']:
return fixed_ip['ip_address']
else:
- fixed_ips = port_dict['fixed_ips']
- if fixed_ips and len(fixed_ips) > 0:
- return fixed_ips[0]['ip_address']
+ if port.ips and len(port.ips) > 0:
+ return port.ips[0]['ip_address']
return None
def get_port_mac(self, port_name):
@@ -392,8 +390,7 @@ class OpenStackVmInstance:
"""
port = self.get_port_by_name(port_name)
if port:
- port_dict = port['port']
- return port_dict['mac_address']
+ return port.mac_address
return None
def get_port_by_name(self, port_name):
@@ -450,7 +447,7 @@ class OpenStackVmInstance:
:param ip: The IP on which to apply the playbook.
:return: the return value from ansible
"""
- port_ip = port['port']['fixed_ips'][0]['ip_address']
+ port_ip = port.ips[0]['ip_address']
variables = {
'floating_ip': ip,
'nic_name': nic_name,