From: Benjamin Diaz Date: Tue, 13 Aug 2019 16:50:09 +0000 (-0300) Subject: Adds check for config param in vim_account dict to avoid errors when it does not... X-Git-Tag: v6.0.2rc1~1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F80%2F7880%2F1;p=osm%2FMON.git Adds check for config param in vim_account dict to avoid errors when it does not exist Change-Id: Iceb0b03a67464ff35ec5e700e5e3b1be92cb48b9 Signed-off-by: Benjamin Diaz (cherry picked from commit 32935034e832a88a21c88f66d2f18b9d48ffc720) --- diff --git a/osm_mon/collector/utils/openstack.py b/osm_mon/collector/utils/openstack.py index 41e96e7..3a2b1b9 100644 --- a/osm_mon/collector/utils/openstack.py +++ b/osm_mon/collector/utils/openstack.py @@ -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'], diff --git a/osm_mon/core/common_db.py b/osm_mon/core/common_db.py index 88a509c..8df8672 100644 --- a/osm_mon/core/common_db.py +++ b/osm_mon/core/common_db.py @@ -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):