summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoregernug <gerard.nugent@est.tech>2020-08-19 14:57:36 +0100
committeregernug <gerard.nugent@est.tech>2020-09-08 09:28:01 +0100
commit2e3c407d0fcf8c73c5fd6714d6013e37930c92cb (patch)
treec9cac72011779bcd6ffdb7658653a08958fa524c
parente783ede93e1c0f2f76a332fc82f6e6a7f40f04fc (diff)
[PMSH] Enhance Filtering Mechanism
Issue-ID: DCAEGEN2-2151 Signed-off-by: egernug <gerard.nugent@est.tech> Change-Id: Ib6c207ac08a54dea06346596ff11c980fa4cf5e8
-rwxr-xr-xcomponents/pm-subscription-handler/Changelog.md1
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/aai_client.py4
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/aai_event_handler.py4
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/network_function.py20
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py3
-rw-r--r--components/pm-subscription-handler/tests/data/aai_xnfs.json26
-rw-r--r--components/pm-subscription-handler/tests/data/cbs_data_1.json10
-rw-r--r--components/pm-subscription-handler/tests/data/filter_test_data.json171
-rwxr-xr-xcomponents/pm-subscription-handler/tests/data/mr_aai_events.json6
-rw-r--r--components/pm-subscription-handler/tests/test_network_function_filter.py86
-rwxr-xr-xcomponents/pm-subscription-handler/tests/test_subscription.py8
-rw-r--r--components/pm-subscription-handler/tox.ini1
12 files changed, 311 insertions, 29 deletions
diff --git a/components/pm-subscription-handler/Changelog.md b/components/pm-subscription-handler/Changelog.md
index 83caf2ca..8f4ce1b5 100755
--- a/components/pm-subscription-handler/Changelog.md
+++ b/components/pm-subscription-handler/Changelog.md
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.1.1]
### Changed
* Moved to alpine base image (DCAEGEN2-2292)
+* Added model-invariant-id and model-version-id to filter (DCAEGEN2-2151)
## [1.1.0]
### Changed
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 5a3c543a..c8dea9f7 100755
--- a/components/pm-subscription-handler/pmsh_service/mod/aai_client.py
+++ b/components/pm-subscription-handler/pmsh_service/mod/aai_client.py
@@ -128,8 +128,10 @@ def _filter_nf_data(nf_data, nf_filter):
for nf in nf_data['results']:
name_identifier = 'pnf-name' if nf['node-type'] == 'pnf' else 'vnf-name'
orchestration_status = nf['properties'].get('orchestration-status')
+ model_invariant_id = nf['properties'].get('model-invariant-id')
+ model_version_id = nf['properties'].get('model-version-id')
if nf_filter.is_nf_in_filter(nf['properties'].get(name_identifier),
- orchestration_status):
+ model_invariant_id, model_version_id, orchestration_status):
nf_set.add(NetworkFunction(
nf_name=nf['properties'].get(name_identifier),
orchestration_status=orchestration_status))
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 60b69602..92369322 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
@@ -59,8 +59,10 @@ def process_aai_events(mr_sub, mr_pub, app, app_conf):
xnf_name = aai_entity['pnf-name'] if entity_type == XNFType.PNF.value \
else aai_entity['vnf-name']
new_status = aai_entity['orchestration-status']
+ model_invariant_id = aai_entity['model-invariant-id']
+ model_version_id = aai_entity['model-version-id']
- if app_conf.nf_filter.is_nf_in_filter(xnf_name, new_status):
+ if app_conf.nf_filter.is_nf_in_filter(xnf_name, model_invariant_id, model_version_id, new_status):
_process_event(action, new_status, xnf_name, mr_pub, app_conf)
except Exception as e:
logger.error(f'Failed to process AAI event: {e}', exc_info=True)
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 191e9512..62cd546f 100755
--- a/components/pm-subscription-handler/pmsh_service/mod/network_function.py
+++ b/components/pm-subscription-handler/pmsh_service/mod/network_function.py
@@ -90,21 +90,33 @@ class NetworkFunction:
db.session.commit()
+
class NetworkFunctionFilter:
def __init__(self, **kwargs):
- self.nf_sw_version = kwargs.get('swVersions')
self.nf_names = kwargs.get('nfNames')
+ self.model_invariant_ids = kwargs.get('modelInvariantUUIDs')
+ self.model_version_ids = kwargs.get('modelVersionIDs')
self.regex_matcher = re.compile('|'.join(raw_regex for raw_regex in self.nf_names))
- def is_nf_in_filter(self, nf_name, orchestration_status):
+ def is_nf_in_filter(self, nf_name, model_invariant_id, model_version_id, orchestration_status):
"""Match the nf name against regex values in Subscription.nfFilter.nfNames
Args:
nf_name (str): the AAI nf name.
+ invariant_uuid (str): the AAI model-invariant-id
+ uuid (str): the AAI model-version-id
orchestration_status (str): orchestration status of the nf
Returns:
bool: True if matched, else False.
"""
- return self.regex_matcher.search(nf_name) and \
- orchestration_status == 'Active'
+ match = True
+ if orchestration_status != 'Active':
+ match = False
+ if self.nf_names and self.regex_matcher.search(nf_name) is None:
+ match = False
+ if self.model_invariant_ids and not model_invariant_id in self.model_invariant_ids:
+ match = False
+ if self.model_version_ids and not model_version_id in self.model_version_ids:
+ match = False
+ return match
diff --git a/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py b/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py
index 872843d7..fd24fca9 100755
--- a/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py
+++ b/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py
@@ -118,9 +118,6 @@ class AppConfig:
raise ValueError('Failed to refresh AppConfig: INVALID JSON')
self.subscription.administrativeState = app_conf['policy']['subscription'][
'administrativeState']
- self.nf_filter.nf_names = app_conf['policy']['subscription']['nfFilter']['nfNames']
- self.nf_filter.nf_sw_version = app_conf['policy']['subscription']['nfFilter'][
- 'swVersions']
logger.info("AppConfig data has been refreshed")
except ValueError or Exception as e:
logger.error(e)
diff --git a/components/pm-subscription-handler/tests/data/aai_xnfs.json b/components/pm-subscription-handler/tests/data/aai_xnfs.json
index d0c2043e..ad92837d 100644
--- a/components/pm-subscription-handler/tests/data/aai_xnfs.json
+++ b/components/pm-subscription-handler/tests/data/aai_xnfs.json
@@ -17,6 +17,8 @@
"serial-number": "6061ZW3",
"ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab",
"resource-version": "1572609320819",
+ "model-invariant-id": "7129e420-d396-4efb-af02-6b83499b12f8",
+ "model-version-id": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
"nf-role": "gNB"
}
},
@@ -36,6 +38,8 @@
"serial-number": "6061ZW3",
"ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab",
"resource-version": "1573053304574",
+ "model-invariant-id": "687kj45-d396-4efb-af02-6b83499b12f8",
+ "model-version-id": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
"nf-role": "gNB",
"orchestration-status": "Active"
}
@@ -57,6 +61,8 @@
"serial-number": "6061ZW3",
"ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab",
"resource-version": "1573054784925",
+ "model-invariant-id": "8lk4578-d396-4efb-af02-6b83499b12f8",
+ "model-version-id": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
"nf-role": "gNB"
}
},
@@ -77,6 +83,8 @@
"serial-number": "6061ZW3",
"ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab",
"resource-version": "1572543742093",
+ "model-invariant-id": "356l489-d396-4efb-af02-6b83499b12f8",
+ "model-version-id": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
"nf-role": "gNB"
}
},
@@ -97,6 +105,8 @@
"serial-number": "6061ZW3",
"ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab",
"resource-version": "1573064215776",
+ "model-invariant-id": "597b524-d396-4efb-af02-6b83499b12f8",
+ "model-version-id": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
"nf-role": "gNB"
}
},
@@ -117,6 +127,8 @@
"serial-number": "6061ZW3",
"ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab",
"resource-version": "1573127626866",
+ "model-invariant-id": "4658489-j465-4efb-af02-6b83499b12f8",
+ "model-version-id": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
"nf-role": "gNB"
}
},
@@ -136,6 +148,8 @@
"serial-number": "6061ZW3",
"ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab",
"resource-version": "1573138552022",
+ "model-invariant-id": "158955jk-4lp8-4efb-af02-6b83499b12f8",
+ "model-version-id": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
"nf-role": "gNB"
}
},
@@ -147,7 +161,9 @@
"pnf-name": "my_pnf_is_bad",
"pnf-id": "4f043f83-3ddf-49d0-a878-ae6b2f9bd7e5",
"in-maint": false,
- "resource-version": "1574701401896"
+ "resource-version": "1574701401896",
+ "model-invariant-id": "j547l65-d396-4efb-af02-6b83499b12f8",
+ "model-version-id": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9"
}
},
{
@@ -164,7 +180,7 @@
"in-maint": false,
"is-closed-loop-disabled": false,
"resource-version": "1575541662410",
- "model-invariant-id": "7129e420-d396-4efb-af02-6b83499b12f8",
+ "model-invariant-id": "4kh7568-d396-4efb-af02-6b83499b12f8",
"model-version-id": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
"model-customization-id": "376dbe87-e9c5-4f2b-80e2-a420b373ee87"
}
@@ -183,7 +199,7 @@
"in-maint": false,
"is-closed-loop-disabled": false,
"resource-version": "1575541662410",
- "model-invariant-id": "7129e420-d396-4efb-af02-6b83499b12f8",
+ "model-invariant-id": "2566646-d396-4efb-af02-lk45879b12f8",
"model-version-id": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
"model-customization-id": "376dbe87-e9c5-4f2b-80e2-a420b373ee87"
}
@@ -202,8 +218,8 @@
"in-maint": false,
"is-closed-loop-disabled": false,
"resource-version": "1575542300539",
- "model-invariant-id": "c6aef848-e119-4572-9643-0b68da217358",
- "model-version-id": "77c1a3d9-422a-4f78-bd8f-f7a357685b25",
+ "model-invariant-id": "76254klj-d396-4efb-af02-6b83499b12f8",
+ "model-version-id": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
"model-customization-id": "1f6a305d-74b6-4b92-b407-cd03284b6432"
}
}
diff --git a/components/pm-subscription-handler/tests/data/cbs_data_1.json b/components/pm-subscription-handler/tests/data/cbs_data_1.json
index 75253c88..5c2e0296 100644
--- a/components/pm-subscription-handler/tests/data/cbs_data_1.json
+++ b/components/pm-subscription-handler/tests/data/cbs_data_1.json
@@ -6,13 +6,15 @@
"fileBasedGP":15,
"fileLocation":"\/pm\/pm.xml",
"nfFilter":{
- "swVersions":[
- "1.0.0",
- "1.0.1"
- ],
"nfNames":[
"^pnf.*",
"^vnf.*"
+ ],
+ "modelInvariantUUIDs": [
+
+ ],
+ "modelVersionIDs": [
+
]
},
"measurementGroups":[
diff --git a/components/pm-subscription-handler/tests/data/filter_test_data.json b/components/pm-subscription-handler/tests/data/filter_test_data.json
new file mode 100644
index 00000000..28dc61d1
--- /dev/null
+++ b/components/pm-subscription-handler/tests/data/filter_test_data.json
@@ -0,0 +1,171 @@
+[
+ {
+ "testName": "test_filter_true_on_xnf",
+ "nfFilter":{
+ "nfNames":[
+ "^pnf.*",
+ "^vnf.*"
+ ],
+ "modelInvariantUUIDs": [
+
+ ],
+ "modelVersionIDs": [
+
+ ]
+ },
+ "nfName": "pnf1",
+ "modelInvariantUUID": "7129e420-d396-4efb-af02-6b83499b12f8",
+ "modelVersionID": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
+ "orchestration_status": "Active",
+ "expectedResult": true
+ },
+ {
+ "testName": "test_filter_false_on_xnf",
+ "nfFilter":{
+ "nfNames":[
+ "^pnf.*",
+ "^vnf.*"
+ ],
+ "modelInvariantUUIDs": [
+
+ ],
+ "modelVersionIDs": [
+
+ ]
+ },
+ "nfName": "PNF-33",
+ "modelInvariantUUID": "7129e420-d396-4efb-af02-6b83499b12f8",
+ "modelVersionID": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
+ "orchestration_status": "Active",
+ "expectedResult": false
+ },
+ {
+ "testName": "test_filter_true_on_modelInvariantUUIDs",
+ "nfFilter":{
+ "nfNames":[
+ ],
+ "modelInvariantUUIDs": [
+ "5845y423-g654-6fju-po78-8n53154532k6",
+ "7129e420-d396-4efb-af02-6b83499b12f8"
+ ],
+ "modelVersionIDs": [
+
+ ]
+ },
+ "nfName": "pnf1",
+ "modelInvariantUUID": "7129e420-d396-4efb-af02-6b83499b12f8",
+ "modelVersionID": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
+ "orchestration_status": "Active",
+ "expectedResult": true
+ },
+ {
+ "testName": "test_filter_false_on_modelInvariantUUIDs",
+ "nfFilter":{
+ "nfNames":[
+ ],
+ "modelInvariantUUIDs": [
+ "5845y423-g654-6fju-po78-8n53154532k6",
+ "7129e420-d396-4efb-af02-6b83499b12f8"
+ ],
+ "modelVersionIDs": [
+
+ ]
+ },
+ "nfName": "pnf1",
+ "modelInvariantUUID": "WrongModelInvariantUUID",
+ "modelVersionID": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
+ "orchestration_status": "Active",
+ "expectedResult": false
+ },
+ {
+ "testName": "test_filter_false_on_modelInvariantUUIDs_being_false_and_pnfname_being_true",
+ "nfFilter":{
+ "nfNames":[
+ "^pnf.*",
+ "^vnf.*"
+ ],
+ "modelInvariantUUIDs": [
+ "7129e420-d396-4efb-af02-6b83499b12f8"
+ ],
+ "modelVersionIDs": [
+
+ ]
+ },
+ "nfName": "pnf1",
+ "modelInvariantUUID": "WrongModelInvariantUUID",
+ "modelVersionID": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
+ "orchestration_status": "Active",
+ "expectedResult": false
+ },
+ {
+ "testName": "test_filter_true_on_modelVersionIDs",
+ "nfFilter":{
+ "nfNames":[
+ ],
+ "modelInvariantUUIDs": [
+ ],
+ "modelVersionIDs": [
+ "e80a6ae3-cafd-4d24-850d-e14c084a5ca9"
+ ]
+ },
+ "nfName": "pnf1",
+ "modelInvariantUUID": "7129e420-d396-4efb-af02-6b83499b12f8",
+ "modelVersionID": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
+ "orchestration_status": "Active",
+ "expectedResult": true
+ },
+ {
+ "testName": "test_filter_false_on_modelVersionIDs",
+ "nfFilter":{
+ "nfNames":[
+ ],
+ "modelInvariantUUIDs": [
+ ],
+ "modelVersionIDs": [
+ "e80a6ae3-cafd-4d24-850d-e14c084a5ca9"
+ ]
+ },
+ "nfName": "pnf1",
+ "modelInvariantUUID": "7129e420-d396-4efb-af02-6b83499b12f8",
+ "modelVersionID": "WrongModelVersionID",
+ "orchestration_status": "Active",
+ "expectedResult": false
+ },
+ {
+ "testName": "test_filter_false_on_modelVersionIDs_being_false_and_pnfname_being_true",
+ "nfFilter":{
+ "nfNames":[
+ "^pnf.*",
+ "^vnf.*"
+ ],
+ "modelInvariantUUIDs": [
+ ],
+ "modelVersionIDs": [
+ "e80a6ae3-cafd-4d24-850d-e14c084a5ca9"
+ ]
+ },
+ "nfName": "pnf1",
+ "modelInvariantUUID": "7129e420-d396-4efb-af02-6b83499b12f8",
+ "modelVersionID": "WrongModelVersionID",
+ "orchestration_status": "Active",
+ "expectedResult": false
+ },
+ {
+ "testName": "test_filter_false_on_OrchestrationStatus",
+ "nfFilter":{
+ "nfNames":[
+ "^pnf.*",
+ "^vnf.*"
+ ],
+ "modelInvariantUUIDs": [
+ ],
+ "modelVersionIDs": [
+ ]
+ },
+ "nfName": "pnf1",
+ "modelInvariantUUID": "7129e420-d396-4efb-af02-6b83499b12f8",
+ "modelVersionID": "e80a6ae3-cafd-4d24-850d-e14c084a5ca9",
+ "orchestration_status": "Inventoried",
+ "expectedResult": false
+ }
+ ] \ No newline at end of file
diff --git a/components/pm-subscription-handler/tests/data/mr_aai_events.json b/components/pm-subscription-handler/tests/data/mr_aai_events.json
index 156a8e8d..19758982 100755
--- a/components/pm-subscription-handler/tests/data/mr_aai_events.json
+++ b/components/pm-subscription-handler/tests/data/mr_aai_events.json
@@ -1,8 +1,8 @@
{
"mr_response": [
- "{\"cambria.partition\":\"AAI\",\"event-header\":{\"severity\":\"NORMAL\",\"entity-type\":\"pnf\",\"top-entity-type\":\"pnf\",\"entity-link\":\"/aai/v16/network/pnfs/pnf/pnf_newly_discovered\",\"event-type\":\"AAI-EVENT\",\"domain\":\"dev\",\"action\":\"UPDATE\",\"sequence-number\":\"0\",\"id\":\"db09e090-196e-4f84-9645-e449b1cd3640\",\"source-name\":\"dcae-curl\",\"version\":\"v16\",\"timestamp\":\"20200203-15:14:08:807\"},\"entity\":{\"ipaddress-v4-oam\":\"10.10.10.37\",\"nf-role\":\"gNB\",\"equip-type\":\"val8\",\"relationship-list\":{\"relationship\":[{\"related-to\":\"service-instance\",\"relationship-data\":[{\"relationship-value\":\"Demonstration\",\"relationship-key\":\"customer.global-customer-id\"},{\"relationship-value\":\"vCPE\",\"relationship-key\":\"service-subscription.service-type\"},{\"relationship-value\":\"2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-key\":\"service-instance.service-instance-id\"}],\"related-link\":\"/aai/v16/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-label\":\"org.onap.relationships.inventory.ComposedOf\",\"related-to-property\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":\"Svc6_1\"}]}]},\"equip-vendor\":\"Ericsson\",\"serial-number\":\"6061ZW3\",\"ipaddress-v6-oam\":\"2001:0db8:0:0:0:0:1428:57ab\",\"equip-model\":\"val6\",\"in-maint\":false,\"resource-version\":\"1578668956804\",\"sw-version\":\"val7\",\"pnf-id\":\"eabcfaf7-b7f3-45fb-94e7-e6112fb3e8b8\",\"pnf-name\":\"pnf_newly_discovered\",\"orchestration-status\":\"Active\"}}",
- "{\"cambria.partition\":\"AAI\",\"event-header\":{\"severity\":\"NORMAL\",\"entity-type\":\"pnf\",\"top-entity-type\":\"pnf\",\"entity-link\":\"/aai/v16/network/pnfs/pnf/pnf_newly_discovered\",\"event-type\":\"AAI-EVENT\",\"domain\":\"dev\",\"action\":\"UPDATE\",\"sequence-number\":\"0\",\"id\":\"db09e090-196e-4f84-9645-e449b1cd3640\",\"source-name\":\"dcae-curl\",\"version\":\"v16\",\"timestamp\":\"20200203-15:14:08:807\"},\"entity\":{\"orchestration-status\":\"Active\",\"ipaddress-v4-oam\":\"10.10.10.37\",\"nf-role\":\"gNB\",\"equip-type\":\"val8\",\"relationship-list\":{\"relationship\":[{\"related-to\":\"service-instance\",\"relationship-data\":[{\"relationship-value\":\"Demonstration\",\"relationship-key\":\"customer.global-customer-id\"},{\"relationship-value\":\"vCPE\",\"relationship-key\":\"service-subscription.service-type\"},{\"relationship-value\":\"2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-key\":\"service-instance.service-instance-id\"}],\"related-link\":\"/aai/v16/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-label\":\"org.onap.relationships.inventory.ComposedOf\",\"related-to-property\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":\"Svc6_1\"}]}]},\"equip-vendor\":\"Ericsson\",\"serial-number\":\"6061ZW3\",\"ipaddress-v6-oam\":\"2001:0db8:0:0:0:0:1428:57ab\",\"equip-model\":\"val6\",\"in-maint\":false,\"resource-version\":\"1578668956804\",\"sw-version\":\"val7\",\"pnf-id\":\"eabcfaf7-b7f3-45fb-94e7-e6112fb3e8b8\",\"pnf-name\":\"pnf_already_active\",\"orchestration-status\":\"Active\"}}",
- "{\"cambria.partition\":\"AAI\",\"event-header\":{\"severity\":\"NORMAL\",\"entity-type\":\"pnf\",\"top-entity-type\":\"pnf\",\"entity-link\":\"/aai/v16/network/pnfs/pnf/pnf_newly_discovered\",\"event-type\":\"AAI-EVENT\",\"domain\":\"dev\",\"action\":\"DELETE\",\"sequence-number\":\"0\",\"id\":\"db09e090-196e-4f84-9645-e449b1cd3640\",\"source-name\":\"dcae-curl\",\"version\":\"v16\",\"timestamp\":\"20200203-15:14:08:807\"},\"entity\":{\"ipaddress-v4-oam\":\"10.10.10.37\",\"nf-role\":\"gNB\",\"equip-type\":\"val8\",\"relationship-list\":{\"relationship\":[{\"related-to\":\"service-instance\",\"relationship-data\":[{\"relationship-value\":\"Demonstration\",\"relationship-key\":\"customer.global-customer-id\"},{\"relationship-value\":\"vCPE\",\"relationship-key\":\"service-subscription.service-type\"},{\"relationship-value\":\"2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-key\":\"service-instance.service-instance-id\"}],\"related-link\":\"/aai/v16/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-label\":\"org.onap.relationships.inventory.ComposedOf\",\"related-to-property\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":\"Svc6_1\"}]}]},\"equip-vendor\":\"Ericsson\",\"serial-number\":\"6061ZW3\",\"ipaddress-v6-oam\":\"2001:0db8:0:0:0:0:1428:57ab\",\"equip-model\":\"val6\",\"in-maint\":false,\"resource-version\":\"1578668956804\",\"sw-version\":\"val7\",\"pnf-id\":\"eabcfaf7-b7f3-45fb-94e7-e6112fb3e8b8\",\"pnf-name\":\"pnf_to_be_deleted\",\"orchestration-status\":\"Active\"}}",
+ "{\"cambria.partition\":\"AAI\",\"event-header\":{\"severity\":\"NORMAL\",\"entity-type\":\"pnf\",\"top-entity-type\":\"pnf\",\"entity-link\":\"/aai/v16/network/pnfs/pnf/pnf_newly_discovered\",\"event-type\":\"AAI-EVENT\",\"domain\":\"dev\",\"action\":\"UPDATE\",\"sequence-number\":\"0\",\"id\":\"db09e090-196e-4f84-9645-e449b1cd3640\",\"source-name\":\"dcae-curl\",\"version\":\"v16\",\"timestamp\":\"20200203-15:14:08:807\"},\"entity\":{\"ipaddress-v4-oam\":\"10.10.10.37\",\"nf-role\":\"gNB\",\"equip-type\":\"val8\",\"relationship-list\":{\"relationship\":[{\"related-to\":\"service-instance\",\"relationship-data\":[{\"relationship-value\":\"Demonstration\",\"relationship-key\":\"customer.global-customer-id\"},{\"relationship-value\":\"vCPE\",\"relationship-key\":\"service-subscription.service-type\"},{\"relationship-value\":\"2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-key\":\"service-instance.service-instance-id\"}],\"related-link\":\"/aai/v16/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-label\":\"org.onap.relationships.inventory.ComposedOf\",\"related-to-property\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":\"Svc6_1\"}]}]},\"equip-vendor\":\"Ericsson\",\"serial-number\":\"6061ZW3\",\"ipaddress-v6-oam\":\"2001:0db8:0:0:0:0:1428:57ab\",\"equip-model\":\"val6\",\"in-maint\":false,\"resource-version\":\"1578668956804\",\"sw-version\":\"val7\",\"pnf-id\":\"eabcfaf7-b7f3-45fb-94e7-e6112fb3e8b8\",\"pnf-name\":\"pnf_newly_discovered\",\"model-invariant-id\":\"7129e420-d396-4efb-af02-6b83499b12f8\",\"model-version-id\":\"e80a6ae3-cafd-4d24-850d-e14c084a5ca9\",\"orchestration-status\":\"Active\"}}",
+ "{\"cambria.partition\":\"AAI\",\"event-header\":{\"severity\":\"NORMAL\",\"entity-type\":\"pnf\",\"top-entity-type\":\"pnf\",\"entity-link\":\"/aai/v16/network/pnfs/pnf/pnf_newly_discovered\",\"event-type\":\"AAI-EVENT\",\"domain\":\"dev\",\"action\":\"UPDATE\",\"sequence-number\":\"0\",\"id\":\"db09e090-196e-4f84-9645-e449b1cd3640\",\"source-name\":\"dcae-curl\",\"version\":\"v16\",\"timestamp\":\"20200203-15:14:08:807\"},\"entity\":{\"orchestration-status\":\"Active\",\"ipaddress-v4-oam\":\"10.10.10.37\",\"nf-role\":\"gNB\",\"equip-type\":\"val8\",\"relationship-list\":{\"relationship\":[{\"related-to\":\"service-instance\",\"relationship-data\":[{\"relationship-value\":\"Demonstration\",\"relationship-key\":\"customer.global-customer-id\"},{\"relationship-value\":\"vCPE\",\"relationship-key\":\"service-subscription.service-type\"},{\"relationship-value\":\"2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-key\":\"service-instance.service-instance-id\"}],\"related-link\":\"/aai/v16/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-label\":\"org.onap.relationships.inventory.ComposedOf\",\"related-to-property\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":\"Svc6_1\"}]}]},\"equip-vendor\":\"Ericsson\",\"serial-number\":\"6061ZW3\",\"ipaddress-v6-oam\":\"2001:0db8:0:0:0:0:1428:57ab\",\"equip-model\":\"val6\",\"in-maint\":false,\"resource-version\":\"1578668956804\",\"sw-version\":\"val7\",\"pnf-id\":\"eabcfaf7-b7f3-45fb-94e7-e6112fb3e8b8\",\"pnf-name\":\"pnf_already_active\",\"model-invariant-id\":\"7129e420-d396-4efb-af02-6b83499b12f8\",\"model-version-id\":\"e80a6ae3-cafd-4d24-850d-e14c084a5ca9\",\"orchestration-status\":\"Active\"}}",
+ "{\"cambria.partition\":\"AAI\",\"event-header\":{\"severity\":\"NORMAL\",\"entity-type\":\"pnf\",\"top-entity-type\":\"pnf\",\"entity-link\":\"/aai/v16/network/pnfs/pnf/pnf_newly_discovered\",\"event-type\":\"AAI-EVENT\",\"domain\":\"dev\",\"action\":\"DELETE\",\"sequence-number\":\"0\",\"id\":\"db09e090-196e-4f84-9645-e449b1cd3640\",\"source-name\":\"dcae-curl\",\"version\":\"v16\",\"timestamp\":\"20200203-15:14:08:807\"},\"entity\":{\"ipaddress-v4-oam\":\"10.10.10.37\",\"nf-role\":\"gNB\",\"equip-type\":\"val8\",\"relationship-list\":{\"relationship\":[{\"related-to\":\"service-instance\",\"relationship-data\":[{\"relationship-value\":\"Demonstration\",\"relationship-key\":\"customer.global-customer-id\"},{\"relationship-value\":\"vCPE\",\"relationship-key\":\"service-subscription.service-type\"},{\"relationship-value\":\"2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-key\":\"service-instance.service-instance-id\"}],\"related-link\":\"/aai/v16/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/2c03b2a8-e31a-4749-9e99-3089ab441400\",\"relationship-label\":\"org.onap.relationships.inventory.ComposedOf\",\"related-to-property\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":\"Svc6_1\"}]}]},\"equip-vendor\":\"Ericsson\",\"serial-number\":\"6061ZW3\",\"ipaddress-v6-oam\":\"2001:0db8:0:0:0:0:1428:57ab\",\"equip-model\":\"val6\",\"in-maint\":false,\"resource-version\":\"1578668956804\",\"sw-version\":\"val7\",\"pnf-id\":\"eabcfaf7-b7f3-45fb-94e7-e6112fb3e8b8\",\"pnf-name\":\"pnf_to_be_deleted\",\"model-invariant-id\":\"7129e420-d396-4efb-af02-6b83499b12f8\",\"model-version-id\":\"e80a6ae3-cafd-4d24-850d-e14c084a5ca9\",\"orchestration-status\":\"Active\"}}",
"{\"cambria.partition\":\"AAI\",\"event-header\":{\"severity\":\"NORMAL\",\"entity-type\":\"model-ver\",\"top-entity-type\":\"model\",\"entity-link\":\"/aai/v19/service-design-and-creation/models/model/60cd7bbf-0a6b-43ce-a5af-07cbf168ecdc/model-vers/model-ver/5485c7ac-825f-414d-aba4-e24147107d0b\",\"event-type\":\"AAI-EVENT\",\"domain\":\"dev\",\"action\":\"UPDATE\",\"sequence-number\":\"0\",\"id\":\"e16cb0f9-3617-4a14-9c81-f7ee4cdf9df7\",\"source-name\":\"UNKNOWN\",\"version\":\"v19\",\"timestamp\":\"20200701-12:06:12:135\"},\"entity\":{\"model-type\":\"service\",\"model-vers\":{\"model-ver\":[{\"model-version-id\":\"5485c7ac-825f-414d-aba4-e24147107d0b\",\"resource-version\":\"1593605171956\",\"model-description\":\"catalog service description\",\"model-name\":\"Demo_pNF_WCcM9Z2VNE3eGfLIKulP\",\"model-elements\":{\"model-element\":[{\"relationship-list\":{\"relationship\":[{\"related-to\":\"model-ver\",\"relationship-data\":[{\"relationship-value\":\"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"relationship-key\":\"model.model-invariant-id\"},{\"relationship-value\":\"46b92144-923a-4d20-b85a-3cbd847668a9\",\"relationship-key\":\"model-ver.model-version-id\"}],\"related-link\":\"/aai/v19/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9\",\"relationship-label\":\"org.onap.relationships.inventory.IsA\",\"related-to-property\":[{\"property-key\":\"model-ver.model-name\",\"property-value\":\"service-instance\"}]}]},\"resource-version\":\"1593605012006\",\"model-elements\":{\"model-element\":[{\"relationship-list\":{\"relationship\":[{\"related-to\":\"model-ver\",\"relationship-data\":[{\"relationship-value\":\"c8fb1064-f38a-4a13-90a6-ec60289879ac\",\"relationship-key\":\"model.model-invariant-id\"},{\"relationship-value\":\"94c051c3-4484-425e-a107-6914816321a6\",\"relationship-key\":\"model-ver.model-version-id\"}],\"related-link\":\"/aai/v19/service-design-and-creation/models/model/c8fb1064-f38a-4a13-90a6-ec60289879ac/model-vers/model-ver/94c051c3-4484-425e-a107-6914816321a6\",\"relationship-label\":\"org.onap.relationships.inventory.IsA\",\"related-to-property\":[{\"property-key\":\"model-ver.model-name\",\"property-value\":\"pNF 77be3d89-b735\"}]}]},\"resource-version\":\"1593605012006\",\"new-data-del-flag\":\"T\",\"cardinality\":\"unbounded\",\"model-element-uuid\":\"44712769-981d-4970-9ea5-4c99b86f838e\"}]},\"new-data-del-flag\":\"T\",\"cardinality\":\"unbounded\",\"model-element-uuid\":\"4a601305-9e09-4152-98ad-b8c466d57813\"}]},\"model-version\":\"1.0\",\"distribution-status\":\"DISTRIBUTION_COMPLETE_OK\"}]},\"model-invariant-id\":\"60cd7bbf-0a6b-43ce-a5af-07cbf168ecdc\"}}",
"{\"cambria.partition\":\"AAI\",\"event-header\":{\"severity\":\"NORMAL\",\"entity-type\":\"customer\",\"top-entity-type\":\"customer\",\"entity-link\":\"/aai/v19/business/customers/customer/ETE_Customer_5638d7b4-a02d-4cc4-801e-77ee837d2855\",\"event-type\":\"AAI-EVENT\",\"domain\":\"dev\",\"action\":\"CREATE\",\"sequence-number\":\"0\",\"id\":\"ef390383-3d08-4268-a013-d11c14efd716\",\"source-name\":\"robot-ete\",\"version\":\"v19\",\"timestamp\":\"20200701-12:06:50:388\"},\"entity\":{\"global-customer-id\":\"ETE_Customer_5638d7b4-a02d-4cc4-801e-77ee837d2855\",\"subscriber-type\":\"INFRA\",\"resource-version\":\"1593605210258\",\"subscriber-name\":\"ETE_Customer_5638d7b4-a02d-4cc4-801e-77ee837d2855\",\"service-subscriptions\":{\"service-subscription\":[{\"relationship-list\":{\"relationship\":[{\"related-to\":\"tenant\",\"relationship-data\":[{\"relationship-value\":\"CloudOwner\",\"relationship-key\":\"cloud-region.cloud-owner\"},{\"relationship-value\":\"RegionForPNF\",\"relationship-key\":\"cloud-region.cloud-region-id\"},{\"relationship-value\":\"dummy_tenant_id_for_pnf\",\"relationship-key\":\"tenant.tenant-id\"}],\"related-link\":\"/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionForPNF/tenants/tenant/dummy_tenant_id_for_pnf\",\"relationship-label\":\"org.onap.relationships.inventory.Uses\",\"related-to-property\":[{\"property-key\":\"tenant.tenant-name\",\"property-value\":\"dummy_tenant_for_pnf\"}]}]},\"resource-version\":\"1593605210258\",\"service-type\":\"pNF\"}]}}}"
]
diff --git a/components/pm-subscription-handler/tests/test_network_function_filter.py b/components/pm-subscription-handler/tests/test_network_function_filter.py
new file mode 100644
index 00000000..95c9b7bc
--- /dev/null
+++ b/components/pm-subscription-handler/tests/test_network_function_filter.py
@@ -0,0 +1,86 @@
+# ============LICENSE_START===================================================
+# Copyright (C) 2020 Nordix Foundation.
+# ============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=====================================================
+
+import json
+import os
+from unittest import TestCase
+from parameterized import parameterized
+from mod.network_function import NetworkFunctionFilter
+
+
+def custom_name_func(testcase_func, param_num, param):
+ return "%s_%s" % (
+ testcase_func.__name__,
+ parameterized.to_safe_name((str(param.args[0]))),
+ )
+
+
+def load_test_cases():
+ test_parameters = []
+ with open(os.path.join(os.path.dirname(__file__), 'data/filter_test_data.json'), 'r') as test_data:
+ loaded_test_data = json.load(test_data)
+ for test in loaded_test_data:
+ params = [value for key, value in test.items()]
+ test_parameters.append(params)
+ return test_parameters
+
+
+class NetworkFunctionFilterTest(TestCase):
+
+ @parameterized.expand(load_test_cases, name_func=custom_name_func)
+ def test(self, test_name, nf_filter, nf_name, model_invariant_uuid, model_version_id, orchestration_status,
+ expected_result):
+ nf_filter = NetworkFunctionFilter(**nf_filter)
+ self.assertEqual(nf_filter.is_nf_in_filter(nf_name,
+ model_invariant_uuid,
+ model_version_id,
+ orchestration_status), expected_result)
+
+ def test_filter_true_on_multiple_modelInvariantUUIDs(self):
+ nf_filter = NetworkFunctionFilter(**{
+ "nfNames": [
+ ],
+ "modelInvariantUUIDs": [
+ '5845y423-g654-6fju-po78-8n53154532k6',
+ '7129e420-d396-4efb-af02-6b83499b12f8'
+ ],
+ "modelVersionIDs": [
+ ]
+ })
+ self.assertTrue(nf_filter.is_nf_in_filter('pnf1',
+ '7129e420-d396-4efb-af02-6b83499b12f8',
+ 'e80a6ae3-cafd-4d24-850d-e14c084a5ca9',
+ 'Active'))
+
+ def test_filter_false_on_modelInvariantUUIDs_being_false_and_pnfname_being_true(self):
+ nf_filter = NetworkFunctionFilter(**{
+ "nfNames": [
+ "^pnf.*",
+ "^vnf.*"
+ ],
+ "modelInvariantUUIDs": [
+ '5845y423-g654-6fju-po78-8n53154532k6',
+ '7129e420-d396-4efb-af02-6b83499b12f8'
+ ],
+ "modelVersionIDs": [
+ ]
+ })
+ self.assertFalse(nf_filter.is_nf_in_filter('pnf1',
+ 'WrongModelInvariantUUID',
+ 'e80a6ae3-cafd-4d24-850d-e14c084a5ca9',
+ 'Active')) \ No newline at end of file
diff --git a/components/pm-subscription-handler/tests/test_subscription.py b/components/pm-subscription-handler/tests/test_subscription.py
index 27a189c2..c7845e74 100755
--- a/components/pm-subscription-handler/tests/test_subscription.py
+++ b/components/pm-subscription-handler/tests/test_subscription.py
@@ -66,14 +66,6 @@ class SubscriptionTest(TestCase):
db.session.remove()
self.app_context.pop()
- def test_xnf_filter_true(self):
- self.assertTrue(self.app_conf.nf_filter.is_nf_in_filter('pnf1',
- 'Active'))
-
- def test_xnf_filter_false(self):
- self.assertFalse(self.app_conf.nf_filter.is_nf_in_filter('PNF-33',
- 'Active'))
-
def test_sub_measurement_group(self):
self.assertEqual(len(self.app_conf.subscription.measurementGroups), 2)
diff --git a/components/pm-subscription-handler/tox.ini b/components/pm-subscription-handler/tox.ini
index 3843a37d..4ee06e08 100644
--- a/components/pm-subscription-handler/tox.ini
+++ b/components/pm-subscription-handler/tox.ini
@@ -27,6 +27,7 @@ deps=
coverage
pytest-cov
responses==0.10.7
+ parameterized==0.7.4
setenv =
PYTHONPATH={toxinidir}/pmsh_service:{toxinidir}/pmsh_service/mod:{toxinidir}/tests
commands=