Adds check for config param in vim_account dict to avoid errors when it does not... 44/7844/2
authorBenjamin Diaz <bdiaz@whitestack.com>
Tue, 13 Aug 2019 16:50:09 +0000 (13:50 -0300)
committerBenjamin Diaz <bdiaz@whitestack.com>
Tue, 13 Aug 2019 18:52:59 +0000 (15:52 -0300)
Change-Id: Iceb0b03a67464ff35ec5e700e5e3b1be92cb48b9
Signed-off-by: Benjamin Diaz <bdiaz@whitestack.com>
osm_mon/collector/utils/openstack.py
osm_mon/core/common_db.py

index 41e96e7..3a2b1b9 100644 (file)
@@ -30,14 +30,16 @@ class OpenstackUtils:
 
     @staticmethod
     def get_session(creds: dict):
-        verify_ssl = False if 'insecure' in creds['config'] and creds['config']['insecure'] else True
-        vim_config = creds['config']
+        verify_ssl = True
         project_domain_name = 'Default'
         user_domain_name = 'Default'
-        if 'project_domain_name' in vim_config:
-            project_domain_name = vim_config['project_domain_name']
-        if 'user_domain_name' in vim_config:
-            user_domain_name = vim_config['user_domain_name']
+        if 'config' in creds:
+            vim_config = creds['config']
+            verify_ssl = False if 'insecure' in vim_config and vim_config['insecure'] else True
+            if 'project_domain_name' in vim_config:
+                project_domain_name = vim_config['project_domain_name']
+            if 'user_domain_name' in vim_config:
+                user_domain_name = vim_config['user_domain_name']
         auth = v3.Password(auth_url=creds['vim_url'],
                            username=creds['vim_user'],
                            password=creds['vim_password'],
index 88a509c..8df8672 100644 (file)
@@ -102,11 +102,12 @@ class CommonDbClient:
         vim_config_encrypted = vim_config_encrypted_dict['default']
         if vim_account['schema_version'] in vim_config_encrypted_dict.keys():
             vim_config_encrypted = vim_config_encrypted_dict[vim_account['schema_version']]
-        for key in vim_account['config']:
-            if key in vim_config_encrypted:
-                vim_account['config'][key] = self.decrypt_vim_password(vim_account['config'][key],
-                                                                       vim_account['schema_version'],
-                                                                       vim_account_id)
+        if 'config' in vim_account:
+            for key in vim_account['config']:
+                if key in vim_config_encrypted:
+                    vim_account['config'][key] = self.decrypt_vim_password(vim_account['config'][key],
+                                                                           vim_account['schema_version'],
+                                                                           vim_account_id)
         return vim_account
 
     def get_sdncs(self):