Modifies MON to use mongodb directly for vim info and do vim pass decryption on demand
Change-Id: Id088f60bcbe7943661d088f949b55465c4939800
Signed-off-by: Benjamin Diaz <bdiaz@whitestack.com>
diff --git a/osm_mon/server/server.py b/osm_mon/server/server.py
index 1e3e7f8..44b2340 100755
--- a/osm_mon/server/server.py
+++ b/osm_mon/server/server.py
@@ -50,7 +50,6 @@
async def start(self):
topics = [
- "vim_account",
"alarm_request"
]
await self.msg_bus.aioread(topics, self._process_msg)
@@ -58,24 +57,8 @@
async def _process_msg(self, topic, key, values):
log.info("Message arrived: %s", values)
try:
- if topic == "vim_account":
- if key == "create" or key == "edit":
- if 'config' not in values:
- values['config'] = {}
- self.service.upsert_vim_account(values['_id'],
- values['name'],
- values['vim_type'],
- values['vim_url'],
- values['vim_user'],
- values['vim_password'],
- values['vim_tenant_name'],
- values['schema_version'],
- values['config'])
- if key == "delete":
- self.service.delete_vim_account(values['_id'])
-
- elif topic == "alarm_request":
+ if topic == "alarm_request":
if key == "create_alarm_request":
alarm_details = values['alarm_create_request']
cor_id = alarm_details['correlation_id']
diff --git a/osm_mon/server/service.py b/osm_mon/server/service.py
index 43a0d8e..a14ba5f 100755
--- a/osm_mon/server/service.py
+++ b/osm_mon/server/service.py
@@ -20,14 +20,13 @@
# For those usages not covered by the Apache License, Version 2.0 please
# contact: bdiaz@whitestack.com or glavado@whitestack.com
##
-import json
import logging
import uuid
from osm_mon.core import database
from osm_mon.core.common_db import CommonDbClient
from osm_mon.core.config import Config
-from osm_mon.core.database import VimCredentialsRepository, VimCredentials, AlarmRepository, Alarm
+from osm_mon.core.database import AlarmRepository, Alarm
log = logging.getLogger(__name__)
@@ -37,51 +36,6 @@
def __init__(self, config: Config):
self.common_db = CommonDbClient(config)
- def upsert_vim_account(self,
- vim_uuid: str,
- name: str,
- vim_type: str,
- url: str,
- user: str,
- password: str,
- tenant_name: str,
- schema_version: str,
- config: dict) -> VimCredentials:
- decrypted_vim_password = self.common_db.decrypt_vim_password(password,
- schema_version,
- vim_uuid)
-
- vim_config_encrypted = ("admin_password", "nsx_password", "vcenter_password")
- for key in config:
- if key in vim_config_encrypted:
- config[key] = self.common_db.decrypt_vim_password(config[key],
- schema_version,
- vim_uuid)
- database.db.connect()
- try:
- with database.db.atomic():
- return VimCredentialsRepository.upsert(
- uuid=vim_uuid,
- name=name,
- type=vim_type,
- url=url,
- user=user,
- password=decrypted_vim_password,
- tenant_name=tenant_name,
- config=json.dumps(config)
- )
- finally:
- database.db.close()
-
- def delete_vim_account(self, vim_uuid: str) -> None:
- database.db.connect()
- try:
- with database.db.atomic():
- vim_credentials = VimCredentialsRepository.get(VimCredentials.uuid == vim_uuid)
- vim_credentials.delete_instance()
- finally:
- database.db.close()
-
def create_alarm(self,
name: str,
threshold: str,