X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcore%2Fauth.py;h=6f5e20ad30cead534c735aac27d0cf46bb043d86;hb=refs%2Fchanges%2F68%2F5968%2F1;hp=bdc049891c43d72fe56dadbfea3ba9fc84fdc6d0;hpb=b3f86c9f43a0eb4d56487118a403c39f979ec042;p=osm%2FMON.git diff --git a/osm_mon/core/auth.py b/osm_mon/core/auth.py index bdc0498..6f5e20a 100644 --- a/osm_mon/core/auth.py +++ b/osm_mon/core/auth.py @@ -32,23 +32,31 @@ class AuthManager: def __init__(self): self.database_manager = DatabaseManager() - def store_auth_credentials(self, message): - values = json.loads(message.value) + def store_auth_credentials(self, creds_dict): credentials = VimCredentials() - credentials.uuid = values['_id'] - credentials.name = values['name'] - credentials.type = values['vim_type'] - credentials.url = values['vim_url'] - credentials.user = values['vim_user'] - credentials.password = values['vim_password'] - credentials.tenant_name = values['vim_tenant_name'] - credentials.config = json.dumps(values['config']) + credentials.uuid = creds_dict['_id'] + credentials.name = creds_dict['name'] + credentials.type = creds_dict['vim_type'] + credentials.url = creds_dict['vim_url'] + credentials.user = creds_dict['vim_user'] + credentials.password = creds_dict['vim_password'] + credentials.tenant_name = creds_dict['vim_tenant_name'] + 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) - def delete_auth_credentials(self, message): - # TODO - pass + def delete_auth_credentials(self, creds_dict): + credentials = self.get_credentials(creds_dict['_id']) + if credentials: + credentials.delete_instance()