X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcommon%2Fcommon_db_client.py;h=716f1709cce579594233865cd1b47cf96cca49c7;hb=e27def0d99cc73c5c0b7550a28e95abd6c1cd996;hp=c6237eec941a0d5355ad8faf07934bc3474562d4;hpb=cca77765cc8d43a0a5524e3754b7587b149300b4;p=osm%2FMON.git diff --git a/osm_mon/common/common_db_client.py b/osm_mon/common/common_db_client.py index c6237ee..716f170 100644 --- a/osm_mon/common/common_db_client.py +++ b/osm_mon/common/common_db_client.py @@ -32,19 +32,20 @@ class CommonDbClient: self.common_db = dbmongo.DbMongo() self.common_db.db_connect({'host': cfg.MONGO_URI.split(':')[0], 'port': int(cfg.MONGO_URI.split(':')[1]), - 'name': 'osm'}) + 'name': 'osm', + 'commonkey': cfg.OSMMON_DATABASE_COMMONKEY}) def get_vnfr(self, nsr_id: str, member_index: int): vnfr = self.common_db.get_one("vnfrs", {"nsr-id-ref": nsr_id, "member-vnf-index-ref": str(member_index)}) return vnfr - def get_vnfrs(self, nsr_id: str): - return [self.get_vnfr(nsr_id, member['member-vnf-index']) for member in - self.get_nsr(nsr_id)['nsd']['constituent-vnfd']] - - def get_vnfrs(self): - return self.common_db.get_list('vnfrs') + def get_vnfrs(self, nsr_id: str = None): + if nsr_id: + return [self.get_vnfr(nsr_id, member['member-vnf-index']) for member in + self.get_nsr(nsr_id)['nsd']['constituent-vnfd']] + else: + return self.common_db.get_list('vnfrs') def get_vnfd(self, vnfd_id: str): vnfr = self.common_db.get_one("vnfds", @@ -68,3 +69,6 @@ class CommonDbClient: return vdur raise ValueError('vdur not found for nsr-id %s, member_index %s and vdu_name %s', nsr_id, member_index, vdu_name) + + def decrypt_vim_password(self, vim_password: str, schema_version: str, vim_id: str): + return self.common_db.decrypt(vim_password, schema_version, vim_id)