X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_policy_module%2Fcommon%2Fcommon_db_client.py;h=2be3693cb53bd7c5ada5b828dfc923d1378c14bf;hb=baec43bd41e02bf37c90c4cfdea5de9eb7dd3ce3;hp=83bb46c4b1edda3dfdf7e8fbaf0eccc53f9e0b48;hpb=8d2d6a02f2282c50a934ccab25fc909e3bbc27c6;p=osm%2FPOL.git diff --git a/osm_policy_module/common/common_db_client.py b/osm_policy_module/common/common_db_client.py index 83bb46c..2be3693 100644 --- a/osm_policy_module/common/common_db_client.py +++ b/osm_policy_module/common/common_db_client.py @@ -24,14 +24,14 @@ from osm_common import dbmongo from osm_policy_module.core.config import Config +from osm_policy_module.core.exceptions import VdurNotFound class CommonDbClient: def __init__(self): cfg = Config.instance() self.common_db = dbmongo.DbMongo() - self.common_db.db_connect({'host': cfg.OSMPOL_DATABASE_HOST, - 'port': int(cfg.OSMPOL_DATABASE_PORT), + self.common_db.db_connect({'uri': cfg.OSMPOL_DATABASE_URI, 'name': 'osm'}) def get_vnfr(self, nsr_id: str, member_index: int): @@ -57,3 +57,11 @@ class CommonDbClient: nslcmop = self.common_db.get_one("nslcmops", {"_id": nslcmop_id}) return nslcmop + + def get_vdur(self, nsr_id, member_index, vdur_name): + vnfr = self.get_vnfr(nsr_id, member_index) + for vdur in vnfr['vdur']: + if vdur['name'] == vdur_name: + return vdur + raise VdurNotFound('vdur not found for nsr-id %s, member_index %s and vdur_name %s', nsr_id, member_index, + vdur_name)