2 * ============LICENSE_START===================================================
3 * Copyright (c) 2018 Amdocs
4 * ============================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=====================================================
22 indices 'default-rules'
26 // NDCB-AAI comparison: Context level
28 name 'NDCB-AAI-attribute-comparison'
29 attributes 'context-list.ndcb', 'context-list.aai'
32 // NDCB-AAI comparison: Service entity
34 name 'NDCB-AAI-attribute-comparison'
35 attributes 'context-list.ndcb.service', 'context-list.aai.service'
38 // NDCB-AAI comparison: VF list
40 name 'NDCB-AAI-attribute-comparison'
41 attributes 'context-list.ndcb.vfList[*]', 'context-list.aai.vfList[*]'
44 // NDCB-AAI comparison: VF-Module list
46 name 'NDCB-AAI-attribute-comparison'
47 attributes 'context-list.ndcb.vfList[*].vfModuleList[*]', 'context-list.aai.vfList[*].vfModuleList[*]'
50 // NDCB-AAI comparison: VNFC list
52 name 'NDCB-AAI-attribute-comparison'
53 attributes 'context-list.ndcb.vfList[*].vnfcList[*]', 'context-list.aai.vfList[*].vnfcList[*]'
56 // NDCB-AAI comparison: VM list
58 name 'NDCB-AAI-attribute-comparison'
59 attributes 'context-list.ndcb.vfList[*].vfModuleList[*].vmList[*]', 'context-list.aai.vfList[*].vfModuleList[*].vmList[*]'
62 // NDCB-AAI comparison: Network list
64 name 'NDCB-AAI-attribute-comparison'
65 attributes 'context-list.ndcb.vfList[*].vfModuleList[*].networkList[*]', 'context-list.aai.vfList[*].vfModuleList[*].networkList[*]'
68 // SDNC-AAI comparison: Context level
70 name 'SDNC-AAI-attribute-comparison'
71 attributes 'context-list.sdnc', 'context-list.aai'
74 // SDNC-AAI comparison: Service entity
76 name 'SDNC-AAI-attribute-comparison'
77 attributes 'context-list.sdnc.service', 'context-list.aai.service'
80 // SDNC-AAI comparison: VF list
82 name 'SDNC-AAI-attribute-comparison'
83 attributes 'context-list.sdnc.vfList[*]', 'context-list.aai.vfList[*]'
86 // SDNC-AAI comparison: VF-Module list
88 name 'SDNC-AAI-attribute-comparison'
89 attributes 'context-list.sdnc.vfList[*].vfModuleList[*]', 'context-list.aai.vfList[*].vfModuleList[*]'
92 // SDNC-AAI comparison: VNFC list
94 name 'SDNC-AAI-attribute-comparison'
95 attributes 'context-list.sdnc.vfList[*].vnfcList[*]', 'context-list.aai.vfList[*].vnfcList[*]'
98 // SDNC-AAI comparison: VM list
100 name 'SDNC-AAI-attribute-comparison'
101 attributes 'context-list.sdnc.vfList[*].vfModuleList[*].vmList[*]', 'context-list.aai.vfList[*].vfModuleList[*].vmList[*]'
104 // SDNC-AAI comparison: Network list
106 name 'SDNC-AAI-attribute-comparison'
107 attributes 'context-list.sdnc.vfList[*].vfModuleList[*].networkList[*]', 'context-list.aai.vfList[*].vfModuleList[*].networkList[*]'
110 // SDNC-NDCB comparison: Context level
112 name 'SDNC-NDCB-attribute-comparison'
113 attributes 'context-list.sdnc', 'context-list.ndcb'
116 // SDNC-NDCB comparison: Service entity
118 name 'SDNC-NDCB-attribute-comparison'
119 attributes 'context-list.sdnc.service', 'context-list.ndcb.service'
122 // SDNC-NDCB comparison: VF list
124 name 'SDNC-NDCB-attribute-comparison'
125 attributes 'context-list.sdnc.vfList[*]', 'context-list.ndcb.vfList[*]'
128 // SDNC-NDCB comparison: VF-Module list
130 name 'SDNC-NDCB-attribute-comparison'
131 attributes 'context-list.sdnc.vfList[*].vfModuleList[*]', 'context-list.ndcb.vfList[*].vfModuleList[*]'
134 // SDNC-NDCB comparison: VNFC list
136 name 'SDNC-NDCB-attribute-comparison'
137 attributes 'context-list.sdnc.vfList[*].vnfcList[*]', 'context-list.ndcb.vfList[*].vnfcList[*]'
140 // SDNC-NDCB comparison: VM list
142 name 'SDNC-NDCB-attribute-comparison'
143 attributes 'context-list.sdnc.vfList[*].vfModuleList[*].vmList[*]', 'context-list.ndcb.vfList[*].vfModuleList[*].vmList[*]'
146 // SDNC-NDCB comparison: Network list
148 name 'SDNC-NDCB-attribute-comparison'
149 attributes 'context-list.sdnc.vfList[*].vfModuleList[*].networkList[*]', 'context-list.ndcb.vfList[*].vfModuleList[*].networkList[*]'
154 name 'SDC-AAI-vnfc-type'
155 attributes 'context-list.sdc.vfList[*].vnfcList[*]', 'context-list.aai.vfList[*].vnfcList[*]'
158 // SDC-AAI VNFC node count
160 name 'SDC-AAI-vnfc-node-count'
161 attributes 'context-list.sdc.vfList[*].vnfcList[*]', 'context-list.aai.vfList[*].vnfcList[*]'
164 // SDC-AAI VF-Module instance
166 name 'SDC-AAI-vf-module-instance-check'
167 attributes 'context-list.ndcb.vfList[*].vfModuleList[*]', 'context-list.aai.vfList[*].vfModuleList[*]'
173 name 'SDC-AAI-vnfc-type'
174 category 'VNFC Consistency'
175 description 'Validate that each VNFC instance in AAI conforms to a VNFC type defined in SDC model'
176 errorText 'AAI VNFC instance includes non-specified type in design SDC model'
178 attributes 'sdcList', 'aaiList'
180 def getVnfcTypes = { parsedData ->
181 parsedData.collect{ it.findResult{ k, v -> if(k.equals("type")) {return "$v"}}}
184 def slurper = new groovy.json.JsonSlurper()
185 def sdcTypes = getVnfcTypes(slurper.parseText(sdcList.toString()))
186 def aaiTypes = getVnfcTypes(slurper.parseText(aaiList.toString()))
188 // each type in AAI must exist in SDC
189 return sdcTypes.containsAll(aaiTypes)
194 name 'SDC-AAI-vnfc-node-count'
195 category 'VNFC Consistency'
196 description 'Validate that for each VNFC node defined in SDC model, there is at least one VNFC instance in AAI'
197 errorText 'Design has specified types but not all of them exist in AAI'
199 attributes 'sdcList', 'aaiList'
201 def getVnfcNodes = { parsedData ->
202 parsedData.collect { new Tuple2(
203 it.findResult{ k, v -> if(k.equals("name")) {return "$v"}},
204 it.findResult{ k, v -> if(k.equals("type")) {return "$v"}})
208 def slurper = new groovy.json.JsonSlurper()
209 def sdcNodes = getVnfcNodes(slurper.parseText(sdcList.toString()))
210 def aaiNodes = getVnfcNodes(slurper.parseText(aaiList.toString()))
212 // each node in AAI must exist in SDC
213 return aaiNodes.containsAll(sdcNodes)
218 name 'SDC-AAI-vf-module-instance-check'
219 category 'VF Consistency'
220 description 'Validate that each VF module instance in AAI conforms to a VF module defined in SDC service model'
221 errorText 'One or more AAI VF module instance(s) not defined in SDC model'
223 attributes 'sdcList', 'aaiList'
225 def getVfModules = { parsedData ->
226 parsedData.collect{ it.findResult{ k, v -> if(k.equals("name")) {return "$v"}}}
229 def slurper = new groovy.json.JsonSlurper()
230 def sdcVfModules = getVfModules(slurper.parseText(sdcList.toString()))
231 def aaiVfModules = getVfModules(slurper.parseText(aaiList.toString()))
233 // all VF modules in AAI must exist in SDC
234 return aaiVfModules.containsAll(sdcVfModules)
239 name 'NDCB-AAI-attribute-comparison'
240 category 'Attribute Mismatch'
241 description 'Verify that all attributes in Network-Discovery are the same as in AAI'
242 errorText 'Error found with attribute "{0}"; Network-Discovery value does not match AAI value "{1}"'
244 attributes 'ndcbItems', 'aaiItems'
246 Closure<java.util.Map> getAttributes = { parsedData ->
247 java.util.Map attributeMap = new java.util.HashMap()
249 def isAttributeDataQualityOk = { attribute ->
250 attribute.findResult{ k, v -> if(k.equals("dataQuality") ) {return v.get("status")}}.equals("ok")
253 def addToMap = { attrKey, attrValue ->
254 java.util.Set values = attributeMap.get("$attrKey")
256 values = new java.util.HashSet()
257 attributeMap.put("$attrKey", values)
259 values.add("$attrValue")
262 def addAttributeToMap = { attribute ->
263 if(isAttributeDataQualityOk(attribute)) {
265 attribute.each { k, v ->
266 if(k.equals("name")) {key = "$v"}
267 if(k.equals("value")) {value = "$v"}
269 addToMap("$key", "$value")
273 def processKeyValue = { key, value ->
274 if(value instanceof java.util.ArrayList) {
275 if(key.equals("attributeList")) {
277 addAttributeToMap(it)
280 } else if(!(value instanceof groovy.json.internal.LazyMap)) {
281 // only add key-value attributes, skip the rest
282 addToMap("$key", "$value")
286 if(parsedData instanceof java.util.ArrayList) {
288 it.each { key, value -> processKeyValue(key, value) }
291 parsedData.each { key, value -> processKeyValue(key, value) }
296 def slurper = new groovy.json.JsonSlurper()
297 java.util.Map ndcb = getAttributes(slurper.parseText(ndcbItems.toString()))
298 java.util.Map aai = getAttributes(slurper.parseText(aaiItems.toString()))
300 boolean result = true
301 List<String> details = new ArrayList<>();
302 ndcb.any{ ndcbKey, ndcbValueList ->
303 def aaiValueList = aai.get("$ndcbKey")
304 aaiValueList.each{ aaiValue ->
305 if(!ndcbValueList.any{ it == "$aaiValue" }) {
307 details.add("$ndcbKey")
308 details.add("$aaiValue")
311 if(result == false) {
312 // break out of 'any' loop
316 return new Tuple2(result, details)
321 name 'SDNC-AAI-attribute-comparison'
322 category 'Attribute Mismatch'
323 description 'Verify that all attributes in SDN-C are the same as in AAI'
324 errorText 'Error found with attribute "{0}"; SDN-C value does not match AAI value "{1}"'
326 attributes 'sdncItems', 'aaiItems'
328 Closure<java.util.Map> getAttributes = { parsedData ->
329 java.util.Map attributeMap = new java.util.HashMap()
331 def isAttributeDataQualityOk = { attribute ->
332 attribute.findResult{ k, v -> if(k.equals("dataQuality") ) {return v.get("status")}}.equals("ok")
335 def addToMap = { attrKey, attrValue ->
336 java.util.Set values = attributeMap.get("$attrKey")
338 values = new java.util.HashSet()
339 attributeMap.put("$attrKey", values)
341 values.add("$attrValue")
344 def addAttributeToMap = { attribute ->
345 if(isAttributeDataQualityOk(attribute)) {
347 attribute.each { k, v ->
348 if(k.equals("name")) {key = "$v"}
349 if(k.equals("value")) {value = "$v"}
351 addToMap("$key", "$value")
355 def processKeyValue = { key, value ->
356 if(value instanceof java.util.ArrayList) {
357 if(key.equals("attributeList")) {
359 addAttributeToMap(it)
362 } else if(!(value instanceof groovy.json.internal.LazyMap)) {
363 // only add key-value attributes, skip the rest
364 addToMap("$key", "$value")
368 if(parsedData instanceof java.util.ArrayList) {
370 it.each { key, value -> processKeyValue(key, value) }
373 parsedData.each { key, value -> processKeyValue(key, value) }
378 def slurper = new groovy.json.JsonSlurper()
379 java.util.Map sdnc = getAttributes(slurper.parseText(sdncItems.toString()))
380 java.util.Map aai = getAttributes(slurper.parseText(aaiItems.toString()))
382 boolean result = true
383 List<String> details = new ArrayList<>();
384 sdnc.any{ sdncKey, sdncValueList ->
385 def aaiValueList = aai.get("$sdncKey")
386 aaiValueList.each{ aaiValue ->
387 if(!sdncValueList.any{ it == "$aaiValue" }) {
389 details.add("$sdncKey")
390 details.add("$aaiValue")
393 if(result == false) {
394 // break out of 'any' loop
398 return new Tuple2(result, details)
404 name 'SDNC-NDCB-attribute-comparison'
405 category 'Attribute Mismatch'
406 description 'Verify that all attributes in SDN-C are the same as in Network Discovery'
407 errorText 'Error found with attribute "{0}"; SDN-C value does not match Network-Discovery value "{1}"'
409 attributes 'sdncItems', 'ndcbItems'
411 Closure<java.util.Map> getAttributes = { parsedData ->
412 java.util.Map attributeMap = new java.util.HashMap()
414 def isAttributeDataQualityOk = { attribute ->
415 attribute.findResult{ k, v -> if(k.equals("dataQuality") ) {return v.get("status")}}.equals("ok")
418 def addToMap = { attrKey, attrValue ->
419 java.util.Set values = attributeMap.get("$attrKey")
421 values = new java.util.HashSet()
422 attributeMap.put("$attrKey", values)
424 values.add("$attrValue")
427 def addAttributeToMap = { attribute ->
428 if(isAttributeDataQualityOk(attribute)) {
430 attribute.each { k, v ->
431 if(k.equals("name")) {key = "$v"}
432 if(k.equals("value")) {value = "$v"}
434 addToMap("$key", "$value")
438 def processKeyValue = { key, value ->
439 if(value instanceof java.util.ArrayList) {
440 if(key.equals("attributeList")) {
442 addAttributeToMap(it)
445 } else if(!(value instanceof groovy.json.internal.LazyMap)) {
446 // only add key-value attributes, skip the rest
447 addToMap("$key", "$value")
451 if(parsedData instanceof java.util.ArrayList) {
453 it.each { key, value -> processKeyValue(key, value) }
456 parsedData.each { key, value -> processKeyValue(key, value) }
461 def slurper = new groovy.json.JsonSlurper()
462 java.util.Map sdnc = getAttributes(slurper.parseText(sdncItems.toString()))
463 java.util.Map ndcb = getAttributes(slurper.parseText(ndcbItems.toString()))
465 boolean result = true
466 List<String> details = new ArrayList<>();
467 sdnc.any{ sdncKey, sdncValueList ->
468 def ndcbValueList = ndcb.get("$sdncKey")
469 ndcbValueList.each{ ndcbValue ->
470 if(!sdncValueList.any{ it == "$ndcbValue" }) {
472 details.add("$sdncKey")
473 details.add("$ndcbValue")
476 if(result == false) {
477 // break out of 'any' loop
481 return new Tuple2(result, details)