summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTait,Trevor(rt0435) <rtait@amdocs.com>2019-01-31 10:58:16 -0500
committerTait,Trevor(rt0435) <rtait@amdocs.com>2019-02-04 14:21:26 -0500
commit769cb4c222fb6123bda3ae12abadd73cba7bdbb5 (patch)
treede57d516fea37140e7fbb23bd4130767b2bbf716
parent7aa6d16dff7103b7b83fbd3261c2caa374b7810e (diff)
SDNC Context Builder : L2 Fabric Retrieval - pnf
Handle the case where there ONE PNF under source-port OR dest-port but not both. Issue-ID: LOG-778 Change-Id: Ia37bc98e51e9bc8548ac897af369c0e576f57308 Signed-off-by: Tait,Trevor(rt0435) <rtait@amdocs.com>
-rw-r--r--config/application.properties6
-rw-r--r--config/portMirrorConfigurations.spec60
-rw-r--r--config/providedConfigurations.spec48
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/sdnc/util/RestUtil.java9
-rw-r--r--src/test/resources/junit/portMirrorConfigurationsResponse.json40
5 files changed, 80 insertions, 83 deletions
diff --git a/config/application.properties b/config/application.properties
index 87eca62..de3a896 100644
--- a/config/application.properties
+++ b/config/application.properties
@@ -50,9 +50,9 @@ aai.readTimeout=5000
aai.http.userId=admin
aai.http.password=OBF:1u2a1toa1w8v1tok1u30
-aai.searchNodeQuery=/aai/v11/search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:
-aai.customerQuery=/aai/v11/business/customers/customer/
-aai.serviceInstancePath=/aai/v11/business/customers/customer/{0}/service-subscriptions/service-subscription/{1}/service-instances/service-instance/{2}
+aai.searchNodeQuery=/aai/v13/search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:
+aai.customerQuery=/aai/v13/business/customers/customer/
+aai.serviceInstancePath=/aai/v13/business/customers/customer/{0}/service-subscriptions/service-subscription/{1}/service-instances/service-instance/{2}
diff --git a/config/portMirrorConfigurations.spec b/config/portMirrorConfigurations.spec
index c570c59..964b385 100644
--- a/config/portMirrorConfigurations.spec
+++ b/config/portMirrorConfigurations.spec
@@ -1,32 +1,28 @@
-[
- // Use https://jolt-demo.appspot.com/#inception to develop/test
- // any changes to this file
-
- {
- // This section extracts pnf-information from the GENERIC-RESOURCES-API
- // response from sdnc
- "operation": "shift",
- "spec": {
- "port-mirror-configuration-request-input": {
- "source-port": {
- "*": {
- "pnf-information": {
- "pnf-name": "pnfList[0].name",
- "#nfType": "pnfList[0].attributeList[0].name",
- "pnf-type": "pnfList[0].attributeList[0].value"
- }
- }
- },
- "dest-port": {
- "*": {
- "pnf-information": {
- "pnf-name": "pnfList[1].name",
- "#nfType": "pnfList[1].attributeList[0].name",
- "pnf-type": "pnfList[1].attributeList[0].value"
- }
- }
- }
- }
- }
- }
- ]
+[
+ // Use https://jolt-demo.appspot.com/#inception to develop/test
+ // any changes to this file
+
+ {
+ // This section extracts pnf-information from the GENERIC-RESOURCES-API
+ // response from sdnc
+ "operation": "shift",
+ "spec": {
+ "port-mirror-configuration-request-input": {
+ "source-port": {
+ "pnf-information": {
+ "pnf-name": "pnfList[0].name",
+ "#nfType": "pnfList[0].attributeList[0].name",
+ "pnf-type": "pnfList[0].attributeList[0].value"
+ }
+ },
+ "dest-port": {
+ "pnf-information": {
+ "pnf-name": "pnfList[1].name",
+ "#nfType": "pnfList[1].attributeList[0].name",
+ "pnf-type": "pnfList[1].attributeList[0].value"
+ }
+ }
+ }
+ }
+ }
+ ]
diff --git a/config/providedConfigurations.spec b/config/providedConfigurations.spec
index 6af573f..7238439 100644
--- a/config/providedConfigurations.spec
+++ b/config/providedConfigurations.spec
@@ -1,25 +1,25 @@
-[
- // Use https://jolt-demo.appspot.com/#inception to develop/test
- // any changes to this file
-
- {
- // This section extracts configuration-id from the GENERIC-RESOURCES-API
- // response from sdnc
- "operation": "shift",
- "spec": {
- "service": {
- "*": {
- "service-data": {
- "provided-configurations": {
- "provided-configuration": {
- "*": {
- "configuration-id": "configuration-id[&1]"
- }
- }
- }
- }
- }
- }
- }
- }
+[
+ // Use https://jolt-demo.appspot.com/#inception to develop/test
+ // any changes to this file
+
+ {
+ // This section extracts configuration-id from the GENERIC-RESOURCES-API
+ // response from sdnc
+ "operation": "shift",
+ "spec": {
+ "service": {
+ "*": {
+ "service-data": {
+ "provided-configurations": {
+ "provided-configuration": {
+ "*": {
+ "configuration-id": "configuration-id[&1]"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
] \ No newline at end of file
diff --git a/src/main/java/org/onap/pomba/contextbuilder/sdnc/util/RestUtil.java b/src/main/java/org/onap/pomba/contextbuilder/sdnc/util/RestUtil.java
index ab48ac5..5065da3 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/sdnc/util/RestUtil.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/sdnc/util/RestUtil.java
@@ -225,6 +225,7 @@ public class RestUtil {
}
public static List<PNF> getPnfFromSdncResonse(Client sdncClient, String sdncBaseUrl, String authorization, String sdncPortMirrorResourcePath, String sdncResponse) throws AuditException {
+ List<PNF> pnfList = new ArrayList<>();
List<Object> providedConfigurationsSpec = JsonUtils.filepathToList(PROVIDED_CONFIGURATIONS_SPEC_PATH);
Object providedConfigurationsInput = JsonUtils.jsonToObject(sdncResponse);
Chainr providedConfigurations = Chainr.fromSpec(providedConfigurationsSpec);
@@ -240,9 +241,13 @@ public class RestUtil {
Object portMirrorInput = JsonUtils.jsonToObject(portMirrorResponse);
Chainr portMirror = Chainr.fromSpec(portMirrorSpec);
Object portMirrorObject = portMirror.transform(portMirrorInput);
- return gson.fromJson(JsonUtils.toPrettyJsonString(portMirrorObject), ModelContext.class).getPnfs();
+ for (PNF pnf :gson.fromJson(JsonUtils.toPrettyJsonString(portMirrorObject), ModelContext.class).getPnfs()) {
+ if (null != pnf) {
+ pnfList.add(pnf);
+ }
+ };
}
- return new ArrayList<>();
+ return pnfList;
}
/**
diff --git a/src/test/resources/junit/portMirrorConfigurationsResponse.json b/src/test/resources/junit/portMirrorConfigurationsResponse.json
index 1c9b430..50b5b07 100644
--- a/src/test/resources/junit/portMirrorConfigurationsResponse.json
+++ b/src/test/resources/junit/portMirrorConfigurationsResponse.json
@@ -1,23 +1,19 @@
-{
- "port-mirror-configuration-request-input": {
- "source-port": [
- {
- "vnf-information": {
- "vnf-id": "09a8c1d8-0981-4e3d-a4c0-6007d6f57e1b"
- },
- "pnf-information": {
- "pnf-name": "onapTest1",
- "pnf-type": "onapSrc"
- }
- }
- ],
- "dest-port": [
- {
- "pnf-information": {
- "pnf-name": "onapTest2",
- "pnf-type": "onapDest"
- }
- }
- ]
- }
+{
+ "port-mirror-configuration-request-input": {
+ "source-port": {
+ "vnf-information": {
+ "vnf-id": "09a8c1d8-0981-4e3d-a4c0-6007d6f57e1b"
+ },
+ "pnf-information": {
+ "pnf-name": "onapTest1",
+ "pnf-type": "onapSrc"
+ }
+ },
+ "dest-port": {
+ "pnf-information": {
+ "pnf-name": "onapTest2",
+ "pnf-type": "onapDest"
+ }
+ }
+ }
} \ No newline at end of file