summaryrefslogtreecommitdiffstats
path: root/snaps/config/network.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2018-04-17 08:24:18 -0600
committerspisarski <s.pisarski@cablelabs.com>2018-04-19 15:20:51 -0600
commitf65dbaef830fe7121173fdb83e5e4dde09b11a8a (patch)
treefa2c1a7bdc5fdc10b28c8ba722ff324267e9444a /snaps/config/network.py
parentbd658dbe250e93a9fa4405b99ecdb2ad1a7029b6 (diff)
Fixed bug with regards to subnet lookups.
Neutron returns all subnets regardless of visibility which cause problems within routers if there is another subnet with the same name attached to a different network. JIRA: SNAPS-304 In addition, this patch contains two other minor fixes. launch_utils.py - raise an exception when the creator is not properly instantiated network.py - allow fixed IPs to be none. Change-Id: Ib343074d925be4592a713727a03d5b531890eada Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/config/network.py')
-rw-r--r--snaps/config/network.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/snaps/config/network.py b/snaps/config/network.py
index 8148c61..eca8734 100644
--- a/snaps/config/network.py
+++ b/snaps/config/network.py
@@ -412,22 +412,23 @@ class PortConfig(object):
raise PortConfigError(
'The attribute network_name is required')
- def __get_fixed_ips(self, neutron):
+ def __get_fixed_ips(self, neutron, network):
"""
Sets the self.fixed_ips value
:param neutron: the Neutron client
+ :param network: the SNAPS-OO network domain object
:return: None
"""
-
fixed_ips = list()
if self.ip_addrs:
for ip_addr_dict in self.ip_addrs:
subnet = neutron_utils.get_subnet(
- neutron, subnet_name=ip_addr_dict['subnet_name'])
- if subnet and 'ip' in ip_addr_dict:
- fixed_ips.append({'ip_address': ip_addr_dict['ip'],
- 'subnet_id': subnet.id})
+ neutron, network, subnet_name=ip_addr_dict['subnet_name'])
+ if subnet:
+ if 'ip' in ip_addr_dict:
+ fixed_ips.append({'ip_address': ip_addr_dict['ip'],
+ 'subnet_id': subnet.id})
else:
raise PortConfigError(
'Invalid port configuration, subnet does not exist '
@@ -443,25 +444,29 @@ class PortConfig(object):
TODO - expand automated testing to exercise all parameters
:param neutron: the Neutron client
+ :param keystone: the Keystone client
:param os_creds: the OpenStack credentials
:return: the dictionary object
"""
-
out = dict()
-
session = keystone_utils.keystone_session(os_creds)
keystone = keystone_utils.keystone_client(os_creds, session)
+
+ project_name = os_creds.project_name
+ if self.project_name:
+ project_name = project_name
try:
network = neutron_utils.get_network(
neutron, keystone, network_name=self.network_name,
- project_name=self.project_name)
+ project_name=project_name)
finally:
- keystone_utils.close_session(session)
+ if session:
+ keystone_utils.close_session(session)
if not network:
raise PortConfigError(
'Cannot locate network with name - ' + self.network_name
- + ' in project - ' + str(self.project_name))
+ + ' in project - ' + str(project_name))
out['network_id'] = network.id
@@ -484,7 +489,7 @@ class PortConfig(object):
if self.mac_address:
out['mac_address'] = self.mac_address
- fixed_ips = self.__get_fixed_ips(neutron)
+ fixed_ips = self.__get_fixed_ips(neutron, network)
if fixed_ips and len(fixed_ips) > 0:
out['fixed_ips'] = fixed_ips