aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNorm Traxler <normant@amdocs.com>2019-01-21 21:03:59 +0000
committerNorm Traxler <normant@amdocs.com>2019-01-22 14:23:19 +0000
commit5c07f0088fd71e30bfd8dc92b870f604b4297420 (patch)
tree8f4fca51f25c591888b6dad00c6b94ee0db6a1ce
parentcdad28821c2ac6834e284aae72f10ad2d0529147 (diff)
NetworkDiscCtxBuilder error handling
Issue-ID: LOG-938 Change-Id: I20e8592efe5f1ca8960f228041303c8d25628018 Signed-off-by: Norm Traxler <normant@amdocs.com>
-rw-r--r--.gitignore15
-rw-r--r--config/jolt/sdToModelContextSpec.json (renamed from config/networkdiscovery.spec)2
-rw-r--r--config/jolt/sdToNdResourcesSpec.json43
-rw-r--r--config/ndQuery.spec34
-rw-r--r--pom.xml2
-rw-r--r--src/main/docker/Dockerfile3
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/Application.java1
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/JerseyConfiguration.java20
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/NdctxbConfiguration.java49
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/WebConfiguration.java1
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/exception/DiscoveryException.java35
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/exception/ErrorMessage.java1
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdQuery.java45
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResource.java5
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResources.java4
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResourcesList.java45
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NetworkDiscoveryRspInfo.java93
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringService.java1
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringServiceImpl.java358
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/rs/RestService.java5
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/rs/RestServiceImpl.java45
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/util/RestUtil.java8
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/NetworkDiscoveryRspInfoTest.java104
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/jolt/TransformationTest.java48
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/unittest/service/NetworkDiscoveryContextBuilderTest.java163
-rw-r--r--src/test/resources/jolt/serviceDecompResponse.json211
-rw-r--r--src/test/resources/jolt/serviceDecompToModelContext-expected.json108
-rw-r--r--src/test/resources/jolt/serviceDecompToNdQuery-expected.json16
-rw-r--r--src/test/resources/jolt/serviceDecompToNdQuery-input.json260
-rw-r--r--src/test/resources/jolt/serviceDecompToNdResources-expected.json21
-rw-r--r--src/test/resources/junit/SD_response.json557
-rw-r--r--src/test/resources/junit/networkDiscovery-1.json83
-rw-r--r--src/test/resources/junit/networkDiscoveryResponseL3Network.json83
-rw-r--r--src/test/resources/junit/networkDiscoveryResponseVserver-1.json (renamed from src/test/resources/junit/networkDiscoveryResponse-1.json)12
-rw-r--r--src/test/resources/junit/serviceDecompositionResponse-1.json (renamed from src/test/resources/junit/serviceDecomposition-1.json)2
35 files changed, 841 insertions, 1642 deletions
diff --git a/.gitignore b/.gitignore
index 306f683..5fcf40e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,8 @@
-.idea/
-target/
-.settings/
-logs/*
-.classpath
-.project
-
+.idea/
+target/
+.settings/
+logs/*
+.classpath
+.project
+
+.checkstyle
diff --git a/config/networkdiscovery.spec b/config/jolt/sdToModelContextSpec.json
index 2cc882c..88201a7 100644
--- a/config/networkdiscovery.spec
+++ b/config/jolt/sdToModelContextSpec.json
@@ -11,7 +11,7 @@
"*": {
"vservers": {
"*": {
- "vserver-id": "vnfList[&3].vfModuleList[0].vmList[&1].uuid"
+ "vserver-id": "vnfList[&3].vfModuleList[0].vmList[&1].uuid"
}
},
"l3-networks": {
diff --git a/config/jolt/sdToNdResourcesSpec.json b/config/jolt/sdToNdResourcesSpec.json
new file mode 100644
index 0000000..c7d7496
--- /dev/null
+++ b/config/jolt/sdToNdResourcesSpec.json
@@ -0,0 +1,43 @@
+[
+ // Use https://jolt-demo.appspot.com/#inception to develop/test
+ // any changes to this file
+ {
+ // This section converts the updated json from service-decomposition
+ // to org.onap.pomba.contextbuilder.networkdiscovery.model.NdResources
+ "operation": "shift",
+ "spec": {
+ "generic-vnfs": {
+ "*": {
+ "vservers": {
+ "*": {
+ "vserver-id": {
+ "@": "tempResourceId",
+ "#vserver": "tempResourceType"
+
+ }
+ }},
+ "l3-networks": {
+ "*": {
+ "network-id": {
+ "@": "tempResourceId",
+ "#l3-network": "tempResourceType"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ {
+ "operation": "shift",
+ "spec": {
+ "tempResourceType": {
+ "*": {
+ "@": "ndResources[&].resourceType",
+ "@(2,tempResourceId[&])": "ndResources[&].resourceId"
+ }
+ }
+ }
+ }
+
+]
diff --git a/config/ndQuery.spec b/config/ndQuery.spec
deleted file mode 100644
index d9248be..0000000
--- a/config/ndQuery.spec
+++ /dev/null
@@ -1,34 +0,0 @@
-[
- // Use https://jolt-demo.appspot.com/#inception to develop/test
- // any changes to this file
- {
- // This section converts the updated json from service-decomposition
- // to org.onap.pomba.contextbuilder.networkdiscovery.model.NdQuery
- "operation": "shift",
- "spec": {
- "generic-vnfs": {
- "*": {
- "vservers": {
- "*": {
- "vserver-id": "ndQuery[&3].ndResourcesList[0].ndResources[&1].resourceId",
- "#vserver": "ndQuery[&3].ndResourcesList[0].ndResources[&1].resourceType"
- }
- },
- "l3-networks": {
- "*": {
- "network-id": "ndQuery[&3].ndResourcesList[1].ndResources[&1].resourceId",
- "#l3-network": "ndQuery[&3].ndResourcesList[1].ndResources[&1].resourceType"
- }
- },
- "vnfcs": {
- "*": {
- "vnfc-id": "ndQuery[&3].ndResourcesList[2].ndResources[&1].resourceId",
- "#vnfc": "ndQuery[&3].ndResourcesList[2].ndResources[&1].resourceType"
- }
- }
- }
- }
- }
- }
-
- ]
diff --git a/pom.xml b/pom.xml
index 3f41974..1edf07f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -310,7 +310,7 @@ limitations under the License.
<includes>
<include>*.properties</include>
<include>*.xml</include>
- <include>*.spec</include>
+ <include>**/*.json</include>
</includes>
<filtering>false</filtering>
</resource>
diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile
index 9963da1..eb50570 100644
--- a/src/main/docker/Dockerfile
+++ b/src/main/docker/Dockerfile
@@ -5,6 +5,7 @@ ARG MICROSERVICE_HOME=/opt/app/
# Build up the deployment folder structure
RUN mkdir -p $MICROSERVICE_HOME
RUN mkdir -p $MICROSERVICE_HOME/config/
+RUN mkdir -p $MICROSERVICE_HOME/config/jolt/
RUN mkdir -p $MICROSERVICE_HOME/lib/
RUN mkdir -p $MICROSERVICE_HOME/bin/
@@ -16,4 +17,4 @@ RUN chmod 755 $MICROSERVICE_HOME/config/*
RUN chmod 755 $MICROSERVICE_HOME/lib/*
RUN chmod 755 $MICROSERVICE_HOME/bin/*
-CMD ["/opt/app/bin/startService.sh"] \ No newline at end of file
+CMD ["/opt/app/bin/startService.sh"]
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/Application.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/Application.java
index f5e8247..397aabc 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/Application.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/Application.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.networkdiscovery;
import org.springframework.boot.SpringApplication;
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/JerseyConfiguration.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/JerseyConfiguration.java
index 2bec9ad..7d97614 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/JerseyConfiguration.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/JerseyConfiguration.java
@@ -15,18 +15,15 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.networkdiscovery;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.MapperFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.logging.Logger;
+
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
@@ -36,6 +33,7 @@ import javax.net.ssl.X509TrustManager;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
+
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.server.ResourceConfig;
@@ -43,7 +41,6 @@ import org.glassfish.jersey.servlet.ServletProperties;
import org.onap.pomba.contextbuilder.networkdiscovery.service.rs.RestServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
@Component
@@ -59,17 +56,6 @@ public class JerseyConfiguration extends ResourceConfig {
}
@Bean
- @Primary
- public ObjectMapper objectMapper() {
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
- objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
- objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
- return objectMapper;
- }
-
- @Bean
public Client jerseyClient() {
return ClientBuilder.newClient(new ClientConfig());
}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/NdctxbConfiguration.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/NdctxbConfiguration.java
index f123e62..ed39de7 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/NdctxbConfiguration.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/NdctxbConfiguration.java
@@ -18,29 +18,17 @@
package org.onap.pomba.contextbuilder.networkdiscovery;
-import java.util.Arrays;
import java.util.Base64;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.stream.StreamSupport;
import org.eclipse.jetty.util.security.Password;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
-import org.springframework.core.env.AbstractEnvironment;
-import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.Environment;
-import org.springframework.core.env.MutablePropertySources;
import org.springframework.stereotype.Component;
@Component
public class NdctxbConfiguration {
- private static Logger log = LoggerFactory.getLogger(NdctxbConfiguration.class);
- private static final String PREFIX_RESOURCE_TYPE = "networkDiscoveryCtxBuilder.resourceTypeMapping.";
- private static final String WHITE_SPACE = "\\s";
// Network Discovery Context Builder Configuration values
@@ -59,10 +47,6 @@ public class NdctxbConfiguration {
@Value("${networkDiscoveryCtxBuilder.password:OBF:1u2a1toa1w8v1tok1u30}")
private String networkDiscoveryCtxBuilderPassword;
- @Value("${networkDiscoveryCtxBuilder.resourceList:vnfcs}")
- private String networkDiscoveryCtxBuilderResourceList;
-
-
// Service Decomposition Configuration values
@Value("${serviceDecomposition.host:127.0.0.1}")
@@ -134,12 +118,6 @@ public class NdctxbConfiguration {
+ this.networkDiscoveryCtxBuilderPort;
}
- @Bean(name = "networkDiscoveryCtxBuilderResources")
- public String getNetworkDiscoveryCtxBuilderResourcs() {
- return this.networkDiscoveryCtxBuilderResourceList;
- }
-
-
@Bean(name = "networkDiscoveryMicroServiceBaseUrl")
public String getNetworkDiscoveryURL() {
return this.httpNetworkDiscoveryMicroServiceProtocol + "://" + this.networkDiscoveryMicroServiceHost + ":"
@@ -166,31 +144,4 @@ public class NdctxbConfiguration {
@Autowired
private Environment env;
- // This method builds a map between Service Decomposition resource type and Network Discovery
- // Context Builder resource type using dynamic mapping technique.
- // It scans the contents of the configuration file "application.properties",
- // searching for the string "networkDiscoveryCtxBuilder.resourceTypeMapping.", and if found,
- // anything from the remaining string will be used as the key (Service Decomposition resource Type)
- // to match to the value of assignment (network discovery context builder resource type).
- // For example,"networkDiscoveryCtxBuilder.resourceTypeMapping.BBB = bbb",
- // Service Decomposition resource type BBB matches to context builder resource type bbb
- @Bean(name = "networkDiscoveryCtxBuilderResourceTypeMapping")
- public Map<String, String> getResourceTypeMapping() {
- Map<String, String> props = new HashMap<>();
- MutablePropertySources propSrcs = ((AbstractEnvironment) this.env).getPropertySources();
- StreamSupport.stream(propSrcs.spliterator(), false)
- .filter(ps -> ps instanceof EnumerablePropertySource)
- .map(ps -> ((EnumerablePropertySource<?>) ps).getPropertyNames())
- .flatMap(Arrays::<String>stream)
- .forEach(propName -> {
- if (propName.startsWith(PREFIX_RESOURCE_TYPE)) {
- String myKey = propName.substring(PREFIX_RESOURCE_TYPE.length()).replaceAll(WHITE_SPACE,"");
- String myValue = this.env.getProperty(propName).replaceAll(WHITE_SPACE, "");
- props.put( myKey , myValue);
- }
- });
-
- log.info(props.toString());
- return props;
- }
}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/WebConfiguration.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/WebConfiguration.java
index ed779b8..e7a446e 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/WebConfiguration.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/WebConfiguration.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.networkdiscovery;
import org.springframework.context.annotation.Bean;
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/exception/DiscoveryException.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/exception/DiscoveryException.java
index 149efaa..0107672 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/exception/DiscoveryException.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/exception/DiscoveryException.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.networkdiscovery.exception;
import javax.ws.rs.core.Response.Status;
@@ -25,11 +26,11 @@ public class DiscoveryException extends Exception {
private final Status httpStatus;
- public DiscoveryException(String message) {
- super(message);
- this.httpStatus = matchErrorCode(message);
- }
-
+ /**
+ * Internal Exception class with HTTP status.
+ * @param message Exception message
+ * @param httpStatus The http status code
+ */
public DiscoveryException(String message, Status httpStatus) {
super(message);
if (httpStatus == null) {
@@ -38,32 +39,8 @@ public class DiscoveryException extends Exception {
this.httpStatus = httpStatus;
}
- public DiscoveryException(String message, Exception cause) {
- super(message, cause);
- this.httpStatus = matchErrorCode(cause.getMessage());
- }
-
public Status getHttpStatus() {
return this.httpStatus;
}
- private Status matchErrorCode(String errorMessage) {
- if(null == errorMessage) {
- return Status.INTERNAL_SERVER_ERROR;
- }
- if (errorMessage.toLowerCase().contains("auth")) {
- return Status.UNAUTHORIZED;
- }
- if ((errorMessage.toLowerCase().contains("missing"))) {
- return Status.BAD_REQUEST;
- } else {
- for (Status st : Status.values()) {
-
- if (errorMessage.toLowerCase().contains(st.getReasonPhrase().toLowerCase())) {
- return st;
- }
- }
- }
- return Status.INTERNAL_SERVER_ERROR;
- }
}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/exception/ErrorMessage.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/exception/ErrorMessage.java
index 7bf9e96..90a75d2 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/exception/ErrorMessage.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/exception/ErrorMessage.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.networkdiscovery.exception;
public class ErrorMessage {
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdQuery.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdQuery.java
deleted file mode 100644
index f40af2b..0000000
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdQuery.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
- * 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.
- * ============LICENSE_END=====================================================
- */
-
-package org.onap.pomba.contextbuilder.networkdiscovery.model;
-
-import com.google.gson.annotations.Expose;
-import com.google.gson.annotations.SerializedName;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import java.util.ArrayList;
-import java.util.List;
-
-@ApiModel(value="NdQuery")
-public class NdQuery {
-
- @Expose
- @SerializedName("ndQuery")
- private List<NdResourcesList> ndQuery = new ArrayList<>();
-
- @ApiModelProperty(value = "List of NdResource associated with the service instance")
- public List<NdResourcesList> getNdQuery() {
- return ndQuery;
- }
- public void setNdQuery(List<NdResourcesList> ndQuery) {
- this.ndQuery = ndQuery;
- }
- public void addNdQuery(NdResourcesList ndResourcesList) {
- this.ndQuery.add(ndResourcesList);
- }
-}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResource.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResource.java
index a4575b6..9f79849 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResource.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResource.java
@@ -23,7 +23,7 @@ import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-@ApiModel(value="NdResource")
+@ApiModel(value = "NdResource")
public class NdResource {
@Expose
@@ -37,13 +37,16 @@ public class NdResource {
public String getResourceId() {
return resourceId;
}
+
public void setResourceId(String resourceId) {
this.resourceId = resourceId;
}
+
@ApiModelProperty(value = "Type of Resource for Network Discovery")
public String getResourceType() {
return resourceType;
}
+
public void setResourceType(String resourceType) {
this.resourceType = resourceType;
}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResources.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResources.java
index a1592fc..54e627d 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResources.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResources.java
@@ -25,7 +25,7 @@ import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
-@ApiModel(value="NdResources")
+@ApiModel(value = "NdResources")
public class NdResources {
@Expose
@@ -36,9 +36,11 @@ public class NdResources {
public List<NdResource> getNdResources() {
return ndResources;
}
+
public void setNdResources(List<NdResource> ndResources) {
this.ndResources = ndResources;
}
+
public void addNdResource(NdResource ndResource) {
this.ndResources.add(ndResource);
}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResourcesList.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResourcesList.java
deleted file mode 100644
index c7e397f..0000000
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NdResourcesList.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
- * 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.
- * ============LICENSE_END=====================================================
- */
-
-package org.onap.pomba.contextbuilder.networkdiscovery.model;
-
-import com.google.gson.annotations.Expose;
-import com.google.gson.annotations.SerializedName;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import java.util.ArrayList;
-import java.util.List;
-
-@ApiModel(value="NdResourcesList")
-public class NdResourcesList {
-
- @Expose
- @SerializedName("ndResourcesList")
- private List<NdResources> ndResourcesList = new ArrayList<>();
-
- @ApiModelProperty(value = "List of NdResources associated with the service instance")
- public List<NdResources> getNdResources() {
- return ndResourcesList;
- }
- public void setNdResources(List<NdResources> ndResourcesList) {
- this.ndResourcesList = ndResourcesList;
- }
- public void addNdResource(NdResources ndResources) {
- this.ndResourcesList.add(ndResources);
- }
-}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NetworkDiscoveryRspInfo.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NetworkDiscoveryRspInfo.java
deleted file mode 100644
index b371631..0000000
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/model/NetworkDiscoveryRspInfo.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
- * 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.
- * ============LICENSE_END=====================================================
- */
-package org.onap.pomba.contextbuilder.networkdiscovery.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
-import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.NetworkDiscoveryNotification;
-
-public class NetworkDiscoveryRspInfo {
-
- private String requestId;
- private String resourceId; // e.g.:
- // vserverId
- private String resourceType; // e.g.:
- // vserver
- private CountDownLatch latchSignal;
-
- private List<NetworkDiscoveryNotification> networkDiscoveryNotificationList = Collections
- .synchronizedList(new ArrayList<>());
- private List<String> relatedRequestIdList;
-
- public String getRequestId() {
- return requestId;
- }
-
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- public String getResourceType() {
- return resourceType;
- }
-
- public void setResourceType(String resourceType) {
- this.resourceType = resourceType;
- }
-
- public String getResourceId() {
- return resourceId;
- }
-
- public void setResourceId(String resourceId) {
- this.resourceId = resourceId;
- }
-
- public CountDownLatch getLatchSignal() {
- return latchSignal;
- }
-
- public void setLatchSignal(CountDownLatch latchSignal) {
- this.latchSignal = latchSignal;
- }
-
- public List<NetworkDiscoveryNotification> getNetworkDiscoveryNotificationList() {
- return this.networkDiscoveryNotificationList;
- }
-
- public void setNetworkDiscoveryNotificationList(List<NetworkDiscoveryNotification> response) {
- this.networkDiscoveryNotificationList = response;
- }
-
- public List<String> getRelatedRequestIdList() {
- return this.relatedRequestIdList;
- }
-
- public void setRelatedRequestIdList(List<String> response) {
- this.relatedRequestIdList = response;
- }
-
- @Override
- public String toString() {
- return "networkDiscoveryRspInfo [requestId=" + this.requestId + ", resourceId=" + this.resourceId
- + ", resourceType=" + this.resourceType + "]";
- }
-}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringService.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringService.java
index 4a8c50c..6b707ee 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringService.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringService.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.networkdiscovery.service;
import javax.servlet.http.HttpServletRequest;
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 b6c1d12..2df082c 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
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.networkdiscovery.service;
import com.bazaarvoice.jolt.Chainr;
@@ -38,16 +39,15 @@ import javax.ws.rs.core.Response.Status.Family;
import org.onap.aai.restclient.client.Headers;
import org.onap.pomba.common.datatypes.Attribute;
+import org.onap.pomba.common.datatypes.DataQuality;
import org.onap.pomba.common.datatypes.ModelContext;
import org.onap.pomba.common.datatypes.Network;
import org.onap.pomba.common.datatypes.VFModule;
import org.onap.pomba.common.datatypes.VM;
import org.onap.pomba.common.datatypes.VNF;
import org.onap.pomba.contextbuilder.networkdiscovery.exception.DiscoveryException;
-import org.onap.pomba.contextbuilder.networkdiscovery.model.NdQuery;
import org.onap.pomba.contextbuilder.networkdiscovery.model.NdResource;
import org.onap.pomba.contextbuilder.networkdiscovery.model.NdResources;
-import org.onap.pomba.contextbuilder.networkdiscovery.model.NdResourcesList;
import org.onap.pomba.contextbuilder.networkdiscovery.service.rs.RestService;
import org.onap.pomba.contextbuilder.networkdiscovery.util.RestUtil;
import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.NetworkDiscoveryNotification;
@@ -122,47 +122,33 @@ public class SpringServiceImpl implements SpringService {
String serviceInstanceId, String modelVersionId, String modelInvariantId) throws DiscoveryException {
String remoteAddress = req.getRemoteAddr() != null ? req.getRemoteAddr() : null;
- initMDC(requestId, partnerName, serviceInstanceId, remoteAddress);
-
- try {
- RestUtil.validateServiceInstanceId(serviceInstanceId);
- RestUtil.validatePartnerName(partnerName);
- validateBasicAuth(authorization);
- String sdReply = getServiceDeomposition(serviceInstanceId, partnerName, requestId);
- ModelContext networkDiscoveryCtx = createModelContextFromSdResonse(sdReply);
- NdQuery ndQuery = createNdQueryFromSdResonse(sdReply);
- sendNetworkDiscoveryRequest(networkDiscoveryCtx, ndQuery, requestId, partnerName);
- return networkDiscoveryCtx;
-
- } catch (Exception x) {
- DiscoveryException exception = new DiscoveryException(x.getMessage(), x);
- MDC.put(MDC_RESPONSE_CODE, String.valueOf(exception.getHttpStatus().getStatusCode()));
- MDC.put(MDC_STATUS_CODE, "ERROR");
- log.error(x.getMessage());
- throw exception;
- } finally {
- MDC.clear();
- }
+ initMdc(requestId, partnerName, serviceInstanceId, remoteAddress);
+
+ RestUtil.validateServiceInstanceId(serviceInstanceId);
+ RestUtil.validatePartnerName(partnerName);
+ validateBasicAuth(authorization);
+ String sdReply = getServiceDeomposition(serviceInstanceId, partnerName, requestId);
+ ModelContext networkDiscoveryCtx = createModelContextFromSdResonse(sdReply);
+ NdResources ndResources = createNdResourcesFromSdResonse(sdReply);
+ sendNetworkDiscoveryRequest(networkDiscoveryCtx, ndResources, requestId, partnerName);
+ return networkDiscoveryCtx;
}
- private void initMDC(String requestId, String partnerName, String serviceInstanceId, String remoteAddress) {
- MDC.clear();
- MDC.put(MDC_REQUEST_ID, requestId);
- MDC.put(MDC_SERVICE_NAME, APP_NAME);
- MDC.put(MDC_SERVICE_INSTANCE_ID, serviceInstanceId);
- MDC.put(MDC_PARTNER_NAME, partnerName);
- MDC.put(MDC_CLIENT_ADDRESS, remoteAddress);
- MDC.put(MDC_START_TIME, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(new Date()));
- MDC.put(MDC_INVOCATION_ID, UUID.randomUUID().toString());
- MDC.put(MDC_INSTANCE_UUID, instanceUUID.toString());
-
- try {
- MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName());
- } catch (Exception e) {
- // If, for some reason we are unable to get the canonical host name,
- // we
- // just want to leave the field null.
- log.info("Could not get canonical host name for " + MDC_SERVER_FQDN + ", leaving field null");
+ /**
+ * Validates the Basic authorization header as admin:admin.
+ *
+ * @throws DiscoveryException
+ * if there is missing parameter
+ */
+ public void validateBasicAuth(String authorization) throws DiscoveryException {
+ if (authorization != null && !authorization.trim().isEmpty() && authorization.startsWith("Basic")) {
+ if (!authorization.equals(networkDiscoveryCtxBuilderBasicAuthorization)) {
+ throw new DiscoveryException("Authorization Failed", Status.UNAUTHORIZED);
+ }
+ } else {
+ throw new DiscoveryException(
+ "Missing Authorization: " + (authorization == null ? "null" : authorization),
+ Status.UNAUTHORIZED);
}
}
@@ -174,77 +160,49 @@ public class SpringServiceImpl implements SpringService {
if (serviceInstanceId == null) {
return null;
}
+
+ String urlStr = serviceDecompositionBaseUrl + "?serviceInstanceId=" + serviceInstanceId;
- log.info("Querying Service Decomposition for service instance {}", serviceInstanceId);
-
- String urlStr = getUrl(serviceInstanceId);
-
- log.info("Querying Service Decomposition for url {}", urlStr);
+ log.info("Querying Service Decomposition for service instance {} at url {}", serviceInstanceId, urlStr);
+ Response response = jerseyClient.target(urlStr).request().header(Headers.ACCEPT, MediaType.APPLICATION_JSON)
+ .header(Headers.AUTHORIZATION, serviceDecompositionBasicAuthorization)
+ .header(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_X_ONAP_PARTNER_NAME, partnerName)
+ .header(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_X_ONAP_REQUEST_ID, requestId).get();
- try {
- Response response = jerseyClient.target(urlStr).request()
- .header(Headers.ACCEPT, MediaType.APPLICATION_JSON)
- .header(Headers.AUTHORIZATION, getSdBasicAuthorization())
- .header(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_X_ONAP_PARTNER_NAME, partnerName)
- .header(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_X_ONAP_REQUEST_ID, requestId).get();
-
- String reply = null;
- if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) {
- MDC.put(MDC_RESPONSE_CODE, String.valueOf(response.getStatus()));
- MDC.put(MDC_STATUS_CODE, "ERROR");
- throw new DiscoveryException(response.getStatusInfo().toString(),
- Response.Status.fromStatusCode(response.getStatus()));
- } else {
- MDC.put(MDC_RESPONSE_CODE, String.valueOf(response.getStatus()));
- MDC.put(MDC_STATUS_CODE, "COMPLETE");
- reply = response.readEntity(String.class);
-
- log.info(
- "GET Response from ServiceDecompositionMircoService GetContext for serviceInstanceId: {}, message body: {}",
- serviceInstanceId, reply);
- }
+ log.info(
+ "GET Response from ServiceDecompositionMircoService for serviceInstanceId: {}, status code {}",
+ serviceInstanceId, response.getStatusInfo().getStatusCode());
- return reply;
- } catch (Exception x) {
- throw new DiscoveryException(x.getMessage(), x);
+ if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) {
+ MDC.put(MDC_RESPONSE_CODE, String.valueOf(response.getStatus()));
+ MDC.put(MDC_STATUS_CODE, "ERROR");
+ throw new DiscoveryException(
+ "Error from Service Decomposition service: " + response.getStatusInfo().getReasonPhrase(),
+ Response.Status.fromStatusCode(response.getStatus()));
}
- }
- private String getUrl(String serviceInstanceId) {
- return serviceDecompositionBaseUrl + "?serviceInstanceId=" + serviceInstanceId;
- }
+ MDC.put(MDC_RESPONSE_CODE, String.valueOf(response.getStatus()));
+ MDC.put(MDC_STATUS_CODE, "COMPLETE");
+ String reply = response.readEntity(String.class);
- private String getSdBasicAuthorization() {
- return serviceDecompositionBasicAuthorization;
- }
+ log.info(
+ "GET Response from ServiceDecompositionMircoService GetContext for serviceInstanceId: {}, message body: {}",
+ serviceInstanceId, reply);
- /**
- * Validates the Basic authorization header as admin:admin.
- *
- * @throws DiscoveryException
- * if there is missing parameter
- */
- public void validateBasicAuth(String authorization) throws DiscoveryException {
- if (authorization != null && !authorization.trim().isEmpty() && authorization.startsWith("Basic")) {
- if (!authorization.equals(networkDiscoveryCtxBuilderBasicAuthorization)) {
- throw new DiscoveryException("Authorization Failed", Status.UNAUTHORIZED);
- }
- } else {
- throw new DiscoveryException(
- "Missing Authorization: " + (authorization == null ? "null" : authorization),
- Status.UNAUTHORIZED);
- }
+ return reply;
}
private void updateNetworkDiscoveryCtx(ModelContext networkDiscoveryCtx, Resource resource) {
+ // Future: try to replace this with a Jolt transformation.
for (VNF vnf : networkDiscoveryCtx.getVnfs()) {
for (VFModule vfModule : vnf.getVfModules()) {
for (VM vm : vfModule.getVms()) {
- if (vm.getUuid().equals(resource.getId())) {
+ if (vm.getUuid().equals(resource.getId()) && "vserver".equals(resource.getType())) {
vm.setDataQuality(resource.getDataQuality());
if (null != resource.getAttributeList()) {
- for (org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Attribute ndattribute : resource.getAttributeList()) {
+ for (org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Attribute ndattribute : resource
+ .getAttributeList()) {
try {
String ndattributeName = ndattribute.getName();
// Some Network Discovery attribute name do not exactly
@@ -270,41 +228,66 @@ public class SpringServiceImpl implements SpringService {
attribute.setValue(ndattribute.getValue());
attribute.setDataQuality(ndattribute.getDataQuality());
vm.addAttribute(attribute);
- break;
+ break;
default:
attribute = new Attribute();
attribute.setName(Attribute.Name.valueOf(ndattributeName));
attribute.setValue(ndattribute.getValue());
attribute.setDataQuality(ndattribute.getDataQuality());
- vm.addAttribute(attribute);
+ vm.addAttribute(attribute);
}
} catch (IllegalArgumentException ex) {
// The attribute Name passed back from Network Discovery is not in our enum
- log.info("Attribute Name: {} for Resource: {} Id: {} is invalid", ndattribute.getName(), resource.getName(), resource.getId());
+ log.info("Attribute Name: {} for Resource: {} Id: {} is invalid",
+ ndattribute.getName(), resource.getName(), resource.getId());
}
}
}
}
}
for (Network network : vfModule.getNetworks()) {
- if (network.getUuid().equals(resource.getId())) {
+ if (network.getUuid().equals(resource.getId()) && "l3-network".equals(resource.getType())) {
network.setDataQuality(resource.getDataQuality());
if (null != resource.getAttributeList()) {
- for (org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Attribute ndattribute : resource.getAttributeList()) {
+ for (org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Attribute ndattribute : resource
+ .getAttributeList()) {
try {
String ndattributeName = ndattribute.getName();
- if (ndattributeName.equals("name")) {
+ // Some Network Discovery attribute name do not exactly
+ // match the pomba-audit-common model Attribute Enums,
+ // so we have to do some custom mapping here:
+ switch (ndattributeName) {
+ case "id":
+ network.setUuid(ndattribute.getValue());
+ break;
+ case "name":
network.setName(ndattribute.getValue());
- }
- else {
+ break;
+ case "AdminState":
Attribute attribute = new Attribute();
+ attribute.setName(Attribute.Name.adminStatus);
+ attribute.setValue(ndattribute.getValue());
+ attribute.setDataQuality(ndattribute.getDataQuality());
+ network.addAttribute(attribute);
+ break;
+ case "sharedNetwork":
+ attribute = new Attribute();
+ attribute.setName(Attribute.Name.sharedNetworkBoolean);
+ attribute.setValue(ndattribute.getValue());
+ attribute.setDataQuality(ndattribute.getDataQuality());
+ network.addAttribute(attribute);
+ break;
+ default:
+ attribute = new Attribute();
attribute.setName(Attribute.Name.valueOf(ndattributeName));
attribute.setValue(ndattribute.getValue());
+ attribute.setDataQuality(ndattribute.getDataQuality());
network.addAttribute(attribute);
}
} catch (IllegalArgumentException ex) {
// The attribute Name passed back from Network Discovery is not in our enum
- log.info("Attribute Name: {} for Resource: {} Id: {} is invalid", ndattribute.getName(), resource.getName(), resource.getId());
+ log.info("Attribute Name: {} for Resource: {} Id: {} is invalid",
+ ndattribute.getName(), resource.getName(), resource.getId());
}
}
}
@@ -315,72 +298,111 @@ public class SpringServiceImpl implements SpringService {
}
}
+ private void updateNetworkDiscoveryCtxDataQuality(ModelContext networkDiscoveryCtx, String resourceId,
+ DataQuality dataQuality) {
+ for (VNF vnf : networkDiscoveryCtx.getVnfs()) {
+ for (VFModule vfModule : vnf.getVfModules()) {
+ for (VM vm : vfModule.getVms()) {
+ if (vm.getUuid().equals(resourceId)) {
+ vm.setDataQuality(dataQuality);
+ }
+ }
+ for (Network network : vfModule.getNetworks()) {
+ if (network.getUuid().equals(resourceId)) {
+ network.setDataQuality(dataQuality);
+ }
+ }
+
+ }
+ }
+ }
/* Return list of requestIds sent to network-discovery microService. */
- private void sendNetworkDiscoveryRequest(ModelContext networkDiscoveryCtx,
- NdQuery ndQuery,
- String parentRequestId,
- String partnerName) throws DiscoveryException {
- for (NdResourcesList ndResourcesList : ndQuery.getNdQuery()) {
- for (NdResources ndResources : ndResourcesList.getNdResources()) {
- for (NdResource ndResource : ndResources.getNdResources()) {
- // The old_requestId is inherited from ServiceDecomposition.
- // Before we send a message to NetworkDiscoveryMicroService for each Resource,
- // we need to generate a new request for identification, based on the old ID.
- String requestId = parentRequestId + NETWORK_DISCOVERY_RSP_REQUESTID_SPLITTER + uniqueSeq.incrementAndGet();
-
- NetworkDiscoveryNotification nt = sendNetworkDiscoveryRequestToSpecificServer(partnerName, parentRequestId,
- requestId, ndResource.getResourceId(), ndResource.getResourceType());
-
- List<Resource> resourceList = nt.getResources();
- for (Resource resource1 : resourceList) {
- updateNetworkDiscoveryCtx(networkDiscoveryCtx, resource1);
- }
+ private void sendNetworkDiscoveryRequest(ModelContext networkDiscoveryCtx, NdResources ndResources,
+ String parentRequestId, String partnerName) throws DiscoveryException {
+
+ for (NdResource ndResource : ndResources.getNdResources()) {
+ try {
+ // The old_requestId is inherited from ServiceDecomposition.
+ // Before we send a message to NetworkDiscoveryMicroService for each Resource,
+ // we need to generate a new request for identification, based on the old ID.
+ String requestId = parentRequestId + NETWORK_DISCOVERY_RSP_REQUESTID_SPLITTER
+ + uniqueSeq.incrementAndGet();
+
+ NetworkDiscoveryNotification nt = sendNetworkDiscoveryRequestToSpecificServer(partnerName,
+ parentRequestId, requestId, ndResource.getResourceId(), ndResource.getResourceType());
+
+ List<Resource> resourceList = nt.getResources();
+ for (Resource resource1 : resourceList) {
+ updateNetworkDiscoveryCtx(networkDiscoveryCtx, resource1);
}
+ } catch (Exception e) {
+ log.error("Error from Network Disovery Request - resourceId: {}, message: {}",
+ ndResource.getResourceId(), e.getMessage());
+ DataQuality dataQuality = DataQuality.error("Error from Network Disovery Request: " + e.getMessage());
+ updateNetworkDiscoveryCtxDataQuality(networkDiscoveryCtx, ndResource.getResourceId(), dataQuality);
}
}
}
- private NetworkDiscoveryNotification sendNetworkDiscoveryRequestToSpecificServer(String partnerName, String parentRequestId,
- String requestId, String resourceId, String resourceType)
+ private NetworkDiscoveryNotification sendNetworkDiscoveryRequestToSpecificServer(String partnerName,
+ String parentRequestId, String requestId, String resourceId, String resourceType)
throws DiscoveryException {
- String networkDiscoveryUrl = networkDiscoveryMicroServiceBaseUrl;
// Prepare MDC for logs
- initMdcSendToNetworkDiscoveryMicroService(networkDiscoveryUrl, requestId, resourceType, resourceId,
- partnerName);
+ initMdcSendToNetworkDiscoveryMicroService(networkDiscoveryMicroServiceBaseUrl, requestId, resourceType,
+ resourceId, partnerName);
- try {
- Response response = jerseySslClient.target(networkDiscoveryUrl)
- .queryParam(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_REQUEST_ID, requestId)
- .queryParam(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_RESOURCE_TYPE, resourceType)
- .queryParam(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_RESOURCE_ID, resourceId)
- .request()
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON)
- .header(HttpHeaders.AUTHORIZATION, getNetworkDiscoveryMircoServiceBasicAuthorization())
- .header(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_X_ONAP_PARTNER_NAME, partnerName)
- .header(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_X_ONAP_REQUEST_ID, parentRequestId).get();
-
- String status = Response.Status.fromStatusCode(response.getStatus()) + ",code:" + response.getStatus();
-
- if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) {
- MDC.put(MDC_TO_NETWORK_DISCOVERY_MICRO_SERVICE_STATUS, status);
- throw new DiscoveryException(response.getStatusInfo().toString(),
- Response.Status.fromStatusCode(response.getStatus()));
- } else {
- MDC.put(MDC_TO_NETWORK_DISCOVERY_MICRO_SERVICE_STATUS, status);
- NetworkDiscoveryNotification ndResponse = response.readEntity(NetworkDiscoveryNotification.class);
- log.info("Message sent. Response Payload: {}", ndResponse);
- return ndResponse;
- }
- } catch (Exception e) {
- MDC.put(MDC_TO_NETWORK_DISCOVERY_MICRO_SERVICE_STATUS, e.getMessage());
- throw new DiscoveryException(e.getMessage(), e);
+ log.info("Network Disvovery request for url {}, resourceId {}, resourceType {}",
+ networkDiscoveryMicroServiceBaseUrl, resourceId, resourceType);
+
+ Response response = jerseySslClient.target(networkDiscoveryMicroServiceBaseUrl)
+ .queryParam(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_REQUEST_ID, requestId)
+ .queryParam(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_RESOURCE_TYPE, resourceType)
+ .queryParam(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_RESOURCE_ID, resourceId).request()
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON)
+ .header(HttpHeaders.AUTHORIZATION, networkDiscoveryMicroServiceBasicAuthorization)
+ .header(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_X_ONAP_PARTNER_NAME, partnerName)
+ .header(NETWORK_DISCOVERY_FIND_RESOURCE_BY_TYPE_REST_X_ONAP_REQUEST_ID, parentRequestId).get();
+
+ String status = Response.Status.fromStatusCode(response.getStatus()) + ",code:" + response.getStatus();
+
+ log.info("Network Disvovery response status code: {}", response.getStatus());
+
+ MDC.put(MDC_TO_NETWORK_DISCOVERY_MICRO_SERVICE_STATUS, status);
+
+ if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) {
+ throw new DiscoveryException(
+ "Error from Network Discovery service: " + response.getStatusInfo().getReasonPhrase(),
+ Response.Status.fromStatusCode(response.getStatus()));
}
+
+ NetworkDiscoveryNotification ndResponse = response.readEntity(NetworkDiscoveryNotification.class);
+ log.info("Message sent. Response Payload: {}", ndResponse);
+ return ndResponse;
}
- private String getNetworkDiscoveryMircoServiceBasicAuthorization() {
- return networkDiscoveryMicroServiceBasicAuthorization;
+
+ private void initMdc(String requestId, String partnerName, String serviceInstanceId, String remoteAddress) {
+ MDC.clear();
+ MDC.put(MDC_REQUEST_ID, requestId);
+ MDC.put(MDC_SERVICE_NAME, APP_NAME);
+ MDC.put(MDC_SERVICE_INSTANCE_ID, serviceInstanceId);
+ MDC.put(MDC_PARTNER_NAME, partnerName);
+ MDC.put(MDC_CLIENT_ADDRESS, remoteAddress);
+ MDC.put(MDC_START_TIME, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(new Date()));
+ MDC.put(MDC_INVOCATION_ID, UUID.randomUUID().toString());
+ MDC.put(MDC_INSTANCE_UUID, instanceUUID.toString());
+
+ try {
+ MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName());
+ } catch (Exception e) {
+ // If, for some reason we are unable to get the canonical host name,
+ // we
+ // just want to leave the field null.
+ log.info("Could not get canonical host name for " + MDC_SERVER_FQDN + ", leaving field null");
+ }
}
private void initMdcSendToNetworkDiscoveryMicroService(String networkDiscoveryUrl, String requestId,
@@ -390,7 +412,7 @@ public class SpringServiceImpl implements SpringService {
String parentPartnerName = MDC.get(MDC_PARTNER_NAME);
MDC.clear();
- initMDC(parentRequestId, parentPartnerName, parentServiceInstanceId, networkDiscoveryMicroServiceHostAndPort);
+ initMdc(parentRequestId, parentPartnerName, parentServiceInstanceId, networkDiscoveryMicroServiceHostAndPort);
MDC.put(MDC_SERVICE_NAME, MDC_TO_NETWORK_DISCOVERY_MICRO_SERVICE_APP);
MDC.put(MDC_TO_NETWORK_DISCOVERY_MICRO_SERVICE_MSG_NAME,
@@ -410,30 +432,24 @@ public class SpringServiceImpl implements SpringService {
}
}
-
private ModelContext createModelContextFromSdResonse(String response) {
- List<Object> jsonSpec = JsonUtils.filepathToList("config/networkdiscovery.spec");
+ List<Object> jsonSpec = JsonUtils.filepathToList("config/jolt/sdToModelContextSpec.json");
Object jsonInput = JsonUtils.jsonToObject(response);
Chainr chainr = Chainr.fromSpec(jsonSpec);
Object transObject = chainr.transform(jsonInput);
+ log.debug("Jolt transformed output: {}", JsonUtils.toJsonString(transObject));
Gson gson = new Gson();
return gson.fromJson(JsonUtils.toPrettyJsonString(transObject), ModelContext.class);
-
}
- private NdQuery createNdQueryFromSdResonse(String response) {
- List<Object> jsonSpec = JsonUtils.filepathToList("config/ndQuery.spec");
+ private NdResources createNdResourcesFromSdResonse(String response) {
+ List<Object> jsonSpec = JsonUtils.filepathToList("config/jolt/sdToNdResourcesSpec.json");
Object jsonInput = JsonUtils.jsonToObject(response);
Chainr chainr = Chainr.fromSpec(jsonSpec);
Object transObject = chainr.transform(jsonInput);
- Gson gson = new Gson();
-
- log.info("Jolt transformed output: {}", JsonUtils.toJsonString(transObject));
-
-
- return gson.fromJson(JsonUtils.toPrettyJsonString(transObject), NdQuery.class);
-
+ log.debug("Jolt transformed output: {}", JsonUtils.toJsonString(transObject));
+ Gson gson = new Gson();
+ return gson.fromJson(JsonUtils.toPrettyJsonString(transObject), NdResources.class);
}
-
}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/rs/RestService.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/rs/RestService.java
index 55fe2d2..9b17e47 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/rs/RestService.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/rs/RestService.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.networkdiscovery.service.rs;
import javax.servlet.http.HttpServletRequest;
@@ -47,8 +48,8 @@ public interface RestService {
@ApiResponse(code = 404, message = "Service not available"),
@ApiResponse(code = 500, message = "Unexpected Runtime error") })
public Response getContext(@Context HttpServletRequest req, @HeaderParam("Authorization") String authorization,
- @HeaderParam("X-ONAP-PartnerName") String xpartnerName, @HeaderParam("X-ONAP-RequestID") String xRequestId,
- @HeaderParam("X-FromAppId") String xFromAppId, @HeaderParam("X-TransactionId") String xTransactionId,
+ @HeaderParam("X-ONAP-PartnerName") String xpartnerName, @HeaderParam("X-ONAP-RequestID") String requestId,
+ @HeaderParam("X-FromAppId") String fromAppId, @HeaderParam("X-TransactionId") String transactionId,
@QueryParam("serviceInstanceId") String serviceInstanceId,
@QueryParam("modelVersionId") String modelVersionId,
@QueryParam("modelInvariantId") String modelInvariantId) throws DiscoveryException;
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/rs/RestServiceImpl.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/rs/RestServiceImpl.java
index 53adbc4..67899ac 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/rs/RestServiceImpl.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/rs/RestServiceImpl.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.networkdiscovery.service.rs;
import com.google.gson.Gson;
@@ -32,6 +33,7 @@ import org.onap.pomba.contextbuilder.networkdiscovery.exception.ErrorMessage;
import org.onap.pomba.contextbuilder.networkdiscovery.service.SpringService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -45,27 +47,30 @@ public class RestServiceImpl implements RestService {
private SpringService service;
@Override
- public Response getContext(HttpServletRequest req, String authorization, String partnerName, String requestId, String fromAppId, String transactionId,
- String serviceInstanceId, String modelVersionId, String modelInvariantId) throws DiscoveryException {
+ public Response getContext(HttpServletRequest req, String authorization, String partnerName, String requestId,
+ String fromAppId, String transactionId, String serviceInstanceId, String modelVersionId,
+ String modelInvariantId) throws DiscoveryException {
// Do some validation on Http headers and URL parameters
- //The request ID in the header is not yet standardized to X-ONAP-RequestID. We would still support X-TransactionId until further notice.
- if(requestId == null || requestId.isEmpty()) {
- if(transactionId != null) {
- requestId = transactionId;
- } else {
- requestId = UUID.randomUUID().toString();
- log.debug("{} is missing; using newly generated value: {}", HEADER_REQUEST_ID, requestId);
- }
- }
+ // The request ID in the header is not yet standardized to X-ONAP-RequestID. We
+ // would still support X-TransactionId until further notice.
+ if (requestId == null || requestId.isEmpty()) {
+ if (transactionId != null) {
+ requestId = transactionId;
+ } else {
+ requestId = UUID.randomUUID().toString();
+ log.debug("{} is missing; using newly generated value: {}", HEADER_REQUEST_ID, requestId);
+ }
+ }
- //The partner name in the header is not yet standardized to X-PartnerName. We would still support X-FromAppId until further notice.
- if(partnerName == null || partnerName.isEmpty()) {
- if(fromAppId != null) {
- partnerName = fromAppId;
- }
- }
+ // The partner name in the header is not yet standardized to X-PartnerName. We
+ // would still support X-FromAppId until further notice.
+ if (partnerName == null || partnerName.isEmpty()) {
+ if (fromAppId != null) {
+ partnerName = fromAppId;
+ }
+ }
try {
ModelContext sdContext = service.getContext(req, partnerName, authorization, requestId, serviceInstanceId,
@@ -78,13 +83,17 @@ public class RestServiceImpl implements RestService {
return Response.ok().entity(gson.toJson(sdContext)).build();
}
} catch (DiscoveryException x) {
- log.error(ErrorMessage.CONTEXT_BUILDER_FAILED, x);
+ log.warn(ErrorMessage.CONTEXT_BUILDER_FAILED, x);
return Response.status(x.getHttpStatus()).entity(x.getMessage()).build();
} catch (Exception x) {
log.error(ErrorMessage.CONTEXT_BUILDER_FAILED, x);
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(x.getMessage()).build();
+
+ } finally {
+ MDC.clear();
}
+
}
}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/util/RestUtil.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/util/RestUtil.java
index fe10949..636e9ca 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/util/RestUtil.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/util/RestUtil.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.networkdiscovery.util;
import javax.ws.rs.core.Response.Status;
@@ -39,10 +40,11 @@ public class RestUtil {
*/
public static void validateServiceInstanceId(String serviceInstanceId) throws DiscoveryException {
- if (serviceInstanceId == null || serviceInstanceId.trim().isEmpty())
+ if (serviceInstanceId == null || serviceInstanceId.trim().isEmpty()) {
throw new DiscoveryException(
ErrorMessage.INVALID_REQUEST_URL + ErrorMessage.MISSING_PARAMTER + SERVICE_INSTANCE_ID,
- Status.BAD_REQUEST);
+ Status.BAD_REQUEST);
+ }
}
/**
@@ -54,7 +56,7 @@ public class RestUtil {
public static void validatePartnerName(String partnerName) throws DiscoveryException {
if ((partnerName == null) || partnerName.trim().isEmpty()) {
- throw new DiscoveryException(ErrorMessage.MISSING_PARAMTER + HEADER_PARTNER_NAME, Status.BAD_REQUEST);
+ throw new DiscoveryException(ErrorMessage.MISSING_PARAMTER + HEADER_PARTNER_NAME, Status.BAD_REQUEST);
}
}
diff --git a/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/NetworkDiscoveryRspInfoTest.java b/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/NetworkDiscoveryRspInfoTest.java
deleted file mode 100644
index af2ba01..0000000
--- a/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/NetworkDiscoveryRspInfoTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
- * 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.
- * ============LICENSE_END=====================================================
- */
-
-package org.onap.pomba.contextbuilder.networkdiscovery.test;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.pomba.contextbuilder.networkdiscovery.model.NetworkDiscoveryRspInfo;
-import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.NetworkDiscoveryNotification;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
-import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class })
-@WebAppConfiguration
-@SpringBootTest
-@TestPropertySource(properties = { "enricher.url=http://localhost:9505", "serviceDecomposition.host=localhost",
- "networkDiscoveryMicroService.host=localhost",
- "networkDiscoveryMicroService.responseTimeOutInMilliseconds=1000" })
-public class NetworkDiscoveryRspInfoTest {
- NetworkDiscoveryRspInfo networkDiscoveryRspInfo = new NetworkDiscoveryRspInfo();
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGetRequestId() throws Exception {
- String requestId = "2123";
- networkDiscoveryRspInfo.setRequestId(requestId);
- assertEquals(requestId, networkDiscoveryRspInfo.getRequestId());
- }
-
- @Test
- public void testGetResourceType() throws Exception {
- String resourceType = "vserver";
- networkDiscoveryRspInfo.setResourceType(resourceType);
- assertEquals(resourceType, networkDiscoveryRspInfo.getResourceType());
- }
-
- @Test
- public void testGetResourceId() throws Exception {
- String resourceId = "2123";
- networkDiscoveryRspInfo.setResourceId(resourceId);
- assertEquals(resourceId, networkDiscoveryRspInfo.getResourceId());
- }
-
- @Test
- public void testGetLatchSignal() throws Exception {
- CountDownLatch latchSignal = new CountDownLatch(5);
- networkDiscoveryRspInfo.setLatchSignal(latchSignal);
- assertEquals(latchSignal, networkDiscoveryRspInfo.getLatchSignal());
- }
-
- @Test
- public void testGetNetworkDiscoveryNotificationList() throws Exception {
- NetworkDiscoveryNotification tmpNof = new NetworkDiscoveryNotification();
- List<NetworkDiscoveryNotification> myList = Arrays.asList(tmpNof);
-
- networkDiscoveryRspInfo.setNetworkDiscoveryNotificationList(myList);
- networkDiscoveryRspInfo.toString();
- assertEquals(myList, networkDiscoveryRspInfo.getNetworkDiscoveryNotificationList());
- }
-
- @Test
- public void testGetRelatedRequestIdList() throws Exception {
- List<String> myList = Arrays.asList("myTest123");
-
- networkDiscoveryRspInfo.setRelatedRequestIdList(myList);
- assertEquals(myList, networkDiscoveryRspInfo.getRelatedRequestIdList());
- }
-}
diff --git a/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/jolt/TransformationTest.java b/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/jolt/TransformationTest.java
index 7518591..29a4a6f 100644
--- a/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/jolt/TransformationTest.java
+++ b/src/test/java/org/onap/pomba/contextbuilder/networkdiscovery/test/jolt/TransformationTest.java
@@ -28,10 +28,12 @@ import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.onap.pomba.contextbuilder.networkdiscovery.model.NdQuery;
+import org.onap.pomba.common.datatypes.ModelContext;
+import org.onap.pomba.contextbuilder.networkdiscovery.model.NdResources;
public class TransformationTest {
+ private static final String CONFIG_JOLT_DIRECTORY = "config/jolt/";
private static final String TEST_RESOURCES = "src/test/resources/jolt/";
@Rule
@@ -39,26 +41,58 @@ public class TransformationTest {
@Test
- public void testTransformNdQuery() {
+ public void testTransformNdResources() {
- Object sourceObject = JsonUtils.filepathToObject(TEST_RESOURCES + "serviceDecompToNdQuery-input.json");
+ Object sourceObject = JsonUtils.filepathToObject(TEST_RESOURCES + "/serviceDecompResponse.json");
Object sourceObject1 = JsonUtils.jsonToObject(JsonUtils.toJsonString(sourceObject));
- List<Object> chainrSpecJSON = JsonUtils.filepathToList("config/ndQuery.spec");
- Chainr chainr = Chainr.fromSpec(chainrSpecJSON);
+ List<Object> chainrSpecJson = JsonUtils.filepathToList(CONFIG_JOLT_DIRECTORY + "sdToNdResourcesSpec.json");
+ Chainr chainr = Chainr.fromSpec(chainrSpecJson);
+ Object output = chainr.transform(sourceObject1);
+
+ String resultJson = JsonUtils.toJsonString(output);
+
+ System.err.println(resultJson);
+
+ // read the result into the NqQuery class:
+ Gson gson = new Gson();
+ NdResources ndQuery = gson.fromJson(resultJson, NdResources.class);
+
+ // convert ndQuery back to json:
+ String ndQueryToJson = gson.toJson(ndQuery);
+
+
+
+ // Compare with expected output:
+ Object expectedObject = JsonUtils.filepathToObject(TEST_RESOURCES + "serviceDecompToNdResources-expected.json");
+
+ Assert.assertEquals("Json transformation result does not match expected content",
+ JsonUtils.toPrettyJsonString(expectedObject),
+ JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(ndQueryToJson)));
+
+ }
+
+ @Test
+ public void testTransformModelContext() {
+
+ Object sourceObject = JsonUtils.filepathToObject(TEST_RESOURCES + "serviceDecompResponse.json");
+ Object sourceObject1 = JsonUtils.jsonToObject(JsonUtils.toJsonString(sourceObject));
+
+ List<Object> chainrSpecJson = JsonUtils.filepathToList(CONFIG_JOLT_DIRECTORY + "sdToModelContextSpec.json");
+ Chainr chainr = Chainr.fromSpec(chainrSpecJson);
Object output = chainr.transform(sourceObject1);
String resultJson = JsonUtils.toJsonString(output);
// read the result into the NqQuery class:
Gson gson = new Gson();
- NdQuery ndQuery = gson.fromJson(resultJson, NdQuery.class);
+ ModelContext ndQuery = gson.fromJson(resultJson, ModelContext.class);
// convert ndQuery back to json:
String ndQueryToJson = gson.toJson(ndQuery);
// Compare with expected output:
- Object expectedObject = JsonUtils.filepathToObject(TEST_RESOURCES + "serviceDecompToNdQuery-expected.json");
+ Object expectedObject = JsonUtils.filepathToObject(TEST_RESOURCES + "serviceDecompToModelContext-expected.json");
Assert.assertEquals("Json transformation result does not match expected content",
JsonUtils.toPrettyJsonString(expectedObject),
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 024f21a..c7475b0 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
@@ -24,15 +24,13 @@ import static org.mockito.Mockito.mock;
import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.github.tomakehurst.wiremock.matching.UrlPattern;
+import com.google.gson.Gson;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Base64;
-import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
@@ -44,11 +42,8 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.pomba.common.datatypes.DataQuality;
+import org.onap.pomba.common.datatypes.ModelContext;
import org.onap.pomba.contextbuilder.networkdiscovery.service.rs.RestService;
-import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Attribute;
-import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.NetworkDiscoveryNotification;
-import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@@ -75,10 +70,8 @@ public class NetworkDiscoveryContextBuilderTest {
private String partnerName = "POMBA";
private String transactionId = UUID.randomUUID().toString();
private String serviceInstanceId = "c6456519-6acf-4adb-997c-3c363dd4caaf";
- private String requestId = "2131__1";
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
- NetworkDiscoveryNotification networkDiscoveryNotification = simulateNetworkDiscoveryNotification();
@Autowired
Environment environment;
@@ -135,8 +128,8 @@ public class NetworkDiscoveryContextBuilderTest {
public void testVerifyServiceDecomposition() throws Exception {
String urlStr = "/service-decomposition/service/context?serviceInstanceId=" + serviceInstanceId;
- addResponse(urlStr, "junit/SD_response.json", serviceDecompositionRule);
- addResponseAny("junit/networkDiscoveryResponse-1.json", networkDiscoveryMicroServiceRule);
+ addResponse(urlStr, "junit/serviceDecompositionResponse-1.json", serviceDecompositionRule);
+ addResponseAny("junit/networkDiscoveryResponseVserver-1.json", networkDiscoveryMicroServiceRule);
Response response = this.restService.getContext(httpServletRequest, authorization, partnerName, transactionId,
null, null, serviceInstanceId, null, null);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
@@ -146,20 +139,73 @@ public class NetworkDiscoveryContextBuilderTest {
public void testVerifyGetContext() throws Exception {
String serviceDecompUrl = "/service-decomposition/service/context?serviceInstanceId=" + serviceInstanceId;
- addResponse(serviceDecompUrl, "junit/serviceDecomposition-1.json", serviceDecompositionRule);
- addResponseAny("junit/networkDiscoveryResponse-1.json", networkDiscoveryMicroServiceRule);
+ addResponse(serviceDecompUrl, "junit/serviceDecompositionResponse-1.json", serviceDecompositionRule);
+
+ String vserverPayload = readFully(
+ ClassLoader.getSystemResourceAsStream("junit/networkDiscoveryResponseVserver-1.json"));
+ networkDiscoveryMicroServiceRule.stubFor(WireMock
+ .any(WireMock.urlPathEqualTo("/network-discovery/v1/network/resource"))
+ .withQueryParam("resourceType", WireMock.equalTo("vserver")).willReturn(okJson(vserverPayload)));
+
+ String l3networkPayload = readFully(
+ ClassLoader.getSystemResourceAsStream("junit/networkDiscoveryResponseL3Network.json"));
+ networkDiscoveryMicroServiceRule.stubFor(WireMock
+ .any(WireMock.urlPathEqualTo("/network-discovery/v1/network/resource"))
+ .withQueryParam("resourceType", WireMock.equalTo("l3-network")).willReturn(okJson(l3networkPayload)));
Response response = this.restService.getContext(httpServletRequest, authorization, partnerName, transactionId,
null, null, serviceInstanceId, null, null);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
+
+ System.out.println(response.getEntity());
+
+ Gson gson = new Gson();
+ ModelContext modelContext = gson.fromJson((String) response.getEntity(), ModelContext.class);
+ assertTrue(modelContext.getVnfs().size() > 0);
+ assertTrue(modelContext.getVnfs().get(0).getVfModules().size() > 0);
+ assertTrue(modelContext.getVnfs().get(0).getVfModules().get(0).getVms().size() > 0);
+
+ }
+
+ @Test
+ public void testVerifyGetContextNdResourceNotFound() throws Exception {
+
+ String serviceDecompUrl = "/service-decomposition/service/context?serviceInstanceId=" + serviceInstanceId;
+ addResponse(serviceDecompUrl, "junit/serviceDecompositionResponse-1.json", serviceDecompositionRule);
+ UrlPattern testPath = WireMock.anyUrl();
+ networkDiscoveryMicroServiceRule.stubFor(get(testPath).willReturn(WireMock.notFound()));
+
+ Response response = this.restService.getContext(httpServletRequest, authorization, partnerName, transactionId,
+ null, null, serviceInstanceId, null, null);
+
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+
+ Gson gson = new Gson();
+ ModelContext modelContext = gson.fromJson((String)response.getEntity(), ModelContext.class);
+ assertTrue(modelContext.getVnfs().size() > 0);
+ assertTrue(modelContext.getVnfs().get(0).getVfModules().size() > 0);
+ assertTrue(modelContext.getVnfs().get(0).getVfModules().get(0).getVms().size() > 0);
+
+ }
+
+ @Test
+ public void testVerifyGetContextSdResoureNofFound() throws Exception {
+
+ UrlPattern testPath = WireMock.anyUrl();
+ serviceDecompositionRule.stubFor(get(testPath).willReturn(WireMock.notFound()));
+
+ Response response = this.restService.getContext(httpServletRequest, authorization, partnerName, transactionId,
+ null, null, serviceInstanceId, null, null);
+
+ assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
@Test
public void testVerifyNoPartnerNameWithFromAppId() throws Exception {
String serviceDecompUrl = "/service-decomposition/service/context?serviceInstanceId=" + serviceInstanceId;
- addResponse(serviceDecompUrl, "junit/serviceDecomposition-1.json", serviceDecompositionRule);
- addResponseAny("junit/networkDiscoveryResponse-1.json", networkDiscoveryMicroServiceRule);
+ addResponse(serviceDecompUrl, "junit/serviceDecompositionResponse-1.json", serviceDecompositionRule);
+ addResponseAny("junit/networkDiscoveryResponseVserver-1.json", networkDiscoveryMicroServiceRule);
Response response = this.restService.getContext(httpServletRequest, authorization, null, transactionId,
partnerName, null, serviceInstanceId, null, null);
@@ -169,8 +215,8 @@ public class NetworkDiscoveryContextBuilderTest {
@Test
public void testVerifyNoRequestIdNoTransactionId() throws Exception {
String serviceDecompUrl = "/service-decomposition/service/context?serviceInstanceId=" + serviceInstanceId;
- addResponse(serviceDecompUrl, "junit/serviceDecomposition-1.json", serviceDecompositionRule);
- addResponseAny("junit/networkDiscoveryResponse-1.json", networkDiscoveryMicroServiceRule);
+ addResponse(serviceDecompUrl, "junit/serviceDecompositionResponse-1.json", serviceDecompositionRule);
+ addResponseAny("junit/networkDiscoveryResponseVserver-1.json", networkDiscoveryMicroServiceRule);
Response response = this.restService.getContext(httpServletRequest, authorization, partnerName, null, null,
null, serviceInstanceId, null, null);
@@ -180,8 +226,8 @@ public class NetworkDiscoveryContextBuilderTest {
@Test
public void testVerifyNoPartnerNameNoFromAppId() throws Exception {
String serviceDecompUrl = "/service-decomposition/service/context?serviceInstanceId=" + serviceInstanceId;
- addResponse(serviceDecompUrl, "junit/serviceDecomposition-1.json", serviceDecompositionRule);
- addResponseAny("junit/networkDiscoveryResponse-1.json", networkDiscoveryMicroServiceRule);
+ addResponse(serviceDecompUrl, "junit/serviceDecompositionResponse-1.json", serviceDecompositionRule);
+ addResponseAny("junit/networkDiscoveryResponseVserver-1.json", networkDiscoveryMicroServiceRule);
Response response = this.restService.getContext(httpServletRequest, authorization, null, transactionId, null,
null, serviceInstanceId, null, null);
@@ -191,8 +237,8 @@ public class NetworkDiscoveryContextBuilderTest {
@Test
public void testVerifyNoRequestIdWithTransactionId() throws Exception {
String serviceDecompUrl = "/service-decomposition/service/context?serviceInstanceId=" + serviceInstanceId;
- addResponse(serviceDecompUrl, "junit/serviceDecomposition-1.json", serviceDecompositionRule);
- addResponseAny("junit/networkDiscoveryResponse-1.json", networkDiscoveryMicroServiceRule);
+ addResponse(serviceDecompUrl, "junit/serviceDecompositionResponse-1.json", serviceDecompositionRule);
+ addResponseAny("junit/networkDiscoveryResponseVserver-1.json", networkDiscoveryMicroServiceRule);
Response response = this.restService.getContext(httpServletRequest, authorization, partnerName, null, null,
transactionId, serviceInstanceId, null, null);
@@ -206,8 +252,8 @@ public class NetworkDiscoveryContextBuilderTest {
private void addResponseAny(String classpathResource, WireMockRule thisMock) throws IOException {
String payload = readFully(ClassLoader.getSystemResourceAsStream(classpathResource));
- UrlPattern tPath = WireMock.anyUrl();
- thisMock.stubFor(get(tPath).willReturn(okJson(payload)));
+ UrlPattern testPath = WireMock.anyUrl();
+ thisMock.stubFor(get(testPath).willReturn(okJson(payload)));
}
private String readFully(InputStream in) throws IOException {
@@ -221,75 +267,4 @@ public class NetworkDiscoveryContextBuilderTest {
}
return content.toString();
}
-
- private NetworkDiscoveryNotification simulateNetworkDiscoveryNotification() {
- Resource myResource = new Resource();
- myResource.setId("25fb07ab-0478-465e-a021-6384ac299671");
- myResource.setType("vserver");
- DataQuality dataQuality = new DataQuality();
- dataQuality.setStatus(DataQuality.Status.ok);
- myResource.setDataQuality(dataQuality);
- Attribute attribute = new Attribute();
- attribute.setName("vserver-id");
- attribute.setValue("25fb07ab-0478-465e-a021-6384ac299671");
- attribute.setDataQuality(dataQuality);
- List<Attribute> attributeList = new ArrayList<>();
- attributeList.add(attribute);
-
- attribute.setName("power-state");
- attribute.setValue("1");
- attribute.setDataQuality(dataQuality);
- attributeList.add(attribute);
-
- attribute.setName("vm-state");
- attribute.setValue("active");
- attribute.setDataQuality(dataQuality);
- attributeList.add(attribute);
-
- attribute.setName("status");
- attribute.setValue("ACTIVE");
- attribute.setDataQuality(dataQuality);
- attributeList.add(attribute);
-
- attribute.setName("host-status");
- attribute.setValue("UNKNOWN");
- attribute.setDataQuality(dataQuality);
- attributeList.add(attribute);
-
- attribute.setName("updated");
- attribute.setValue("2017-11-20T04:26:13Z");
- attribute.setDataQuality(dataQuality);
- attributeList.add(attribute);
-
- attribute.setName("disk-allocation-gb");
- attribute.setValue(".010");
- attribute.setDataQuality(dataQuality);
- attributeList.add(attribute);
-
- attribute.setName("memory-usage-mb");
- attribute.setValue("null");
- attribute.setDataQuality(dataQuality);
- attributeList.add(attribute);
-
- attribute.setName("cpu-util-percent");
- attribute.setValue(".048");
- attribute.setDataQuality(dataQuality);
- attributeList.add(attribute);
-
- attribute.setName(".048");
- attribute.setValue("2018-07-26 01:37:07 +0000");
- attribute.setDataQuality(dataQuality);
- attributeList.add(attribute);
- myResource.setAttributeList(attributeList);
-
- NetworkDiscoveryNotification notification = new NetworkDiscoveryNotification();
- notification.setResources(Arrays.asList(myResource));
- notification.setAckFinalIndicator(true);
- notification.setCode(200);
- notification.setRequestId(requestId);
- notification.setMessage("OK");
-
- return notification;
- }
-
}
diff --git a/src/test/resources/jolt/serviceDecompResponse.json b/src/test/resources/jolt/serviceDecompResponse.json
new file mode 100644
index 0000000..2e2f38c
--- /dev/null
+++ b/src/test/resources/jolt/serviceDecompResponse.json
@@ -0,0 +1,211 @@
+{
+ "model-version-id": "e2d52f32-a952-46f5-800c-c250903625d6",
+ "service-instance-id": "PombaDemoCust_001-SerivceInst-001",
+ "resource-version": "1545324562797",
+ "generic-vnfs": [
+ {
+ "nf-role": "",
+ "service-id": "8ea56b0d-459d-4668-b363-c9567432d8b7",
+ "vnf-id": "PombaDemoCust_001-VNF-id-001",
+ "nf-type": "",
+ "l3-networks": [
+ {
+ "network-role": "",
+ "network-technology": "",
+ "network-id": "2ea02809-7279-4b5e-931a-62b231615497",
+ "is-external-network": false,
+ "is-bound-to-vpn": false,
+ "is-provider-network": false,
+ "network-type": "",
+ "model-version-id": "pomba-demo-sdc-model-001-version001",
+ "resource-version": "1547484061985",
+ "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
+ "network-name": "NET_1105",
+ "is-shared-network": true,
+ "model-invariant-id": "pomba-demo-sdc-model-001"
+ },
+ {
+ "network-role": "",
+ "network-technology": "",
+ "network-id": "01e8d84a-17a6-47b5-a167-6a45d1d56603",
+ "is-external-network": false,
+ "is-bound-to-vpn": false,
+ "is-provider-network": false,
+ "network-type": "",
+ "model-version-id": "pomba-demo-sdc-model-001-version001",
+ "resource-version": "1547484429696",
+ "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
+ "network-name": "NET_1106",
+ "is-shared-network": true,
+ "model-invariant-id": "pomba-demo-sdc-model-001"
+ }
+ ],
+ "prov-status": "PREPROV",
+ "vnf-type": "vFW-vSINK-service/vFWvSINK 0",
+ "orchestration-status": "Created",
+ "nf-naming-code": "",
+ "in-maint": false,
+ "nf-function": "",
+ "model-version-id": "pomba-demo-sdc-model-001-version001",
+ "vservers": [
+ {
+ "in-maint": false,
+ "resource-version": "1545323228761",
+ "vserver-name": "Firewall-001",
+ "prov-status": "ACTIVE",
+ "vserver-id": "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
+ "vserver-name2": "Firewall-001",
+ "vserver-selflink": "http://10.12.25.2:8774/v2.1/a6a609e3-967a-48bd-8ce5-41c7ff5c19b9/servers/a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
+ "is-closed-loop-disabled": false
+ }
+ ],
+ "resource-version": "1547828735448",
+ "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
+ "vf-modules": {
+ "vf-module": [
+ {
+ "vf-module-name": "PombaDemoCust_001-VNF-id-001-VfModule001-name",
+ "model-version-id": "pomba-demo-sdc-model-001-version001",
+ "heat-stack-id": "HeatStackId-001",
+ "resource-version": "1547828735835",
+ "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
+ "is-base-vf-module": true,
+ "vf-module-id": "PombaDemoCust_001-VNF-id-001-VfModule001",
+ "module-index": 0,
+ "model-invariant-id": "pomba-demo-sdc-model-001",
+ "orchestration-status": "Active",
+ "automated-assignment": true
+ }
+ ]
+ },
+ "model-invariant-id": "pomba-demo-sdc-model-001",
+ "vnf-name": "Firewall-1",
+ "is-closed-loop-disabled": false
+ },
+ {
+ "nf-role": "",
+ "service-id": "8ea56b0d-459d-4668-b363-c9567432d8b7",
+ "vnf-id": "PombaDemoCust_001-VNF-id-001-2",
+ "nf-type": "",
+ "l3-networks": [
+ {
+ "network-role": "",
+ "network-technology": "",
+ "network-id": "2ea02809-7279-4b5e-931a-62b231615497-1",
+ "is-external-network": false,
+ "is-bound-to-vpn": false,
+ "is-provider-network": false,
+ "network-type": "",
+ "model-version-id": "pomba-demo-sdc-model-001-version001",
+ "resource-version": "1547484061985",
+ "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
+ "network-name": "NET_1105",
+ "is-shared-network": true,
+ "model-invariant-id": "pomba-demo-sdc-model-001"
+ },
+ {
+ "network-role": "",
+ "network-technology": "",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-data": [
+ {
+ "relationship-value": "PombaDemoCust_001",
+ "relationship-key": "customer.global-customer-id"
+ },
+ {
+ "relationship-value": "SDN-ETHERNET-INTERNET",
+ "relationship-key": "service-subscription.service-type"
+ },
+ {
+ "relationship-value": "PombaDemoCust_001-SerivceInst-001",
+ "relationship-key": "service-instance.service-instance-id"
+ }
+ ],
+ "related-link": "/aai/v13/business/customers/customer/PombaDemoCust_001/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/PombaDemoCust_001-SerivceInst-001",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name"
+ }
+ ]
+ },
+ {
+ "related-to": "generic-vnf",
+ "relationship-data": [
+ {
+ "relationship-value": "PombaDemoCust_001-VNF-id-001",
+ "relationship-key": "generic-vnf.vnf-id"
+ }
+ ],
+ "related-link": "/aai/v13/network/generic-vnfs/generic-vnf/PombaDemoCust_001-VNF-id-001",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "Firewall-1"
+ }
+ ]
+ },
+ {
+ "related-to": "generic-vnf",
+ "relationship-data": [
+ {
+ "relationship-value": "PombaDemoCust_001-VNF-id-001-2",
+ "relationship-key": "generic-vnf.vnf-id"
+ }
+ ],
+ "related-link": "/aai/v13/network/generic-vnfs/generic-vnf/PombaDemoCust_001-VNF-id-001-2",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "Firewall-2"
+ }
+ ]
+ }
+ ]
+ },
+ "network-id": "01e8d84a-17a6-47b5-a167-6a45d1d56603-1",
+ "is-external-network": false,
+ "is-bound-to-vpn": false,
+ "is-provider-network": false,
+ "network-type": "",
+ "model-version-id": "pomba-demo-sdc-model-001-version001",
+ "resource-version": "1547484429696",
+ "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
+ "network-name": "NET_1106",
+ "is-shared-network": true,
+ "model-invariant-id": "pomba-demo-sdc-model-001"
+ }
+ ],
+ "prov-status": "PREPROV",
+ "vnf-type": "vFW-vSINK-service/vFWvSINK 0",
+ "orchestration-status": "Created",
+ "nf-naming-code": "",
+ "in-maint": false,
+ "nf-function": "",
+ "model-version-id": "pomba-demo-sdc-model-001-version001",
+ "vservers": [
+ {
+ "in-maint": true,
+ "resource-version": "1547822239190",
+ "vserver-name": "Firewall-001-2",
+ "prov-status": "UNKNOWN",
+ "vserver-id": "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9-2",
+ "vserver-name2": "Firewall-001-2",
+ "vserver-selflink": "http://10.12.25.2:8774/v2.1/a6a609e3-967a-48bd-8ce5-41c7ff5c19b9/servers/a6a609e3-967a-48bd-8ce5-41c7ff5c19b9-2",
+ "is-closed-loop-disabled": false
+ }
+ ],
+ "resource-version": "1547822479098",
+ "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
+ "model-invariant-id": "pomba-demo-sdc-model-001",
+ "vnf-name": "Firewall-2",
+ "is-closed-loop-disabled": false
+ }
+ ],
+ "model-invariant-id": "59dd4d63-8f21-406c-98c0-3b057bb86820"
+} \ No newline at end of file
diff --git a/src/test/resources/jolt/serviceDecompToModelContext-expected.json b/src/test/resources/jolt/serviceDecompToModelContext-expected.json
new file mode 100644
index 0000000..31f1318
--- /dev/null
+++ b/src/test/resources/jolt/serviceDecompToModelContext-expected.json
@@ -0,0 +1,108 @@
+{
+ "service" : {
+ "uuid" : "PombaDemoCust_001-SerivceInst-001",
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ]
+ },
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "vnfList" : [ {
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "vfModuleList" : [ {
+ "maxInstances" : 0,
+ "minInstances" : 0,
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "vmList" : [ {
+ "uuid" : "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "pServer" : {
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "pInterfaceList" : [ ],
+ "logicalLinkList" : [ ]
+ },
+ "lInterfaceList" : [ ]
+ } ],
+ "networkList" : [ {
+ "uuid" : "2ea02809-7279-4b5e-931a-62b231615497",
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "networkPolicyList" : [ ]
+ }, {
+ "uuid" : "01e8d84a-17a6-47b5-a167-6a45d1d56603",
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "networkPolicyList" : [ ]
+ } ]
+ } ],
+ "vnfcList" : [ ],
+ "networkList" : [ ]
+ }, {
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "vfModuleList" : [ {
+ "maxInstances" : 0,
+ "minInstances" : 0,
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "vmList" : [ {
+ "uuid" : "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9-2",
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "pServer" : {
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "pInterfaceList" : [ ],
+ "logicalLinkList" : [ ]
+ },
+ "lInterfaceList" : [ ]
+ } ],
+ "networkList" : [ {
+ "uuid" : "2ea02809-7279-4b5e-931a-62b231615497-1",
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "networkPolicyList" : [ ]
+ }, {
+ "uuid" : "01e8d84a-17a6-47b5-a167-6a45d1d56603-1",
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ ],
+ "networkPolicyList" : [ ]
+ } ]
+ } ],
+ "vnfcList" : [ ],
+ "networkList" : [ ]
+ } ],
+ "pnfList" : [ ],
+ "networkList" : [ ]
+} \ No newline at end of file
diff --git a/src/test/resources/jolt/serviceDecompToNdQuery-expected.json b/src/test/resources/jolt/serviceDecompToNdQuery-expected.json
deleted file mode 100644
index cfc5a5b..0000000
--- a/src/test/resources/jolt/serviceDecompToNdQuery-expected.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "ndQuery": [
- {
- "ndResourcesList": [
- {
- "ndResources": [
- {
- "resourceId": "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
- "resourceType": "vserver"
- }
- ]
- }
- ]
- }
- ]
-} \ No newline at end of file
diff --git a/src/test/resources/jolt/serviceDecompToNdQuery-input.json b/src/test/resources/jolt/serviceDecompToNdQuery-input.json
deleted file mode 100644
index 2954141..0000000
--- a/src/test/resources/jolt/serviceDecompToNdQuery-input.json
+++ /dev/null
@@ -1,260 +0,0 @@
-{
- "relationship-list": {
- "relationship": [
- {
- "related-to": "generic-vnf",
- "relationship-data": [
- {
- "relationship-value": "PombaDemoCust_001-VNF-id-001",
- "relationship-key": "generic-vnf.vnf-id"
- }
- ],
- "related-link": "/aai/v13/network/generic-vnfs/generic-vnf/PombaDemoCust_001-VNF-id-001",
- "relationship-label": "org.onap.relationships.inventory.ComposedOf",
- "related-to-property": [
- {
- "property-key": "generic-vnf.vnf-name",
- "property-value": "Firewall-1"
- }
- ]
- },
- {
- "related-to": "l3-network",
- "relationship-data": [
- {
- "relationship-value": "2ea02809-7279-4b5e-931a-62b231615497",
- "relationship-key": "l3-network.network-id"
- }
- ],
- "related-link": "/aai/v13/network/l3-networks/l3-network/2ea02809-7279-4b5e-931a-62b231615497",
- "relationship-label": "org.onap.relationships.inventory.ComposedOf",
- "related-to-property": [
- {
- "property-key": "l3-network.network-name",
- "property-value": "NET_1105"
- }
- ]
- },
- {
- "related-to": "pnf",
- "relationship-data": [
- {
- "relationship-value": "PombaDemoCust_001-PNF2-id-001",
- "relationship-key": "pnf.pnf-name"
- }
- ],
- "related-link": "/aai/v13/network/pnfs/pnf/PombaDemoCust_001-PNF2-id-001",
- "relationship-label": "org.onap.relationships.inventory.ComposedOf"
- },
- {
- "related-to": "pnf",
- "relationship-data": [
- {
- "relationship-value": "PombaDemoCust_001-PNF-id-001",
- "relationship-key": "pnf.pnf-name"
- }
- ],
- "related-link": "/aai/v13/network/pnfs/pnf/PombaDemoCust_001-PNF-id-001",
- "relationship-label": "org.onap.relationships.inventory.ComposedOf"
- },
- {
- "related-to": "l3-network",
- "relationship-data": [
- {
- "relationship-value": "01e8d84a-17a6-47b5-a167-6a45d1d56603",
- "relationship-key": "l3-network.network-id"
- }
- ],
- "related-link": "/aai/v13/network/l3-networks/l3-network/01e8d84a-17a6-47b5-a167-6a45d1d56603",
- "relationship-label": "org.onap.relationships.inventory.ComposedOf",
- "related-to-property": [
- {
- "property-key": "l3-network.network-name",
- "property-value": "NET_1106"
- }
- ]
- }
- ]
- },
- "model-version-id": "e2d52f32-a952-46f5-800c-c250903625d6",
- "service-instance-id": "PombaDemoCust_001-SerivceInst-001",
- "resource-version": "1545324562797",
- "generic-vnfs": [
- {
- "nf-role": "",
- "service-id": "8ea56b0d-459d-4668-b363-c9567432d8b7",
- "relationship-list": {
- "relationship": [
- {
- "related-to": "service-instance",
- "relationship-data": [
- {
- "relationship-value": "PombaDemoCust_001",
- "relationship-key": "customer.global-customer-id"
- },
- {
- "relationship-value": "SDN-ETHERNET-INTERNET",
- "relationship-key": "service-subscription.service-type"
- },
- {
- "relationship-value": "PombaDemoCust_001-SerivceInst-001",
- "relationship-key": "service-instance.service-instance-id"
- }
- ],
- "related-link": "/aai/v13/business/customers/customer/PombaDemoCust_001/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/PombaDemoCust_001-SerivceInst-001",
- "relationship-label": "org.onap.relationships.inventory.ComposedOf",
- "related-to-property": [
- {
- "property-key": "service-instance.service-instance-name"
- }
- ]
- },
- {
- "related-to": "vserver",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "PombaRegion001",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "PombaRegion001-tenant-001",
- "relationship-key": "tenant.tenant-id"
- },
- {
- "relationship-value": "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
- "relationship-key": "vserver.vserver-id"
- }
- ],
- "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/PombaRegion001/tenants/tenant/PombaRegion001-tenant-001/vservers/vserver/a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
- "relationship-label": "tosca.relationships.HostedOn",
- "related-to-property": [
- {
- "property-key": "vserver.vserver-name",
- "property-value": "Firewall-001"
- }
- ]
- },
- {
- "related-to": "pserver",
- "relationship-data": [
- {
- "relationship-value": "PombaDemoCust_001-pserver-id-001",
- "relationship-key": "pserver.hostname"
- }
- ],
- "related-link": "/aai/v13/cloud-infrastructure/pservers/pserver/PombaDemoCust_001-pserver-id-001",
- "relationship-label": "tosca.relationships.HostedOn",
- "related-to-property": [
- {
- "property-key": "pserver.pserver-name2",
- "property-value": "PombaDemoCust_001-pserver-id-001-name2"
- }
- ]
- }
- ]
- },
- "vnf-id": "PombaDemoCust_001-VNF-id-001",
- "nf-type": "",
- "prov-status": "PREPROV",
- "vnf-type": "vFW-vSINK-service/vFWvSINK 0",
- "orchestration-status": "Created",
- "nf-naming-code": "",
- "in-maint": false,
- "nf-function": "",
- "model-version-id": "e2d52f32-a952-46f5-800c-c250903625d6",
- "vservers": [
- {
- "relationship-list": {
- "relationship": [
- {
- "related-to": "generic-vnf",
- "relationship-data": [
- {
- "relationship-value": "PombaDemoCust_001-VNF-id-001",
- "relationship-key": "generic-vnf.vnf-id"
- }
- ],
- "related-link": "/aai/v13/network/generic-vnfs/generic-vnf/PombaDemoCust_001-VNF-id-001",
- "relationship-label": "tosca.relationships.HostedOn",
- "related-to-property": [
- {
- "property-key": "generic-vnf.vnf-name",
- "property-value": "Firewall-1"
- }
- ]
- },
- {
- "related-to": "flavor",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "PombaRegion001",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "PombaRegion001-flavor001",
- "relationship-key": "flavor.flavor-id"
- }
- ],
- "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/PombaRegion001/flavors/flavor/PombaRegion001-flavor001",
- "relationship-label": "org.onap.relationships.inventory.Uses",
- "related-to-property": [
- {
- "property-key": "flavor.flavor-name",
- "property-value": "m1.medium"
- }
- ]
- },
- {
- "related-to": "image",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "PombaRegion001",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "PombaRegion001-image001",
- "relationship-key": "image.image-id"
- }
- ],
- "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/PombaRegion001/images/image/PombaRegion001-image001",
- "relationship-label": "org.onap.relationships.inventory.Uses",
- "related-to-property": [
- {
- "property-key": "image.image-name",
- "property-value": "unknown"
- }
- ]
- }
- ]
- },
- "in-maint": false,
- "resource-version": "1545323228761",
- "vserver-name": "Firewall-001",
- "prov-status": "ACTIVE",
- "vserver-id": "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
- "vserver-name2": "Firewall-001",
- "vserver-selflink": "http://10.12.25.2:8774/v2.1/a6a609e3-967a-48bd-8ce5-41c7ff5c19b9/servers/a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
- "is-closed-loop-disabled": false
- }
- ],
- "resource-version": "1545324724996",
- "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
- "model-invariant-id": "59dd4d63-8f21-406c-98c0-3b057bb86820",
- "vnf-name": "Firewall-1",
- "is-closed-loop-disabled": false
- }
- ],
- "model-invariant-id": "59dd4d63-8f21-406c-98c0-3b057bb86820"
-} \ No newline at end of file
diff --git a/src/test/resources/jolt/serviceDecompToNdResources-expected.json b/src/test/resources/jolt/serviceDecompToNdResources-expected.json
new file mode 100644
index 0000000..1351350
--- /dev/null
+++ b/src/test/resources/jolt/serviceDecompToNdResources-expected.json
@@ -0,0 +1,21 @@
+{
+ "ndResources" : [ {
+ "resourceId" : "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9",
+ "resourceType" : "vserver"
+ }, {
+ "resourceId" : "2ea02809-7279-4b5e-931a-62b231615497",
+ "resourceType" : "l3-network"
+ }, {
+ "resourceId" : "01e8d84a-17a6-47b5-a167-6a45d1d56603",
+ "resourceType" : "l3-network"
+ }, {
+ "resourceId" : "a6a609e3-967a-48bd-8ce5-41c7ff5c19b9-2",
+ "resourceType" : "vserver"
+ }, {
+ "resourceId" : "2ea02809-7279-4b5e-931a-62b231615497-1",
+ "resourceType" : "l3-network"
+ }, {
+ "resourceId" : "01e8d84a-17a6-47b5-a167-6a45d1d56603-1",
+ "resourceType" : "l3-network"
+ } ]
+} \ No newline at end of file
diff --git a/src/test/resources/junit/SD_response.json b/src/test/resources/junit/SD_response.json
deleted file mode 100644
index d4db960..0000000
--- a/src/test/resources/junit/SD_response.json
+++ /dev/null
@@ -1,557 +0,0 @@
-{
- "relationship-list": {
- "relationship": [
- {
- "related-to": "generic-vnf",
- "relationship-data": [
- {
- "relationship-value": "6700c313-fbb7-4cf9-ac70-0293ec56df68",
- "relationship-key": "generic-vnf.vnf-id"
- }
- ],
- "related-link": "/aai/v13/network/generic-vnfs/generic-vnf/6700c313-fbb7-4cf9-ac70-0293ec56df68",
- "related-to-property": [
- {
- "property-key": "generic-vnf.vnf-name",
- "property-value": "PacketGenerator-1"
- }
- ]
- },
- {
- "related-to": "generic-vnf",
- "relationship-data": [
- {
- "relationship-value": "6700c313-fbb7-4cf9-ac70-0293ec56df69",
- "relationship-key": "generic-vnf.vnf-id"
- }
- ],
- "related-link": "/aai/v13/network/generic-vnfs/generic-vnf/6700c313-fbb7-4cf9-ac70-0293ec56df69",
- "related-to-property": [
- {
- "property-key": "generic-vnf.vnf-name",
- "property-value": "PacketGenerator-2"
- }
- ]
- }
- ]
- },
- "model-version-id": "d3d6cf83-d03a-43cc-99ff-206d40bb9a72",
- "service-instance-id": "c6456519-6acf-4adb-997c-3c363dd4caaf",
- "resource-version": "1527637758480",
- "generic-vnfs": [
- {
- "nf-role": "",
- "service-id": "8ea56b0d-459d-4668-b363-c9567432d8b7",
- "relationship-list": {
- "relationship": [
- {
- "related-to": "service-instance",
- "relationship-data": [
- {
- "relationship-value": "Demonstration",
- "relationship-key": "customer.global-customer-id"
- },
- {
- "relationship-value": "vFWCL",
- "relationship-key": "service-subscription.service-type"
- },
- {
- "relationship-value": "c6456519-6acf-4adb-997c-3c363dd4caaf",
- "relationship-key": "service-instance.service-instance-id"
- }
- ],
- "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFWCL/service-instances/service-instance/c6456519-6acf-4adb-997c-3c363dd4caaf",
- "related-to-property": [
- {
- "property-key": "service-instance.service-instance-name",
- "property-value": "Firewall1"
- }
- ]
- },
- {
- "related-to": "l3-network",
- "relationship-data": [
- {
- "relationship-value": "HNP1d77c-1094-41ec-b7f3-94bb30951870",
- "relationship-key": "l3-network.network-id"
- }
- ],
- "related-link": "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951870",
- "relationship-label": "org.onap.relationships.inventory.Uses",
- "related-to-property": [
- {
- "property-key": "l3-network.network-name",
- "property-value": "HNPORTALOAM.OAM"
- }
- ]
- },
- {
- "related-to": "vserver",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "RegionOne",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "b49b830686654191bb1e952a74b014ad",
- "relationship-key": "tenant.tenant-id"
- },
- {
- "relationship-value": "25fb07ab-0478-465e-a021-6384ac299671",
- "relationship-key": "vserver.vserver-id"
- }
- ],
- "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b49b830686654191bb1e952a74b014ad/vservers/vserver/25fb07ab-0478-465e-a021-6384ac299671"
- },
- {
- "related-to": "vserver",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "RegionOne",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "b49b830686654191bb1e952a74b014ad",
- "relationship-key": "tenant.tenant-id"
- },
- {
- "relationship-value": "25fb07ab-0478-465e-a021-6384ac299672",
- "relationship-key": "vserver.vserver-id"
- }
- ],
- "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b49b830686654191bb1e952a74b014ad/vservers/vserver/25fb07ab-0478-465e-a021-6384ac299672"
- }
- ]
- },
- "vnf-id": "6700c313-fbb7-4cf9-ac70-0293ec56df68",
- "nf-type": "",
- "l3-networks": [
- {
- "network-role": "HNPORTALOAM.OAM",
- "network-technology": "ovs",
- "service-id": "V7611HNP-1222-48f1-8085-94aef0c6ef3d51870",
- "network-id": "HNP1d77c-1222-41ec-b7f3-94bb30951870",
- "neutron-network-id": "491c7cef-a3f4-4990-883e-b0af397466d0",
- "is-external-network": false,
- "is-bound-to-vpn": false,
- "is-provider-network": false,
- "network-type": "OVS_PROVIDER_VLAN",
- "orchestration-status": "active",
- "network-role-instance": 0,
- "resource-version": "1526558298075",
- "network-name": "HNPORTALOAM.OAM",
- "is-shared-network": false
- }
- ],
- "prov-status": "PREPROV",
- "vnf-type": "vFW-vSINK-service/vPKG 0",
- "orchestration-status": "Created",
- "nf-naming-code": "",
- "in-maint": false,
- "nf-function": "",
- "model-version-id": "a5565bf4-d55a-4964-8fbc-6a7674a2e676",
- "vservers": [
- {
- "relationship-list": {
- "relationship": [
- {
- "related-to": "generic-vnf",
- "relationship-data": [
- {
- "relationship-value": "8a9ddb25-2e79-449c-a40d-5011bac0da39",
- "relationship-key": "generic-vnf.vnf-id"
- }
- ],
- "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39",
- "related-to-property": [
- {
- "property-key": "generic-vnf.vnf-name",
- "property-value": "Firewall-1"
- }
- ]
- },
- {
- "related-to": "flavor",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "RegionOne",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "764efb04-5a46-4806-a766-2bdd24559f39",
- "relationship-key": "flavor.flavor-id"
- }
- ],
- "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/764efb04-5a46-4806-a766-2bdd24559f39",
- "related-to-property": [
- {
- "property-key": "flavor.flavor-name",
- "property-value": "m1.medium"
- }
- ]
- },
- {
- "related-to": "image",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "RegionOne",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "42fd42f8-cf81-4f4c-a552-d4b124f83b0b",
- "relationship-key": "image.image-id"
- }
- ],
- "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/42fd42f8-cf81-4f4c-a552-d4b124f83b0b",
- "related-to-property": [
- {
- "property-key": "image.image-name",
- "property-value": "unknown"
- }
- ]
- }
- ]
- },
- "in-maint": false,
- "resource-version": "1528481820321",
- "vserver-name": "Firewall-0",
- "prov-status": "ACTIVE",
- "vserver-id": "25fb07ab-0478-465e-a021-6384ac299671",
- "vserver-name2": "Firewall-0",
- "vserver-selflink": "http://10.12.25.2:8774/v2.1/b49b830686654191bb1e952a74b014ad/servers/25fb07ab-0478-465e-a021-6384ac299671",
- "is-closed-loop-disabled": false
- },
- {
- "relationship-list": {
- "relationship": [
- {
- "related-to": "generic-vnf",
- "relationship-data": [
- {
- "relationship-value": "8a9ddb25-2e79-449c-a40d-5011bac0da39",
- "relationship-key": "generic-vnf.vnf-id"
- }
- ],
- "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39",
- "related-to-property": [
- {
- "property-key": "generic-vnf.vnf-name",
- "property-value": "Firewall-1"
- }
- ]
- },
- {
- "related-to": "flavor",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "RegionOne",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "764efb04-5a46-4806-a766-2bdd24559f39",
- "relationship-key": "flavor.flavor-id"
- }
- ],
- "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/764efb04-5a46-4806-a766-2bdd24559f39",
- "related-to-property": [
- {
- "property-key": "flavor.flavor-name",
- "property-value": "m1.medium"
- }
- ]
- },
- {
- "related-to": "image",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "RegionOne",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "42fd42f8-cf81-4f4c-a552-d4b124f83b0b",
- "relationship-key": "image.image-id"
- }
- ],
- "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/42fd42f8-cf81-4f4c-a552-d4b124f83b0b",
- "related-to-property": [
- {
- "property-key": "image.image-name",
- "property-value": "unknown"
- }
- ]
- }
- ]
- },
- "in-maint": false,
- "resource-version": "1528481820321",
- "vserver-name": "Firewall-0",
- "prov-status": "ACTIVE",
- "vserver-id": "25fb07ab-0478-465e-a021-6384ac299672",
- "vserver-name2": "Firewall-0",
- "vserver-selflink": "http://10.12.25.2:8774/v2.1/b49b830686654191bb1e952a74b014ad/servers/25fb07ab-0478-465e-a021-6384ac299672",
- "is-closed-loop-disabled": false
- }
- ],
- "resource-version": "1527638176989",
- "model-customization-id": "4cc1e555-361f-4d69-ae21-9f371ea9f40c",
- "vf-modules": {
- "vf-module": [
- {
- "vf-module-name": "vPacketGen-VNF-1128-3",
- "model-version-id": "d6d4a002-a584-4640-bdce-a50e9bce552b",
- "heat-stack-id": "vPacketGen-VNF-1128-3/df34f5d6-ed39-4184-b785-51c37cfa8ac2",
- "resource-version": "1527641224058",
- "model-customization-id": "49c8f521-e5ee-4095-bb87-4090166e49ab",
- "is-base-vf-module": true,
- "vf-module-id": "0f792076-f5b3-4251-9fcc-c4d5afae0eb1",
- "module-index": 0,
- "model-invariant-id": "2a8844a8-f5f7-46dd-a732-472c6972a28e",
- "orchestration-status": "active"
- }
- ]
- },
- "vserver": [
- {
- "vserver-name": "Firewall-1",
- "vserver-id": "25fb07ab-0478-465e-a021-6384ac299671",
- "model-invariant-id": "0c5a20de-87ad-442c-9190-f38ab0a6bb7f"
- }
- ],
- "model-invariant-id": "99f1fd3f-845c-48f5-a0ba-11fbde6ae557",
- "vnf-name": "PacketGenerator-1",
- "is-closed-loop-disabled": false
- },
- {
- "nf-role": "",
- "service-id": "8ea56b0d-459d-4668-b363-c9567432d8b9",
- "relationship-list": {
- "relationship": [
- {
- "related-to": "service-instance",
- "relationship-data": [
- {
- "relationship-value": "Demonstration",
- "relationship-key": "customer.global-customer-id"
- },
- {
- "relationship-value": "vFWCL",
- "relationship-key": "service-subscription.service-type"
- },
- {
- "relationship-value": "c6456519-6acf-4adb-997c-3c363dd4caaf",
- "relationship-key": "service-instance.service-instance-id"
- }
- ],
- "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFWCL/service-instances/service-instance/c6456519-6acf-4adb-997c-3c363dd4caaf",
- "related-to-property": [
- {
- "property-key": "service-instance.service-instance-name",
- "property-value": "Firewall1"
- }
- ]
- },
- {
- "related-to": "l3-network",
- "relationship-data": [
- {
- "relationship-value": "HNP1d77c-1094-41ec-b7f3-94bb30951870",
- "relationship-key": "l3-network.network-id"
- }
- ],
- "related-link": "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951871",
- "relationship-label": "org.onap.relationships.inventory.Uses",
- "related-to-property": [
- {
- "property-key": "l3-network.network-name",
- "property-value": "HNPORTALOAM.OAM"
- }
- ]
- },
- {
- "related-to": "vserver",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "RegionOne",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "b49b830686654191bb1e952a74b014ad",
- "relationship-key": "tenant.tenant-id"
- },
- {
- "relationship-value": "25fb07ab-0478-465e-a021-6384ac299671",
- "relationship-key": "vserver.vserver-id"
- }
- ],
- "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74b"
- }
- ]
- },
- "vnf-id": "6700c313-fbb7-4cf9-ac70-0293ec56df69",
- "nf-type": "",
- "l3-networks": [
- {
- "network-role": "HNPORTALOAM.OAM",
- "network-technology": "ovs",
- "service-id": "V7611HNP-1222-48f1-8085-94aef0c6ef3d51870",
- "network-id": "HNP1d77c-1222-41ec-b7f3-94bb30951870",
- "neutron-network-id": "491c7cef-a3f4-4990-883e-b0af397466d0",
- "is-external-network": false,
- "is-bound-to-vpn": false,
- "is-provider-network": false,
- "network-type": "OVS_PROVIDER_VLAN",
- "orchestration-status": "active",
- "network-role-instance": 0,
- "resource-version": "1526558298075",
- "network-name": "HNPORTALOAM.OAM",
- "is-shared-network": false
- }
- ],
- "prov-status": "PREPROV",
- "vnf-type": "vFW-vSINK-service/vPKG 0",
- "orchestration-status": "Created",
- "nf-naming-code": "",
- "in-maint": false,
- "nf-function": "",
- "model-version-id": "a5565bf4-d55a-4964-8fbc-6a7674a2e676",
- "vservers": [
- {
- "relationship-list": {
- "relationship": [
- {
- "related-to": "generic-vnf",
- "relationship-data": [
- {
- "relationship-value": "8a9ddb25-2e79-449c-a40d-5011bac0da39",
- "relationship-key": "generic-vnf.vnf-id"
- }
- ],
- "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39",
- "related-to-property": [
- {
- "property-key": "generic-vnf.vnf-name",
- "property-value": "Firewall-1"
- }
- ]
- },
- {
- "related-to": "flavor",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "RegionOne",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "764efb04-5a46-4806-a766-2bdd24559f39",
- "relationship-key": "flavor.flavor-id"
- }
- ],
- "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/764efb04-5a46-4806-a766-2bdd24559f39",
- "related-to-property": [
- {
- "property-key": "flavor.flavor-name",
- "property-value": "m1.medium"
- }
- ]
- },
- {
- "related-to": "image",
- "relationship-data": [
- {
- "relationship-value": "CloudOwner",
- "relationship-key": "cloud-region.cloud-owner"
- },
- {
- "relationship-value": "RegionOne",
- "relationship-key": "cloud-region.cloud-region-id"
- },
- {
- "relationship-value": "42fd42f8-cf81-4f4c-a552-d4b124f83b0b",
- "relationship-key": "image.image-id"
- }
- ],
- "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/42fd42f8-cf81-4f4c-a552-d4b124f83b0b",
- "related-to-property": [
- {
- "property-key": "image.image-name",
- "property-value": "unknown"
- }
- ]
- }
- ]
- },
- "in-maint": false,
- "resource-version": "1528481820321",
- "vserver-name": "Firewall-0",
- "prov-status": "ACTIVE",
- "vserver-id": "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74b",
- "vserver-name2": "Firewall-0",
- "vserver-selflink": "http://10.12.25.2:8774/v2.1/b49b830686654191bb1e952a74b014ad/servers/25fb07ab-0478-465e-a021-6384ac299671",
- "is-closed-loop-disabled": false
- }
- ],
- "resource-version": "1527638176989",
- "model-customization-id": "4cc1e555-361f-4d69-ae21-9f371ea9f40c",
- "vf-modules": {
- "vf-module": [
- {
- "vf-module-name": "vPacketGen-VNF-1128-3",
- "model-version-id": "d6d4a002-a584-4640-bdce-a50e9bce552b",
- "heat-stack-id": "vPacketGen-VNF-1128-3/df34f5d6-ed39-4184-b785-51c37cfa8ac2",
- "resource-version": "1527641224058",
- "model-customization-id": "49c8f521-e5ee-4095-bb87-4090166e49ab",
- "is-base-vf-module": true,
- "vf-module-id": "0f792076-f5b3-4251-9fcc-c4d5afae0eb1",
- "module-index": 0,
- "model-invariant-id": "2a8844a8-f5f7-46dd-a732-472c6972a28e",
- "orchestration-status": "active"
- }
- ]
- },
- "vserver": [
- {
- "vserver-name": "Firewall-1",
- "vserver-id": "25fb07ab-0478-465e-a021-6384ac299672",
- "model-invariant-id": "0c5a20de-87ad-442c-9190-f38ab0a6bb7f"
- }
- ],
- "model-invariant-id": "99f1fd3f-845c-48f5-a0ba-11fbde6ae557",
- "vnf-name": "PacketGenerator-2",
- "is-closed-loop-disabled": false
- }
- ],
- "model-invariant-id": "0c5a20de-87ad-442c-9190-f38ab0a6bb7f",
- "service-instance-name": "Firewall1"
-} \ No newline at end of file
diff --git a/src/test/resources/junit/networkDiscovery-1.json b/src/test/resources/junit/networkDiscovery-1.json
deleted file mode 100644
index 6dd844f..0000000
--- a/src/test/resources/junit/networkDiscovery-1.json
+++ /dev/null
@@ -1,83 +0,0 @@
-{
- "requestId": "2131_1",
- "code": 200,
- "message": "OK",
- "ackFinalIndicator": true,
- "resources": [{
- "id": "25fb07ab-0478-465e-a021-6384ac299671",
- "type": "vserver",
- "dataQuality": {
- "status": "ok"
- },
- "attributeList": [{
- "name": "vserver-id",
- "value": "25fb07ab-0478-465e-a021-6384ac299671",
- "dataQuality": {
- "status": "ok"
- }
- },
- {
- "name": "power-state",
- "value": "1",
- "dataQuality": {
- "status": "ok"
- }
- },
- {
- "name": "vm-state",
- "value": "active",
- "dataQuality": {
- "status": "ok"
- }
- },
- {
- "name": "status",
- "value": "ACTIVE",
- "dataQuality": {
- "status": "ok"
- }
- },
- {
- "name": "host-status",
- "value": "UNKNOWN",
- "dataQuality": {
- "status": "ok"
- }
- },
- {
- "name": "updated",
- "value": "2017-11-20T04:26:13Z",
- "dataQuality": {
- "status": "ok"
- }
- },
- {
- "name": "disk-allocation-gb",
- "value": ".010",
- "dataQuality": {
- "status": "ok"
- }
- },
- {
- "name": "memory-usage-mb",
- "value": "null",
- "dataQuality": {
- "status": "ok"
- }
- },
- {
- "name": "cpu-util-percent",
- "value": ".048",
- "dataQuality": {
- "status": "ok"
- }
- },
- {
- "name": "retrieval-timestamp",
- "value": "2018-07-26 01:37:07 +0000",
- "dataQuality": {
- "status": "ok"
- }
- }]
- }]
-} \ No newline at end of file
diff --git a/src/test/resources/junit/networkDiscoveryResponseL3Network.json b/src/test/resources/junit/networkDiscoveryResponseL3Network.json
new file mode 100644
index 0000000..e7087e2
--- /dev/null
+++ b/src/test/resources/junit/networkDiscoveryResponseL3Network.json
@@ -0,0 +1,83 @@
+{
+ "requestId": "88001",
+ "code": 200,
+ "message": "OK",
+ "ackFinalIndicator": true,
+ "resources": [
+ {
+ "id": "01e8d84a-17a6-47b5-a167-6a45d1d56603",
+ "name": null,
+ "type": "l3-network",
+ "dataQuality": {
+ "status": "ok",
+ "errorText": null
+ },
+ "attributeList": [
+ {
+ "name": "id",
+ "value": "01e8d84a-17a6-47b5-a167-6a45d1d56603",
+ "dataQuality": {
+ "status": "ok",
+ "errorText": null
+ }
+ },
+ {
+ "name": "name",
+ "value": "NET_1106",
+ "dataQuality": {
+ "status": "ok",
+ "errorText": null
+ }
+ },
+ {
+ "name": "AdminState",
+ "value": "true",
+ "dataQuality": {
+ "status": "ok",
+ "errorText": null
+ }
+ },
+ {
+ "name": "sharedNetwork",
+ "value": "true",
+ "dataQuality": {
+ "status": "ok",
+ "errorText": null
+ }
+ },
+ {
+ "name": "status",
+ "value": "ACTIVE",
+ "dataQuality": {
+ "status": "ok",
+ "errorText": null
+ }
+ },
+ {
+ "name": "subnets",
+ "value": "089c9160-6f7a-4ae0-83b7-33536b4c6672",
+ "dataQuality": {
+ "status": "ok",
+ "errorText": null
+ }
+ },
+ {
+ "name": "tenantId",
+ "value": "cbd5e07f58d84ea6b795aa9f5f207df0",
+ "dataQuality": {
+ "status": "ok",
+ "errorText": null
+ }
+ },
+ {
+ "name": "host-status",
+ "value": "UNKNOWN",
+ "dataQuality": {
+ "status": "ok",
+ "errorText": null
+ }
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/src/test/resources/junit/networkDiscoveryResponse-1.json b/src/test/resources/junit/networkDiscoveryResponseVserver-1.json
index 7df8470..7861c71 100644
--- a/src/test/resources/junit/networkDiscoveryResponse-1.json
+++ b/src/test/resources/junit/networkDiscoveryResponseVserver-1.json
@@ -5,8 +5,8 @@
"ackFinalIndicator": true,
"resources": [
{
- "id": "2c311eae-f542-4173-8a01-582922abd495",
- "name": null,
+ "id": "25fb07ab-0478-465e-a021-6384ac299671",
+ "name": "vserver-name",
"type": "vserver",
"dataQuality": {
"status": "ok",
@@ -23,6 +23,14 @@
},
{
"name": "name",
+ "value": "norm-d2-k8s",
+ "dataQuality": {
+ "status": "ok",
+ "errorText": null
+ }
+ },
+ {
+ "name": "hostname",
"value": "norm_bouygues",
"dataQuality": {
"status": "ok",
diff --git a/src/test/resources/junit/serviceDecomposition-1.json b/src/test/resources/junit/serviceDecompositionResponse-1.json
index 10ebe4a..3303e26 100644
--- a/src/test/resources/junit/serviceDecomposition-1.json
+++ b/src/test/resources/junit/serviceDecompositionResponse-1.json
@@ -348,7 +348,7 @@
"network-role": "HNPORTALOAM.OAM",
"network-technology": "ovs",
"service-id": "V7611HNP-1222-48f1-8085-94aef0c6ef3d51870",
- "network-id": "HNP1d77c-1222-41ec-b7f3-94bb30951870",
+ "network-id": "01e8d84a-17a6-47b5-a167-6a45d1d56603",
"neutron-network-id": "491c7cef-a3f4-4990-883e-b0af397466d0",
"is-external-network": false,
"is-bound-to-vpn": false,