fix 1204: For openstack VIM use domain_id or domain_name provided by client 84/9684/2
authortierno <alfonso.tiernosepulveda@telefonica.com>
Fri, 4 Sep 2020 14:42:29 +0000 (14:42 +0000)
committerpalsus <subhankar.pal@altran.com>
Thu, 8 Oct 2020 09:27:52 +0000 (11:27 +0200)
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 <alfonso.tiernosepulveda@telefonica.com>
osm_mon/collector/utils/openstack.py

index 09c472c..039ce61 100644 (file)
@@ -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)