diff options
author | 2020-10-14 08:52:49 +0100 | |
---|---|---|
committer | 2020-11-19 09:16:15 +0000 | |
commit | 4b2b1445bef3b760ed29efa1c7c78977dde73452 (patch) | |
tree | fd92bb19794e9e74567cffa5788725041a66b468 /components/pm-subscription-handler/pmsh_service | |
parent | 062c4a7c72a1b45bc2e37a04b469321c5abc9d97 (diff) |
[PMSH] Add Resource Name to filter options
Issue-ID: DCAEGEN2-2402
Change-Id: I2242d36ca34e0b8ac085ce790b19b7ad51352c63
Signed-off-by: egernug <gerard.nugent@est.tech>
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service')
4 files changed, 22 insertions, 8 deletions
diff --git a/components/pm-subscription-handler/pmsh_service/mod/aai_client.py b/components/pm-subscription-handler/pmsh_service/mod/aai_client.py index 48f757da..fff91e7e 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/aai_client.py +++ b/components/pm-subscription-handler/pmsh_service/mod/aai_client.py @@ -138,7 +138,7 @@ def _filter_nf_data(nf_data, app_conf): ip_address=nf['properties'].get('ipaddress-v4-oam'), model_invariant_id=nf['properties'].get('model-invariant-id'), model_version_id=nf['properties'].get('model-version-id')) - if not new_nf.set_sdnc_params(app_conf): + if not new_nf.set_nf_model_params(app_conf): continue if app_conf.nf_filter.is_nf_in_filter(new_nf): nf_list.append(new_nf) diff --git a/components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py b/components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py index f39f1f46..fd9f6252 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py +++ b/components/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py @@ -66,7 +66,7 @@ def process_aai_events(mr_sub, mr_pub, app, app_conf): ip_address=aai_entity['ipaddress-v4-oam'], model_invariant_id=aai_entity['model-invariant-id'], model_version_id=aai_entity['model-version-id']) - if not nf.set_sdnc_params(app_conf): + if not nf.set_nf_model_params(app_conf): continue if app_conf.nf_filter.is_nf_in_filter(nf): _process_event(action, nf, mr_pub, app_conf) diff --git a/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py b/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py index b6735cc9..ea9603ef 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py +++ b/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py @@ -60,6 +60,7 @@ class NetworkFunctionModel(db.Model): ip_address = Column(String(50)) model_invariant_id = Column(String(100)) model_version_id = Column(String(100)) + model_name = Column(String(100)) sdnc_model_name = Column(String(100)) sdnc_model_version = Column(String(100)) @@ -68,12 +69,14 @@ class NetworkFunctionModel(db.Model): cascade='all, delete-orphan', backref='nf') - def __init__(self, nf_name, ip_address, model_invariant_id, model_version_id, sdnc_model_name, + def __init__(self, nf_name, ip_address, model_invariant_id, + model_version_id, model_name, sdnc_model_name, sdnc_model_version): self.nf_name = nf_name self.ip_address = ip_address self.model_invariant_id = model_invariant_id self.model_version_id = model_version_id + self.model_name = model_name self.sdnc_model_name = sdnc_model_name self.sdnc_model_version = sdnc_model_version @@ -128,5 +131,6 @@ class NfSubRelationalModel(db.Model): 'nf_sub_status': self.nf_sub_status, 'model_invariant_id': nf.model_invariant_id, 'model_version_id': nf.model_version_id, + 'model_name': nf.model_name, 'sdnc_model_name': nf.sdnc_model_name, 'sdnc_model_version': nf.sdnc_model_version} diff --git a/components/pm-subscription-handler/pmsh_service/mod/network_function.py b/components/pm-subscription-handler/pmsh_service/mod/network_function.py index 3f383885..a6d2164f 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/network_function.py +++ b/components/pm-subscription-handler/pmsh_service/mod/network_function.py @@ -30,12 +30,14 @@ class NetworkFunction: self.ip_address = kwargs.get('ip_address') self.model_invariant_id = kwargs.get('model_invariant_id') self.model_version_id = kwargs.get('model_version_id') + self.model_name = kwargs.get('model_name') self.sdnc_model_name = sdnc_model_name self.sdnc_model_version = sdnc_model_version @classmethod def nf_def(cls): - return cls(nf_name=None, ip_address=None, model_invariant_id=None, model_version_id=None, + return cls(nf_name=None, ip_address=None, model_invariant_id=None, + model_version_id=None, model_name=None, sdnc_model_name=None, sdnc_model_version=None) def __str__(self): @@ -43,6 +45,7 @@ class NetworkFunction: f'ipaddress-v4-oam: {self.ip_address}, ' \ f'model-invariant-id: {self.model_invariant_id}, ' \ f'model-version-id: {self.model_version_id}, ' \ + f'model-name: {self.model_name}, ' \ f'sdnc-model-name: {self.sdnc_model_name}, ' \ f'sdnc-model-version: {self.sdnc_model_version}' @@ -52,12 +55,14 @@ class NetworkFunction: self.ip_address == other.ip_address and \ self.model_invariant_id == other.model_invariant_id and \ self.model_version_id == other.model_version_id and \ + self.model_name == other.model_name and \ self.sdnc_model_name == other.sdnc_model_name and \ self.sdnc_model_version == other.sdnc_model_version def __hash__(self): return hash((self.nf_name, self.ip_address, self.model_invariant_id, - self.model_version_id, self.sdnc_model_name, self.sdnc_model_version)) + self.model_version_id, self.model_name, + self.sdnc_model_name, self.sdnc_model_version)) def create(self): """ Creates a NetworkFunction database entry """ @@ -69,6 +74,7 @@ class NetworkFunction: ip_address=self.ip_address, model_invariant_id=self.model_invariant_id, model_version_id=self.model_version_id, + model_name=self.model_name, sdnc_model_name=self.sdnc_model_name, sdnc_model_version=self.sdnc_model_version) db.session.add(new_nf) @@ -80,23 +86,24 @@ class NetworkFunction: f' returning this network function..') return existing_nf - def set_sdnc_params(self, app_conf): + def set_nf_model_params(self, app_conf): params_set = True try: sdnc_model_data = mod.aai_client.get_aai_model_data(app_conf, self.model_invariant_id, self.model_version_id, self.nf_name) + try: self.sdnc_model_name = sdnc_model_data['sdnc-model-name'] self.sdnc_model_version = sdnc_model_data['sdnc-model-version'] + self.model_name = sdnc_model_data['model-name'] return params_set except KeyError as e: logger.info(f'Skipping NF {self.nf_name} as there is no ' f'sdnc-model data associated in AAI: {e}', exc_info=True) - return not params_set except Exception as e: logger.error(f'Failed to get sdnc-model info for XNF {self.nf_name} from AAI: {e}', exc_info=True) - return not params_set + return not params_set @staticmethod def get(nf_name): @@ -140,6 +147,7 @@ class NetworkFunctionFilter: self.nf_names = kwargs.get('nfNames') self.model_invariant_ids = kwargs.get('modelInvariantIDs') self.model_version_ids = kwargs.get('modelVersionIDs') + self.model_names = kwargs.get('modelNames') self.regex_matcher = re.compile('|'.join(raw_regex for raw_regex in self.nf_names)) def is_nf_in_filter(self, nf): @@ -158,4 +166,6 @@ class NetworkFunctionFilter: match = False if self.model_version_ids and nf.model_version_id not in self.model_version_ids: match = False + if self.model_names and nf.model_name not in self.model_names: + match = False return match |