projects
/
osm
/
MON.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Adds pylint to tox test pipeline and fixes related errors
[osm/MON.git]
/
osm_mon
/
core
/
auth.py
diff --git
a/osm_mon/core/auth.py
b/osm_mon/core/auth.py
index
7b61fe1
..
4627a30
100644
(file)
--- a/
osm_mon/core/auth.py
+++ b/
osm_mon/core/auth.py
@@
-23,16
+23,21
@@
##
import json
##
import json
+import logging
+
+from osm_mon.core.config import Config
from osm_mon.core.database import VimCredentials, DatabaseManager
from osm_mon.core.database import VimCredentials, DatabaseManager
+log = logging.getLogger(__name__)
-class AuthManager:
- def __init__(self):
- self.database_manager = DatabaseManager()
+class AuthManager:
+ def __init__(self, config: Config):
+ self.database_manager = DatabaseManager(config)
def store_auth_credentials(self, creds_dict):
def store_auth_credentials(self, creds_dict):
+ log.info(creds_dict)
credentials = VimCredentials()
credentials.uuid = creds_dict['_id']
credentials.name = creds_dict['name']
credentials = VimCredentials()
credentials.uuid = creds_dict['_id']
credentials.name = creds_dict['name']
@@
-41,14
+46,23
@@
class AuthManager:
credentials.user = creds_dict['vim_user']
credentials.password = creds_dict['vim_password']
credentials.tenant_name = creds_dict['vim_tenant_name']
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'])
self.database_manager.save_credentials(credentials)
def get_credentials(self, vim_uuid):
credentials.config = json.dumps(creds_dict['config'])
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 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