diff options
author | spisarski <s.pisarski@cablelabs.com> | 2018-05-29 10:53:55 -0600 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2018-05-29 10:53:55 -0600 |
commit | f17b5d4631682b4807dc1c4267da65258413ef73 (patch) | |
tree | fa4f5b2ae8b3ed3e5005467992bd7584783a3355 /snaps/openstack/utils | |
parent | 5a81c2abb920cfe5ea975c37b390838d586a98b1 (diff) |
Fixed issue when attempting to add an internal subnet to a router.
Internal subnets that are owned by the same user who is creating a
router now can be added properly. Attempted to fix an issue with the
change in https://gerrit.opnfv.org/gerrit/#/c/57853/ that was allowing
for subnets with the same name to be assigned but ended up breaking
this functionality completely.
JIRA: SNAPS-312
Change-Id: I1687f66db47520e93e401d3e9fb5f0c4f45d460f
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/utils')
-rw-r--r-- | snaps/openstack/utils/neutron_utils.py | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/snaps/openstack/utils/neutron_utils.py b/snaps/openstack/utils/neutron_utils.py index 8783690..78731ae 100644 --- a/snaps/openstack/utils/neutron_utils.py +++ b/snaps/openstack/utils/neutron_utils.py @@ -262,20 +262,17 @@ def get_subnet_by_name(neutron, keystone, subnet_name, project_name=None): retrieve :return: a SNAPS-OO Subnet domain object or None """ - project = None - if project_name: - project = keystone_utils.get_project( - keystone, project_name=project_name) - if project: - sub_filter = {'name': subnet_name, 'project_id': project.id} - subnets = neutron.list_subnets(**sub_filter) - for subnet in subnets['subnets']: - return Subnet(**subnet) - else: - sub_filter = {'name': subnet_name} - subnets = neutron.list_subnets(**sub_filter) - for subnet in subnets['subnets']: - return Subnet(**subnet) + sub_filter = {'name': subnet_name} + subnets = neutron.list_subnets(**sub_filter) + for subnet in subnets['subnets']: + subnet = Subnet(**subnet) + if project_name: + project = keystone_utils.get_project_by_id( + keystone, subnet.project_id) + if project: + return subnet + else: + return subnet def get_subnet_by_id(neutron, subnet_id): |