From e8dbb2edab5055d5e2445c659dc4cb9dac41bb04 Mon Sep 17 00:00:00 2001 From: "Tait,Trevor(rt0435)" Date: Thu, 6 Sep 2018 09:22:38 -0400 Subject: Udates for feedback from demo Changes made to org.onap.pomba.common.datatypes.ModelContext, specifically nfNamingCode and networkType have been adapted in networkDiscoveryContextBuilder Changes made to networkdiscovery.spec to only return attributes and values from the network, no AAI. Also changed the name of this file as it is not a JSON formatted file. James McNider needs to confirm this dependency on ND OOM before we merge. Fixed onap-java-style audit issues with NetworkDiscoveryContextBuilderTest.java Issue-ID: LOG-643 Change-Id: Id18b25d2fea350f93a705b94e96ad26c480c19a0 Signed-off-by: Tait,Trevor(rt0435) --- config/networkdiscovery.spec | 67 ++++++++++ config/networkdiscoveryspec.json | 140 --------------------- .../service/SpringServiceImpl.java | 6 +- .../NetworkDiscoveryContextBuilderTest.java | 10 +- 4 files changed, 75 insertions(+), 148 deletions(-) create mode 100644 config/networkdiscovery.spec delete mode 100644 config/networkdiscoveryspec.json diff --git a/config/networkdiscovery.spec b/config/networkdiscovery.spec new file mode 100644 index 0000000..8da7a87 --- /dev/null +++ b/config/networkdiscovery.spec @@ -0,0 +1,67 @@ +[ + // Use https://jolt-demo.appspot.com/#inception to develop/test + // any changes to this file + + { + // This sections adds nfNamingCode and dataQuality to the json + // fields returned from service-decomposition that we are + // interested in + "operation": "default", + "spec": { + "generic-vnfs[]": { + "*": { + "vf-modules": { + "vf-module[]": { + "*": {} + } + }, + "vservers[]": { + "*": { + "nfNamingCode": "vserver" + } + }, + "l3-networks[]": { + "*": { + "type": "l3-network" + } + }, + "vnfcList[]": { + "*": { + "type": "vnfc" + } + } + } + } + } + }, + { + // This section converts the updated json from service-decompostion + // to org.onap.pomba.common.datatypes.ModelContext + "operation": "shift", + "spec": { + "service-instance-id": "service.uuid", + "generic-vnfs": { + "*": { + "vservers": { + "*": { + "vserver-id": "vfList[&3].vfModuleList[0].vmList[&1].uuid", + "nfNamingCode": "vfList[&3].vfModuleList[0].vmList[&1].nfNamingCode" + } + }, + "l3-networks": { + "*": { + "network-id": "vfList[&3].vfModuleList[0].networkList[&1].uuid", + "type": "vfList[&3].vfModuleList[0].networkList[&1].type" + }, + "vnfcs": { + "*": { + "vnfc-id": "vfList[&2].vnfcList[&1].uuid", + "type": "vfList[&2].vfModuleList[0].type" + } + } + } + } + } + } + } + ] diff --git a/config/networkdiscoveryspec.json b/config/networkdiscoveryspec.json deleted file mode 100644 index b01fbeb..0000000 --- a/config/networkdiscoveryspec.json +++ /dev/null @@ -1,140 +0,0 @@ -[ - // Use https://jolt-demo.appspot.com/#inception to develop/test - // any changes to this file - - { - // This sections adds nfNamingCode and dataQuality to the json - // fields returned from service-decomposition that we are - // interested in - - "operation": "default", - "spec": { - "dataQuality": { - "status": "ok" - }, - "generic-vnfs[]": { - "*": { - "dataQuality": { - "status": "ok" - }, - "nfNamingCode": "vf", - "vf-modules": { - "vf-module[]": { - "*": { - "dataQuality": { - "status": "ok" - }, - "nfNamingCode": "vfModule" - } - } - }, - "vservers[]": { - "*": { - "dataQuality": { - "status": "ok" - }, - "nfNamingCode": "vserver" - } - }, - "l3-networks[]": { - "*": { - "dataQuality": { - "status": "ok" - }, - "nfNamingCode": "l3-network" - } - }, - "vnfcList[]": { - "*": { - "dataQuality": { - "status": "ok" - }, - "nfNamingCode": "vnfc" - } - } - } - } - } - }, - { - // This section converts the updated json from service-decompostion - // to org.onap.pomba.common.datatypes.ModelContext - - "operation": "shift", - "spec": { - "dataQuality": { - "status": "dataQuality.status" - }, - "service-instance-name": "service.name", - "model-invariant-id": "service.invariantUUID", - "service-instance-id": "service.uuid", - "generic-vnfs": { - "*": { - "vnf-name": "vfList[&1].name", - "model-invariant-id": "vfList[&1].invariantUUID", - "vnf-id": "vfList[&1].uuid", - "nfNamingCode": "vfList[&1].nfNamingCode", - "dataQuality": { - "status": "vfList[&2].dataQuality.status" - }, - "vf-modules": { - "vf-module": { - "*": { - "vf-module-name": "vfList[&4].vfModuleList[0].name", - "model-invariant-id": "vfList[&4].vfModuleList[0].invariantUUID", - "vf-module-id": "vfList[&4].vfModuleList[0].uuid", - "nfNamingCode": "vfList[&4].vfModuleList[0].nfNamingCode", - "dataQuality": { - "status": "vfList[&5].vfModuleList[0].dataQuality.status" - } - } - } - }, - "vservers": { - "*": { - "vserver-name": "vfList[&3].vfModuleList[0].vmList[&1].name", - "model-invariant-id": "vfList[&3].vfModuleList[0].vmList[&1].invariantUUID", - "vserver-id": "vfList[&3].vfModuleList[0].vmList[&1].uuid", - "nfNamingCode": "vfList[&3].vfModuleList[0].vmList[&1].nfNamingCode", - "dataQuality": { - "status": "vfList[&4].vfModuleList[0].vmList[&2].dataQuality.status" - } - } - }, - "l3-networks": { - "*": { - "network-name": "vfList[&3].vfModuleList[0].networkList[&1].name", - "model-invariant-id": "vfList[&3].vfModuleList[0].networkList[&1].invariantUUID", - "network-id": "vfList[&3].vfModuleList[0].networkList[&1].uuid", - "nfNamingCode": "vfList[&3].vfModuleList[0].networkList[&1].nfNamingCode", - "dataQuality": { - "status": "vfList[&4].vfModuleList[0].networkList[&2].dataQuality.status" - } - }, - "vnfcs": { - "*": { - "vnfc-name": "vfList[&2].vnfcList[&1].name", - "model-invariant-id": "vfList[&2].vnfcList[&1].invariantUUID", - "vnfc-id": "vfList[&2].vnfcList[&1].uuid", - "nfNamingCode": "vfList[&2].vfModuleList[0].nfNamingCode", - "dataQuality": { - "status": "vfList[&3].vfModuleList[0].dataQuality.status" - } - } - } - } - } - } - } - }, - { - "operation": "default", - "spec": { - "service": { - "dataQuality": { - "status": "ok" - } - } - } - } - ] diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringServiceImpl.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringServiceImpl.java index d982ada..02b223b 100644 --- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringServiceImpl.java +++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringServiceImpl.java @@ -256,7 +256,7 @@ public class SpringServiceImpl implements SpringService { + serviceInstanceId + ", message body: " + reply); } - List jsonSpec = JsonUtils.filepathToList("config/networkdiscoveryspec.json"); + List jsonSpec = JsonUtils.filepathToList("config/networkdiscovery.spec"); Object jsonInput = JsonUtils.jsonToObject(reply); Chainr chainr = Chainr.fromSpec(jsonSpec); Object transObject = chainr.transform(jsonInput); @@ -460,14 +460,14 @@ public class SpringServiceImpl implements SpringService { for (VF vf : networkDiscoveryCtx.getVfs()) { for (VNFC vnfc : vf.getVnfcs()) { - ndresourceList.add(new NdResource(vnfc.getNfcNamingCode(), vnfc.getUuid())); + ndresourceList.add(new NdResource(vnfc.getType(), vnfc.getUuid())); } for (VFModule vfModule : vf.getVfModules()) { for (VM vm : vfModule.getVms() ) { ndresourceList.add(new NdResource(vm.getNfcNamingCode(), vm.getUuid())); } for (Network network : vfModule.getNetworks()) { - ndresourceList.add(new NdResource(network.getNfcNamingCode(), network.getUuid())); + ndresourceList.add(new NdResource(network.getType(), network.getUuid())); } } } diff --git a/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/unittest/service/NetworkDiscoveryContextBuilderTest.java b/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/unittest/service/NetworkDiscoveryContextBuilderTest.java index 19af1f3..1705bde 100644 --- a/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/unittest/service/NetworkDiscoveryContextBuilderTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/unittest/service/NetworkDiscoveryContextBuilderTest.java @@ -21,6 +21,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; +import com.github.jknack.handlebars.internal.Files; +import com.github.tomakehurst.wiremock.client.WireMock; +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import com.github.tomakehurst.wiremock.matching.UrlPattern; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -55,10 +59,6 @@ import org.springframework.core.env.Environment; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; -import com.github.jknack.handlebars.internal.Files; -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import com.github.tomakehurst.wiremock.matching.UrlPattern; @RunWith(SpringJUnit4ClassRunner.class) @@ -262,10 +262,10 @@ public class NetworkDiscoveryContextBuilderTest { dataQuality.setStatus(DataQuality.Status.ok); myResource.setDataQuality(dataQuality); Attribute attribute = new Attribute(); - List attributeList = new ArrayList<>(); attribute.setName("vserver-id"); attribute.setValue("25fb07ab-0478-465e-a021-6384ac299671"); attribute.setDataQuality(dataQuality); + List attributeList = new ArrayList<>(); attributeList.add(attribute); attribute.setName("power-state"); -- cgit 1.2.3-korg