summaryrefslogtreecommitdiffstats
path: root/snaps/config/router.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2018-02-22 11:42:52 -0700
committerspisarski <s.pisarski@cablelabs.com>2018-02-22 11:42:52 -0700
commitc711acf8ae3e4ad6f746500747857bcc9fd6f7be (patch)
tree4eeba467b4f42b37e935ccfff6b547bd11c65778 /snaps/config/router.py
parentf3553913925b8ee5869c8e06047d6e4161a968c7 (diff)
Changed pattern on how objects lookup themselves by name and project.
The pattern being replaced has unwittingly added the requirement that all creator credentials must be of type 'admin' as when looking up the associated project ID required a call to keystone.projects.list(). As the SNAPS integration tests were always creating users with an 'admin' role, this issue was not caught. As part of this patch, integration test users will no longer be admin. JIRA: SNAPS-274 Change-Id: I02957f69e31a9d4dfa63362d371f061687e59fbf Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/config/router.py')
-rw-r--r--snaps/config/router.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/snaps/config/router.py b/snaps/config/router.py
index ae84038..f5bbbf0 100644
--- a/snaps/config/router.py
+++ b/snaps/config/router.py
@@ -61,7 +61,7 @@ class RouterConfig(object):
if not self.name:
raise RouterConfigError('Name is required')
- def dict_for_neutron(self, neutron, os_creds, project_id):
+ def dict_for_neutron(self, neutron, os_creds):
"""
Returns a dictionary object representing this object.
This is meant to be converted into JSON designed for use by the Neutron
@@ -73,23 +73,20 @@ class RouterConfig(object):
:param os_creds: The OpenStack credentials for retrieving the keystone
client for looking up the project ID when the
self.project_name is not None
- :param project_id: the associated project ID to use when
- self.project_name is None
:return: the dictionary object
"""
out = dict()
ext_gw = dict()
+ keystone = keystone_utils.keystone_client(os_creds)
+
if self.name:
out['name'] = self.name
if self.project_name:
- keystone = keystone_utils.keystone_client(os_creds)
project = keystone_utils.get_project(
keystone=keystone, project_name=self.project_name)
if project:
- project_id = project.id
- if project_id:
- out['tenant_id'] = project_id
+ out['tenant_id'] = project.id
else:
raise RouterConfigError(
'Could not find project ID for project named - ' +
@@ -98,7 +95,7 @@ class RouterConfig(object):
out['admin_state_up'] = self.admin_state_up
if self.external_gateway:
ext_net = neutron_utils.get_network(
- neutron, network_name=self.external_gateway)
+ neutron, keystone, network_name=self.external_gateway)
if ext_net:
ext_gw['network_id'] = ext_net.id
out['external_gateway_info'] = ext_gw