X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcore%2Fauth.py;h=71a817e22efc15eb2179bf52d8952b510314f82e;hb=058d51d5f8ba1666242a12f52d99bdd74ec7f94f;hp=6f5e20ad30cead534c735aac27d0cf46bb043d86;hpb=6c10123aa1538801c01d20f659197918967a9b7f;p=osm%2FMON.git diff --git a/osm_mon/core/auth.py b/osm_mon/core/auth.py index 6f5e20a..71a817e 100644 --- a/osm_mon/core/auth.py +++ b/osm_mon/core/auth.py @@ -23,16 +23,19 @@ ## import json +import logging from osm_mon.core.database import VimCredentials, DatabaseManager +log = logging.getLogger(__name__) -class AuthManager: +class AuthManager: def __init__(self): self.database_manager = DatabaseManager() def store_auth_credentials(self, creds_dict): + log.info(creds_dict) credentials = VimCredentials() credentials.uuid = creds_dict['_id'] credentials.name = creds_dict['name'] @@ -41,22 +44,23 @@ class AuthManager: credentials.user = creds_dict['vim_user'] credentials.password = creds_dict['vim_password'] credentials.tenant_name = creds_dict['vim_tenant_name'] + if 'config' not in creds_dict: + creds_dict['config'] = {} credentials.config = json.dumps(creds_dict['config']) - if creds_dict.get('OS_REGION_NAME'): - credentials.region_name = creds_dict['OS_REGION_NAME'] - else: - credentials.region_name = "RegionOne" - if creds_dict.get('OS_ENDPOINT_TYPE'): - credentials.endpoint_type = creds_dict['OS_ENDPOINT_TYPE'] - else: - credentials.endpoint_type = "publicURL" self.database_manager.save_credentials(credentials) def get_credentials(self, vim_uuid): - return self.database_manager.get_credentials(vim_uuid) + creds = self.database_manager.get_credentials(vim_uuid) + return creds def delete_auth_credentials(self, creds_dict): credentials = self.get_credentials(creds_dict['_id']) if credentials: credentials.delete_instance() + def get_config(self, vim_uuid): + return json.loads(self.get_credentials(vim_uuid).config) + + def is_verify_ssl(self, vim_uuid): + vim_config = self.get_config(vim_uuid) + return 'insecure' not in vim_config or vim_config['insecure'] is False