From 40f7b99f1481b5c483fcb43cf084b1c706fb7f82 Mon Sep 17 00:00:00 2001 From: Andrew McLeod Date: Fri, 30 Nov 2018 13:05:57 +0100 Subject: [PATCH] Testing fix suggested in https://bugs.launchpad.net/openstack-bundles/+bug/1803700 --- development/shared/neutron-ext-net-ksv3 | 15 ++++++++++++++- development/shared/neutron-tenant-net-ksv3 | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/development/shared/neutron-ext-net-ksv3 b/development/shared/neutron-ext-net-ksv3 index fb0ee1bf..f8ebca6d 100755 --- a/development/shared/neutron-ext-net-ksv3 +++ b/development/shared/neutron-ext-net-ksv3 @@ -71,8 +71,21 @@ if __name__ == '__main__': keystone = v3.Client(session=sess) quantum = client.Client(session=sess) + # Resolve domain id + domain_id = None + for dom in [t._info for t in keystone.domains.list()]: + if (dom['name'] == (os.environ['OS_PROJECT_DOMAIN_NAME'])): + domain_id = dom['id'] + break # Domain ID found - stop looking + if not domain_id: + logging.error("Unable to locate domain for %s.", os.environ['OS_PROJECT_DOMAIN_NAME']); + # Resolve tenant id - project_id = auth.get_project_id(sess) + project_id = None + for proj in [t._info for t in keystone.projects.list()]: + if (proj['domain_id'] == domain_id and proj['name'] == (opts.project or os.environ['OS_PROJECT_NAME'])): + project_id = proj['id'] + break # Tenant ID found - stop looking if not project_id: logging.error("Unable to locate project id for %s.", opts.tenant) sys.exit(1) diff --git a/development/shared/neutron-tenant-net-ksv3 b/development/shared/neutron-tenant-net-ksv3 index 7fc56918..47562c85 100755 --- a/development/shared/neutron-tenant-net-ksv3 +++ b/development/shared/neutron-tenant-net-ksv3 @@ -71,8 +71,21 @@ if __name__ == '__main__': keystone = v3.Client(session=sess) quantum = client.Client(session=sess) + # Resolve domain id + domain_id = None + for dom in [t._info for t in keystone.domains.list()]: + if (dom['name'] == (os.environ['OS_PROJECT_DOMAIN_NAME'])): + domain_id = dom['id'] + break # Domain ID found - stop looking + if not domain_id: + logging.error("Unable to locate domain for %s.", os.environ['OS_PROJECT_DOMAIN_NAME']); + # Resolve tenant id - project_id = auth.get_project_id(sess) + project_id = None + for proj in [t._info for t in keystone.projects.list()]: + if (proj['domain_id'] == domain_id and proj['name'] == (opts.project or os.environ['OS_PROJECT_NAME'])): + project_id = proj['id'] + break # Tenant ID found - stop looking if not project_id: logging.error("Unable to locate project id for %s.", opts.tenant) sys.exit(1)