aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames MacNider <James.MacNider@amdocs.com>2019-02-25 14:15:59 +0000
committerGerrit Code Review <gerrit@onap.org>2019-02-25 14:15:59 +0000
commit07a623e3e4d810791ae7129c529c42556e920bc6 (patch)
tree5909a74cbd07a885c79ed541b1e63b8a1ca0b185
parent03d0e528dadc44118e61773f3dc9d3ab58844573 (diff)
parent67032122ab52f59338278de8af7d3938e9ba7d9e (diff)
Merge "LOG-958: PNF comparison rule"
-rw-r--r--kubernetes/pomba/charts/pomba-validation-service/resources/bundleconfig/etc/rules/poa-event/default-rules.groovy58
1 files changed, 56 insertions, 2 deletions
diff --git a/kubernetes/pomba/charts/pomba-validation-service/resources/bundleconfig/etc/rules/poa-event/default-rules.groovy b/kubernetes/pomba/charts/pomba-validation-service/resources/bundleconfig/etc/rules/poa-event/default-rules.groovy
index 1902a1050f..95206cf984 100644
--- a/kubernetes/pomba/charts/pomba-validation-service/resources/bundleconfig/etc/rules/poa-event/default-rules.groovy
+++ b/kubernetes/pomba/charts/pomba-validation-service/resources/bundleconfig/etc/rules/poa-event/default-rules.groovy
@@ -132,8 +132,13 @@ entity {
attributes 'context-list.sdnc.vnfList[*].vfModuleList[*].vmList[*]', 'context-list.aai.vnfList[*].vfModuleList[*].vmList[*]'
}
-
-
+ // AAI-SDNC PNF name validation
+ useRule {
+ name 'AAI-SDNC-pnf-name-check'
+ attributes 'context-list.aai.pnfList[*].name', 'context-list.sdnc.pnfList[*].name'
+ }
+
+
// SDNC-NDCB comparison: Context level
useRule {
name 'Attribute-comparison'
@@ -432,3 +437,52 @@ rule {
return new Tuple2(success, details)
'''
}
+
+rule {
+ name 'AAI-SDNC-pnf-name-check'
+ category 'PNF Consistency'
+ description 'Validate that each PNF name in AAI matches a PNF name in the SDNC model'
+ errorText 'AAI PNF names do not match SDNC - {0}'
+ severity 'ERROR'
+ attributes 'aaiNames', 'sdncNames'
+ validate '''
+ def addName = { values, key ->
+ values.add("$key")
+ }
+
+ List<String> errorReasons = new ArrayList();
+
+ if (aaiNames.size() != sdncNames.size()) {
+ errorReasons.add("Number of PNFs don't match; aai has ${aaiNames.size()}, sdnc has ${sdncNames.size()}")
+ return new Tuple2(false, errorReasons)
+ }
+
+ // collect all the "name" values from AAI and SDNC into two Sets.
+ Set aaiNameSet = new java.util.HashSet()
+ aaiNames.each {
+ aValue -> addName(aaiNameSet, aValue)
+ }
+
+ Set sdncNameSet = new java.util.HashSet()
+ sdncNames.each {
+ aValue -> addName(sdncNameSet, aValue)
+ }
+
+ // Validate that the names match by comparing the size of the two Sets.
+ if (aaiNameSet.size() != sdncNameSet.size()) {
+ errorReasons.add("Number of distinct PNF names don't match; aai: ${aaiNameSet}, sdnc: ${sdncNameSet}")
+ return new Tuple2(false, errorReasons)
+ }
+
+ Set combinedSet = new HashSet();
+ combinedSet.addAll(aaiNameSet);
+ combinedSet.addAll(sdncNameSet);
+ if (combinedSet.size() != aaiNameSet.size()) {
+ errorReasons.add("PNF names don't match; aai names: ${aaiNameSet}, sdnc names: ${sdncNameSet}")
+ return new Tuple2(false, errorReasons)
+ }
+
+ return true
+
+ '''
+}