From 6df433f173c0117e3bf2f70c8b51bbd51ce2c1e4 Mon Sep 17 00:00:00 2001 From: tierno Date: Fri, 4 Sep 2020 14:42:29 +0000 Subject: [PATCH] fix 1204: For openstack VIM use domain_id or domain_name provided by client for both project and user. So the client can provide only the 'id', only the 'name', or both. Only when no one is provided it is assume the value 'default' for the 'id' Change-Id: I60acf26dfdbfa20f10df6e60587080a430f5fe8b Signed-off-by: tierno --- osm_mon/collector/utils/openstack.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/osm_mon/collector/utils/openstack.py b/osm_mon/collector/utils/openstack.py index 09c472c..039ce61 100644 --- a/osm_mon/collector/utils/openstack.py +++ b/osm_mon/collector/utils/openstack.py @@ -31,8 +31,10 @@ class OpenstackUtils: @staticmethod def get_session(creds: dict): verify_ssl = True - project_domain_name = 'Default' - user_domain_name = 'Default' + project_domain_id = None + user_domain_id = None + project_domain_name = None + user_domain_name = None if 'config' in creds: vim_config = creds['config'] if 'insecure' in vim_config and vim_config['insecure']: @@ -41,12 +43,22 @@ class OpenstackUtils: verify_ssl = vim_config['ca_cert'] if 'project_domain_name' in vim_config: project_domain_name = vim_config['project_domain_name'] + if 'project_domain_id' in vim_config: + project_domain_id = vim_config['project_domain_id'] if 'user_domain_name' in vim_config: user_domain_name = vim_config['user_domain_name'] + if 'user_domain_id' in vim_config: + user_domain_id = vim_config['user_domain_id'] + if not project_domain_id and not project_domain_name: + project_domain_id = 'default' + if not user_domain_id and not user_domain_name: + user_domain_id = 'default' auth = v3.Password(auth_url=creds['vim_url'], username=creds['vim_user'], password=creds['vim_password'], project_name=creds['vim_tenant_name'], project_domain_name=project_domain_name, - user_domain_name=user_domain_name) + project_domain_id=project_domain_id, + user_domain_name=user_domain_name, + user_domain_id=user_domain_id) return session.Session(auth=auth, verify=verify_ssl, timeout=10) -- 2.25.1