summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java42
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java57
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java47
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create2.json15
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml5
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml6
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml6
-rwxr-xr-xadapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java5
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java100
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java57
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java4
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java8
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java36
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java5
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java4
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java11
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java7
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java20
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java95
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java40
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml16
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java58
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java102
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java47
-rw-r--r--asdc-controller/pom.xml4
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java33
-rw-r--r--bpmn/MSOCommonBPMN/pom.xml10
-rw-r--r--common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java2
-rw-r--r--docs/architecture/SO Internal Arc.pptxbin56617 -> 58944 bytes
-rw-r--r--vnfm-simulator/vnf-service/pom.xml78
-rw-r--r--vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java69
-rw-r--r--vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmHealthcheck.java58
-rw-r--r--vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/GlobalExceptionHandler.java27
-rw-r--r--vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/InvalidRestRequestException.java37
-rw-r--r--vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/RestProcessingException.java37
-rw-r--r--vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java60
-rw-r--r--vnfm-simulator/vnf-service/src/main/resources/json/createVNFResponse.json19
-rw-r--r--vnfm-simulator/vnfm-service/pom.xml261
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/ApplicationConfig.java43
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/SvnfmApplication.java6
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/WebSecurityConfigImpl.java48
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/constants/Constant.java8
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java129
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/model/VnfOperation.java (renamed from vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/model/VnfJob.java)45
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/model/Vnfds.java97
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfOperationRepository.java (renamed from vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfJobRepository.java)4
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfmCacheRepository.java23
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/InstantiateOperationProgressor.java123
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java239
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SubscriptionService.java21
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java167
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/TerminateOperationProgressor.java74
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java47
-rw-r--r--vnfm-simulator/vnfm-service/src/main/resources/application.properties13
-rw-r--r--vnfm-simulator/vnfm-service/src/main/resources/application.yaml59
-rw-r--r--vnfm-simulator/vnfm-service/src/test/java/org/onap/svnfm/simulator/controllers/TestSvnfmController.java17
56 files changed, 1637 insertions, 1014 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java
index bb15e58c88..732f9b5196 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java
@@ -22,13 +22,16 @@ package org.onap.so.openstack.utils;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({"template_type", "workload_id", "template_response"})
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonPropertyOrder({"template_type", "workload_id", "template_response", "workload_status_reason", "workload_status"})
public class MulticloudCreateResponse implements Serializable {
private final static long serialVersionUID = -5215028275577848311L;
@@ -37,12 +40,16 @@ public class MulticloudCreateResponse implements Serializable {
@JsonProperty("workload_id")
private String workloadId;
@JsonProperty("template_response")
- private MulticloudCreateStackResponse templateResponse;
+ private JsonNode templateResponse;
+ @JsonProperty("workload_status_reason")
+ private JsonNode workloadStatusReason;
+ @JsonProperty("workload_status")
+ private String workloadStatus;
@JsonCreator
public MulticloudCreateResponse(@JsonProperty("template_type") String templateType,
@JsonProperty("workload_id") String workloadId,
- @JsonProperty("template_response") MulticloudCreateStackResponse templateResponse) {
+ @JsonProperty("template_response") JsonNode templateResponse) {
this.templateType = templateType;
this.workloadId = workloadId;
this.templateResponse = templateResponse;
@@ -69,18 +76,41 @@ public class MulticloudCreateResponse implements Serializable {
}
@JsonProperty("template_response")
- public void setTemplateResponse(MulticloudCreateStackResponse templateResponse) {
+ public void setTemplateResponse(JsonNode templateResponse) {
this.templateResponse = templateResponse;
}
@JsonProperty("template_response")
- public MulticloudCreateStackResponse getTemplateResponse() {
+ public JsonNode getTemplateResponse() {
return templateResponse;
}
+ @JsonProperty("workload_status_reason")
+ public void setWorkloadStatusReason(JsonNode workloadStatusReason) {
+ this.workloadStatusReason = workloadStatusReason;
+ }
+
+ @JsonProperty("workload_status_reason")
+ public JsonNode getWorkloadStatusReason() {
+ return workloadStatusReason;
+ }
+
+ @JsonProperty("workload_status")
+ public String getWorkloadSstatus() {
+ return workloadStatus;
+ }
+
+ @JsonProperty("workload_status")
+ public void setWorkloadStatus(String workloadStatus) {
+ this.workloadStatus = workloadStatus;
+ }
+
+
@Override
public String toString() {
return new ToStringBuilder(this).append("templateType", templateType).append("workloadId", workloadId)
- .append("templateResponse", templateResponse).toString();
+ .append("templateResponse", templateResponse)
+ .append("workload_status_reason", workloadStatusReason.toString())
+ .append("workload_status", workloadStatus).toString();
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java
deleted file mode 100644
index 67cb73539d..0000000000
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Intel Corp. All rights reserved.
- * ================================================================================
- * 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.so.openstack.utils;
-
-import java.io.Serializable;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import org.apache.commons.lang.builder.ToStringBuilder;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({"stack"})
-public class MulticloudCreateStackResponse implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
-
- @JsonProperty("stack")
- private MulticloudCreateHeatResponse stack;
-
- @JsonCreator
- public MulticloudCreateStackResponse(@JsonProperty("stack") MulticloudCreateHeatResponse stack) {
- this.stack = stack;
- }
-
- @JsonProperty("stack")
- public MulticloudCreateHeatResponse getStack() {
- return stack;
- }
-
- @JsonProperty("stack")
- public void setStack(MulticloudCreateHeatResponse stack) {
- this.stack = stack;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("stack", stack).toString();
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
index 5f2057524f..48ca0fd79c 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
@@ -55,8 +55,6 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils {
@Autowired
private CloudConfig cloudConfig;
- private static final String CREATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
- + "\"workload-id\", \"template_response\": {\"stack\": {\"id\": \"TEST-stack\", \"links\": []}}}";
private static final String UPDATE_STACK_RESPONSE =
"{\"template_type\": \"heat\", \"workload_id\": " + "\"workload-id\"}";
private static final String GET_CREATE_STACK_RESPONSE = "{\"template_type\": \"heat\", \"workload_id\": "
@@ -125,6 +123,51 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils {
}
@Test
+ public void createVfModule2() throws Exception {
+
+ Map<String, Object> stackInputs = new HashMap<>();
+ stackInputs.put("oof_directives", "{}");
+ stackInputs.put("sdnc_directives", "{}");
+ stackInputs.put("user_directives", "{}");
+ stackInputs.put("generic_vnf_id", "genVNFID");
+ stackInputs.put("vf_module_id", "vfMODULEID");
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_NAME)).willReturn(
+ aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND)));
+
+ wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE")
+ .whenScenarioStateIs("CREATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(GET_CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
+
+ wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE")
+ .whenScenarioStateIs("UPDATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(GET_UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
+
+ wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE")
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("MulticloudResponse_Stack_Create2.json").withStatus(HttpStatus.SC_CREATED))
+ .willSetStateTo("CREATING"));
+
+ wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH))
+ .inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_ACCEPTED))
+ .willSetStateTo("UPDATING"));
+
+ try {
+ instance.createVfModule("MTN13", "CloudOwner", "123", "vf", "v1", "genericVnfId", "vfname", "vfModuleId",
+ "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true,
+ msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
+ } catch (VnfException e) {
+ fail("createVfModule success expected, failed with exception: " + e.toString());
+ }
+ wireMockServer.resetScenarios();
+ }
+
+ @Test
public void createVfModuleAlreadyExists() throws Exception {
Map<String, Object> stackInputs = new HashMap<>();
diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create2.json b/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create2.json
new file mode 100644
index 0000000000..8532fae97c
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create2.json
@@ -0,0 +1,15 @@
+{
+ "template_type": "HEAT",
+ "workload_id": "workload-id",
+ "workload_status_reason":
+ {
+ "id": "workload-id",
+ "links": [
+ {
+ "href": "http://localhost:1234/v1/id12345678/stacks/workload-id/abcdef00-1234-abcd-5678-ef9123456789",
+ "rel": "self"
+ }
+ ]
+ },
+ "workload_status": "CREATE_IN_PROGRESS"
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml
index 66a1cb1ca7..9d9e33a524 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml
@@ -100,5 +100,10 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.squareup.okio</groupId>
+ <artifactId>okio</artifactId>
+ <version>1.13.0</version>
+ </dependency>
</dependencies>
</project>
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml
index da778d286e..91478e1f8e 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml
@@ -62,7 +62,6 @@
<apiPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.api</apiPackage>
<modelPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model</modelPackage>
<configOptions>
- <jackson>true</jackson>
<sourceFolder>src/gen/java/main</sourceFolder>
<withXml>true</withXml>
<useRxJava2>true</useRxJava2>
@@ -79,15 +78,16 @@
<inputSpec>${basedir}/src/main/resources/SOL003-VNFLifecycleOperationGranting-API.json
</inputSpec>
<language>java</language>
- <library>retrofit2</library>
+ <library>okhttp-gson</library>
<output>${project.build.directory}/generated-sources/sol003-vnf-grant</output>
- <generateApis>false</generateApis>
+ <apiPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.api</apiPackage>
<modelPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model</modelPackage>
<configOptions>
<generateSupportingFiles>false</generateSupportingFiles>
<sourceFolder>src/gen/java/main</sourceFolder>
<withXml>true</withXml>
<useRxJava2>true</useRxJava2>
+ <serializableModel>true</serializableModel>
</configOptions>
</configuration>
</execution>
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml
index c561721b3e..09c28f93f1 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml
@@ -63,6 +63,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
index 30ce0c2253..62d2f7e2a9 100755
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
@@ -20,11 +20,13 @@
package org.onap.so.adapters.vnfmadapter;
+import static org.slf4j.LoggerFactory.getLogger;
import org.onap.so.adapters.vnfmadapter.rest.VnfmAdapterController;
import org.slf4j.Logger;
import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import static org.slf4j.LoggerFactory.getLogger;
+import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
/**
* The spring boot application for the VNFM (Virtual Network Function Manager) Adapter.
@@ -36,6 +38,7 @@ import static org.slf4j.LoggerFactory.getLogger;
* SOL003 v2.5.1</a>
*/
@SpringBootApplication(scanBasePackages = {"org.onap.so"})
+@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class})
public class VnfmAdapterApplication {
private static final Logger logger = getLogger(VnfmAdapterApplication.class);
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
index f1074bcba8..fd92910e36 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
@@ -22,20 +22,21 @@
package org.onap.so.adapters.vnfmadapter.extclients;
+import static com.google.common.base.Splitter.on;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.io.ByteStreams.toByteArray;
+import static java.lang.String.format;
+import static org.apache.http.HttpHeaders.ACCEPT;
+import static org.apache.http.HttpHeaders.AUTHORIZATION;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.abortOperation;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.child;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.childElement;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.children;
+import static org.slf4j.LoggerFactory.getLogger;
+import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
import com.google.common.io.ByteStreams;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.onap.so.utils.CryptoUtils;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-import org.yaml.snakeyaml.Yaml;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -48,25 +49,24 @@ import java.util.NoSuchElementException;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import static com.google.common.base.Splitter.on;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.io.ByteStreams.toByteArray;
-import static java.lang.String.format;
-import static org.apache.http.HttpHeaders.ACCEPT;
-import static org.apache.http.HttpHeaders.AUTHORIZATION;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.abortOperation;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.child;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.childElement;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.children;
-import static org.slf4j.LoggerFactory.getLogger;
-import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.onap.so.utils.CryptoUtils;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.yaml.snakeyaml.Yaml;
@Component
public class SdcPackageProvider {
- private static final String GET_PACKAGE_URL = "%s/catalog/resources/%s/toscaModel";
+ private static final String GET_PACKAGE_URL = "%s/sdc/v1/catalog/resources/%s/toscaModel";
@Value("${sdc.toscametapath:TOSCA-Metadata/TOSCA.meta}")
private List<String> toscaMetaPaths;
- private final String TOSCA_VNFD_KEY = "Entry-Definitions";
+ private static final String TOSCA_VNFD_KEY = "Entry-Definitions";
private static Logger logger = getLogger(SdcPackageProvider.class);
@Value("${sdc.username}")
@@ -78,7 +78,7 @@ public class SdcPackageProvider {
@Value("${sdc.endpoint}")
private String baseUrl;
- public String getVnfdId(String csarId) {
+ public String getVnfdId(final String csarId) {
return getVnfNodeProperty(csarId, "descriptor_id");
}
@@ -96,7 +96,7 @@ public class SdcPackageProvider {
for (final JsonObject child : children(nodeTemplates)) {
final String type = childElement(child, "type").getAsString();
String propertyValue = null;
- if (type.equals("tosca.nodes.nfv.VNF")) {
+ if ("tosca.nodes.nfv.VNF".equals(type)) {
final JsonObject properties = child(child, "properties");
logger.debug("properties: " + properties.toString());
@@ -119,7 +119,7 @@ public class SdcPackageProvider {
final JsonObject nodeTypes = child(root, "node_types");
final JsonObject nodeType = child(nodeTypes, nodeTypeName);
- if (childElement(nodeType, "derived_from").getAsString().equals("tosca.nodes.nfv.VNF")) {
+ if ("tosca.nodes.nfv.VNF".equals(childElement(nodeType, "derived_from").getAsString())) {
final JsonObject properties = child(nodeType, "properties");
logger.debug("properties: " + properties.toString());
final JsonObject property = child(properties, propertyName);
@@ -130,34 +130,33 @@ public class SdcPackageProvider {
return null;
}
- private byte[] getPackage(String csarId) {
+ private byte[] getPackage(final String csarId) {
final String SERVICE_NAME = "vnfm-adapter";
try (CloseableHttpClient client = HttpClients.createDefault()) {
- HttpGet httpget = new HttpGet(format(GET_PACKAGE_URL, baseUrl, csarId));
+ final HttpGet httpget = new HttpGet(format(GET_PACKAGE_URL, baseUrl, csarId));
httpget.setHeader(ACCEPT, APPLICATION_OCTET_STREAM_VALUE);
httpget.setHeader("X-ECOMP-InstanceID", SERVICE_NAME);
httpget.setHeader("X-FromAppId", SERVICE_NAME);
- String auth = sdcUsername + ":" + CryptoUtils.decrypt(sdcPassword, sdcKey);
- byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
- String authHeader = "Basic " + new String(encodedAuth);
+ final String auth = sdcUsername + ":" + CryptoUtils.decrypt(sdcPassword, sdcKey);
+ final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
+ final String authHeader = "Basic " + new String(encodedAuth);
httpget.setHeader(AUTHORIZATION, authHeader);
logger.debug("Fetching from SDC: " + httpget);
- CloseableHttpResponse response = client.execute(httpget);
- HttpEntity entity = response.getEntity();
- InputStream is = entity.getContent();
- byte[] bytes = toByteArray(is);
- return bytes;
- } catch (Exception e) {
+ final CloseableHttpResponse response = client.execute(httpget);
+ final HttpEntity entity = response.getEntity();
+ final InputStream is = entity.getContent();
+ return toByteArray(is);
+ } catch (final Exception e) {
throw abortOperation("Unable to download " + csarId + " package from SDC", e);
}
}
- private String getVnfdLocation(InputStream stream) throws IOException {
- Iterator pathIterator = toscaMetaPaths.iterator();
+ private String getVnfdLocation(final InputStream stream) throws IOException {
+ final Iterator<String> pathIterator = toscaMetaPaths.iterator();
while (pathIterator.hasNext()) {
- String toscaMetadata = new String(getFileInZip(stream, pathIterator.next().toString()).toByteArray());
+ final String toscaMetadata = new String(getFileInZip(stream, pathIterator.next()).toByteArray());
if (!toscaMetadata.isEmpty()) {
- String toscaVnfdLine =
+ final String toscaVnfdLine =
filter(on("\n").split(toscaMetadata), line -> line.contains(TOSCA_VNFD_KEY)).iterator().next();
return toscaVnfdLine.replace(TOSCA_VNFD_KEY + ":", "").trim();
}
@@ -165,20 +164,21 @@ public class SdcPackageProvider {
throw abortOperation("Unable to find valid Tosca Path");
}
- private static ByteArrayOutputStream getFileInZip(InputStream zip, String path) throws IOException {
- ZipInputStream zipInputStream = new ZipInputStream(zip);
- ByteArrayOutputStream fileContent = getFileInZip(zipInputStream, path);
+ private static ByteArrayOutputStream getFileInZip(final InputStream zip, final String path) throws IOException {
+ final ZipInputStream zipInputStream = new ZipInputStream(zip);
+ final ByteArrayOutputStream fileContent = getFileInZip(zipInputStream, path);
zipInputStream.close();
return fileContent;
}
- private static ByteArrayOutputStream getFileInZip(ZipInputStream zipInputStream, String path) throws IOException {
+ private static ByteArrayOutputStream getFileInZip(final ZipInputStream zipInputStream, final String path)
+ throws IOException {
ZipEntry zipEntry;
- Set<String> items = new HashSet<>();
+ final Set<String> items = new HashSet<>();
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
items.add(zipEntry.getName());
if (zipEntry.getName().matches(path)) {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ByteStreams.copy(zipInputStream, byteArrayOutputStream);
return byteArrayOutputStream;
}
@@ -187,7 +187,7 @@ public class SdcPackageProvider {
throw new NoSuchElementException("Unable to find the " + path + " in archive found: " + items);
}
- public String getFlavourId(String csarId) {
+ public String getFlavourId(final String csarId) {
return getVnfNodeProperty(csarId, "flavour_id");
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
index 50fd5bcf3a..1374e89a19 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
@@ -20,6 +20,10 @@
package org.onap.so.adapters.vnfmadapter.extclients.aai;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrVnfm;
@@ -40,9 +44,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
/**
* Provides helper methods for interactions with AAI.
@@ -110,7 +111,7 @@ public class AaiHelper {
*/
public String getIdOfAssignedVnfm(final GenericVnf vnf) {
final Relationship relationship = getRelationship(vnf, "esr-vnfm");
- return getRelationshipKey(relationship, "esr-vnfm.vnfm-id");
+ return getRelationshipData(relationship, "esr-vnfm.vnfm-id");
}
/**
@@ -121,9 +122,9 @@ public class AaiHelper {
*/
public Tenant getAssignedTenant(final GenericVnf vnf) {
final Relationship relationship = getRelationship(vnf, "tenant");
- final String cloudOwner = getRelationshipKey(relationship, "cloud-region.cloud-owner");
- final String cloudRegion = getRelationshipKey(relationship, "cloud-region.cloud-region-id");
- final String tenantId = getRelationshipKey(relationship, "tenant.tenant-id");
+ final String cloudOwner = getRelationshipData(relationship, "cloud-region.cloud-owner");
+ final String cloudRegion = getRelationshipData(relationship, "cloud-region.cloud-region-id");
+ final String tenantId = getRelationshipData(relationship, "tenant.tenant-id");
if (cloudOwner == null || cloudRegion == null || tenantId == null) {
throw new TenantNotFoundException("No matching Tenant found in AAI. VNFID: " + vnf.getVnfId());
} else {
@@ -141,10 +142,17 @@ public class AaiHelper {
return null;
}
- private String getRelationshipKey(final Relationship relationship, final String relationshipKey) {
+ /**
+ * Get the value of the relationship data with the given key in the given relationship.
+ *
+ * @param relationship the relationship
+ * @param relationshipDataKey the key for the relationship data
+ * @return the value of the relationship data for the given key
+ */
+ public String getRelationshipData(final Relationship relationship, final String relationshipDataKey) {
if (relationship != null) {
for (final RelationshipData relationshipData : relationship.getRelationshipData()) {
- if (relationshipData.getRelationshipKey().equals(relationshipKey)) {
+ if (relationshipData.getRelationshipKey().equals(relationshipDataKey)) {
return relationshipData.getRelationshipValue();
}
}
@@ -153,6 +161,32 @@ public class AaiHelper {
}
/**
+ * Delete from the given VNF the relationship matching the given criteria.
+ *
+ * @param vnf the VNF
+ * @param relationshipRelatedToValue the related-to value for the relationship
+ * @param dataKey the relationship data key to match on
+ * @param dataValue the value the relationship data with the given key must match
+ * @return the deleted relationship or <code>null</code> if none found matching the given criteria
+ */
+ public Relationship deleteRelationshipWithDataValue(final GenericVnf vnf, final String relationshipRelatedToValue,
+ final String dataKey, final String dataValue) {
+ final Iterator<Relationship> relationships =
+ vnf.getRelationshipList() == null ? Collections.<Relationship>emptyList().iterator()
+ : vnf.getRelationshipList().getRelationship().iterator();
+
+ while (relationships.hasNext()) {
+ final Relationship relationship = relationships.next();
+ if (relationship.getRelatedTo().equals(relationshipRelatedToValue)
+ && dataValue.equals(getRelationshipData(relationship, dataKey))) {
+ relationships.remove();
+ return relationship;
+ }
+ }
+ return null;
+ }
+
+ /**
* Select a VNFM to use for the given generic VNF. Should only be used when no VNFM has already been assigned to the
* VNF.
*
@@ -257,7 +291,12 @@ public class AaiHelper {
relationship.setRelatedTo("tenant");
relationship.setRelatedLink("/aai/" + AAIVersion.LATEST + AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
tenant.getCloudOwner(), tenant.getRegionName(), tenant.getTenantId()).build().toString());
+ relationship.getRelationshipData()
+ .add(createRelationshipData("cloud-region.cloud-owner", tenant.getCloudOwner()));
+ relationship.getRelationshipData()
+ .add(createRelationshipData("cloud-region.cloud-region-id", tenant.getRegionName()));
relationship.getRelationshipData().add(createRelationshipData("tenant.tenant-id", tenant.getTenantId()));
return relationship;
}
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
index f991ffafba..7021c02511 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
@@ -24,9 +24,9 @@ import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.EsrVnfmList;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Vserver;
import org.onap.vnfmadapter.v1.model.Tenant;
-import java.util.List;
/**
* Provides methods for invoking REST calls to AAI.
@@ -47,7 +47,7 @@ public interface AaiServiceProvider {
* @param selfLink the selfLink
* @return the matching generic vnfs
*/
- List<GenericVnf> invokeQueryGenericVnf(final String selfLink);
+ GenericVnfs invokeQueryGenericVnf(final String selfLink);
/**
* Invoke a GET request for the VNFMs.
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
index fa07ab5720..50e579dd83 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
@@ -24,6 +24,7 @@ import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.EsrVnfmList;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
@@ -32,7 +33,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.List;
@Service
public class AaiServiceProviderImpl implements AaiServiceProvider {
@@ -56,9 +56,9 @@ public class AaiServiceProviderImpl implements AaiServiceProvider {
}
@Override
- public List<GenericVnf> invokeQueryGenericVnf(final String selfLink) {
+ public GenericVnfs invokeQueryGenericVnf(final String selfLink) {
return aaiClientProvider.getAaiClient()
- .get(List.class,
+ .get(GenericVnfs.class,
AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNFS).queryParam("selflink", selfLink))
.orElseGet(() -> {
logger.debug("No vnf found in AAI with selflink: {}", selfLink);
@@ -104,7 +104,7 @@ public class AaiServiceProviderImpl implements AaiServiceProvider {
@Override
public void invokePutVserver(final String cloudOwner, final String cloudRegion, final String tenant,
final Vserver vserver) {
- aaiClientProvider.getAaiClient().update(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner,
+ aaiClientProvider.getAaiClient().create(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner,
cloudRegion, tenant, vserver.getVserverId()), vserver);
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
index 31399f7720..249cf74cb2 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
@@ -20,10 +20,16 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
+import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
+import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vim.model.AccessInfo;
@@ -40,7 +46,7 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilte
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilterVnfInstanceSubscriptionFilter;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateExtVirtualLinks;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateVimConnectionInfo;
-import org.onap.so.security.WebSecurityConfig;
+import org.onap.so.utils.CryptoUtils;
import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
import org.onap.vnfmadapter.v1.model.Tenant;
@@ -49,11 +55,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
-import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
/**
* Provides helper methods for interactions with VNFM.
@@ -64,15 +65,19 @@ public class VnfmHelper {
private static final Logger logger = LoggerFactory.getLogger(VnfmHelper.class);
private static final String SEPARATOR = "_";
private final AaiServiceProvider aaiServiceProvider;
- private final WebSecurityConfig webSecurityConfig;
@Value("${vnfmadapter.endpoint}")
private String vnfmAdapterEndoint;
+ @Value("${vnfmadapter.auth:E39823AAB2739CC654C4E92B52C05BC34149342D0A46451B00CA508C8EDC62242CE4E9DA9445D3C01A3F13}")
+ private String vnfmAdapterAuth;
+
+ @Value("${mso.key}")
+ private String msoEncryptionKey;
+
@Autowired
- public VnfmHelper(final AaiServiceProvider aaiServiceProvider, final WebSecurityConfig webSecurityConfig) {
+ public VnfmHelper(final AaiServiceProvider aaiServiceProvider) {
this.aaiServiceProvider = aaiServiceProvider;
- this.webSecurityConfig = webSecurityConfig;
}
/**
@@ -171,8 +176,10 @@ public class VnfmHelper {
*
* @param the ID of the VNF notifications are required for
* @return the request
+ * @throws GeneralSecurityException
*/
- public LccnSubscriptionRequest createNotificationSubscriptionRequest(final String vnfId) {
+ public LccnSubscriptionRequest createNotificationSubscriptionRequest(final String vnfId)
+ throws GeneralSecurityException {
final LccnSubscriptionRequest lccnSubscriptionRequest = new LccnSubscriptionRequest();
lccnSubscriptionRequest.setAuthentication(getSubscriptionsAuthentication());
lccnSubscriptionRequest.setCallbackUri(vnfmAdapterEndoint + BASE_URL + OPERATION_NOTIFICATION_ENDPOINT);
@@ -186,12 +193,11 @@ public class VnfmHelper {
return lccnSubscriptionRequest;
}
- private SubscriptionsAuthentication getSubscriptionsAuthentication() {
+ private SubscriptionsAuthentication getSubscriptionsAuthentication() throws GeneralSecurityException {
final SubscriptionsAuthenticationParamsBasic basicAuthParams = new SubscriptionsAuthenticationParamsBasic();
- basicAuthParams.setUserName("vnfm");
- basicAuthParams.setPassword(webSecurityConfig.getUsercredentials().stream()
- .filter(userCredentials -> "vnfm".equals(userCredentials.getUsername())).findFirst().get()
- .getPassword());
+ final String[] decrypedAuth = CryptoUtils.decrypt(vnfmAdapterAuth, msoEncryptionKey).split(":");
+ basicAuthParams.setUserName(decrypedAuth[0]);
+ basicAuthParams.setPassword(decrypedAuth[1]);
final SubscriptionsAuthentication authentication = new SubscriptionsAuthentication();
authentication.addAuthTypeItem(AuthTypeEnum.BASIC);
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
index 951c6f187b..e66f86b66f 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
@@ -84,10 +84,12 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
@Override
public InlineResponse2001 subscribeForNotifications(final String vnfmId,
final LccnSubscriptionRequest subscriptionRequest) {
+ logger.info("Subscribing for notifications {}", subscriptionRequest);
final String url = urlProvider.getSubscriptionsUrl(vnfmId);
ResponseEntity<InlineResponse2001> response = null;
try {
response = httpServiceProvider.postHttpRequest(subscriptionRequest, url, InlineResponse2001.class);
+ logger.info("Subscribing for notifications response {}", response);
} catch (final Exception exception) {
final String errorMessage =
"Subscription to VNFM " + vnfmId + " resulted in exception" + subscriptionRequest;
@@ -131,7 +133,7 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
public void deleteVnf(final String vnfSelfLink) {
logger.debug("Sending delete request to : " + vnfSelfLink);
final ResponseEntity<Void> response = httpServiceProvider.deleteHttpRequest(vnfSelfLink, Void.class);
- if (response.getStatusCode() != HttpStatus.OK) {
+ if (response.getStatusCode() != HttpStatus.NO_CONTENT) {
throw new VnfmRequestFailureException(
"Delete request to " + vnfSelfLink + " return status code: " + response.getStatusCode());
}
@@ -146,6 +148,7 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
@Override
public Optional<InlineResponse201> createVnf(final String vnfmId, final CreateVnfRequest createVnfRequest) {
final String url = urlProvider.getCreationUrl(vnfmId);
+ logger.debug("Sending create request {} to : {}", createVnfRequest, url);
try {
return httpServiceProvider.post(createVnfRequest, url, InlineResponse201.class);
} catch (final Exception exception) {
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java
index d4aa65d159..f948f3cfac 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java
@@ -20,6 +20,8 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
+import static org.slf4j.LoggerFactory.getLogger;
+import java.net.URI;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
@@ -28,8 +30,6 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.util.UriComponentsBuilder;
-import java.net.URI;
-import static org.slf4j.LoggerFactory.getLogger;
/**
* Provides URLs for REST calls to a VNFM.
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
index e61bf860b3..345ff5119a 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
@@ -20,8 +20,11 @@
package org.onap.so.adapters.vnfmadapter.jobmanagement;
+import static org.slf4j.LoggerFactory.getLogger;
import com.google.common.base.Optional;
import com.google.common.collect.Maps;
+import java.util.Map;
+import java.util.UUID;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.JobNotFoundException;
@@ -32,9 +35,6 @@ import org.onap.vnfmadapter.v1.model.QueryJobResponse;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.Map;
-import java.util.UUID;
-import static org.slf4j.LoggerFactory.getLogger;
/**
* Manages jobs enabling the status of jobs to be queried. A job is associated with an operation on a VNFM.
@@ -123,12 +123,15 @@ public class JobManager {
public void notificationProcessedForOperation(final String operationId,
final boolean notificationProcessingWasSuccessful) {
+ logger.debug("Notification processed for operation ID {} success?: {}", operationId,
+ notificationProcessingWasSuccessful);
final java.util.Optional<VnfmOperation> relatedOperation = mapOfJobIdToVnfmOperation.values().stream()
.filter(operation -> operation.getOperationId().equals(operationId)).findFirst();
if (relatedOperation.isPresent()) {
relatedOperation.get().setNotificationProcessed(notificationProcessingWasSuccessful);
+ } else {
+ logger.debug("No operation found for operation ID " + operationId);
}
- logger.debug("No operation found for operation ID " + operationId);
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java
index 3ed66ad713..7ce08df52f 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java
@@ -94,4 +94,11 @@ public class VnfmOperation {
NOTIFICATION_PROCESSING_FAILED;
}
+ @Override
+ public String toString() {
+ return "VnfmOperation [vnfmId=" + vnfmId + ", operationId=" + operationId + ", notificationStatus="
+ + notificationStatus + "]";
+ }
+
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
index e6b787bacc..32bb9b93a4 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
@@ -21,6 +21,7 @@
package org.onap.so.adapters.vnfmadapter.lifecycle;
import com.google.common.base.Optional;
+import java.util.Map;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider;
@@ -46,7 +47,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.Map;
/**
* Manages lifecycle operations towards the VNFMs.
@@ -64,7 +64,7 @@ public class LifecycleManager {
@Autowired
LifecycleManager(final AaiServiceProvider aaiServiceProvider, final AaiHelper aaiHelper,
final VnfmHelper vnfmHelper, final VnfmServiceProvider vnfmServiceProvider, final JobManager jobManager,
- SdcPackageProvider packageProvider) {
+ final SdcPackageProvider packageProvider) {
this.aaiServiceProvider = aaiServiceProvider;
this.vnfmServiceProvider = vnfmServiceProvider;
this.aaiHelper = aaiHelper;
@@ -90,7 +90,11 @@ public class LifecycleManager {
aaiHelper.addRelationshipFromGenericVnfToVnfm(genericVnf, vnfm.getVnfmId());
}
aaiHelper.addRelationshipFromGenericVnfToTenant(genericVnf, request.getTenant());
- InlineResponse201 vnfmResponse = sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm.getVnfmId());
+ final InlineResponse201 vnfmResponse =
+ sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm.getVnfmId());
+
+ logger.info("Create response: {}", vnfmResponse);
+
genericVnf.setSelflink(vnfmResponse.getLinks().getSelf().getHref());
aaiServiceProvider.invokePutGenericVnf(genericVnf);
final String vnfIdInVnfm = vnfmResponse.getId();
@@ -135,18 +139,18 @@ public class LifecycleManager {
}
}
- private InlineResponse201 sendCreateRequestToVnfm(CreateVnfRequest aaiRequest, GenericVnf genericVnf,
- String vnfIdInAai, String vnfmId) {
+ private InlineResponse201 sendCreateRequestToVnfm(final CreateVnfRequest aaiRequest, final GenericVnf genericVnf,
+ final String vnfIdInAai, final String vnfmId) {
logger.debug("Sending a create request to SVNFM " + aaiRequest);
- org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest vnfmRequest =
+ final org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest vnfmRequest =
new org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest();
- String vnfdId = packageProvider.getVnfdId(genericVnf.getModelVersionId());
+ final String vnfdId = packageProvider.getVnfdId(genericVnf.getModelVersionId());
vnfmRequest.setVnfdId(vnfdId);
vnfmRequest.setVnfInstanceName(aaiRequest.getName().replaceAll(" ", "_"));
vnfmRequest.setVnfInstanceDescription(vnfIdInAai);
- Optional<InlineResponse201> optionalResponse = vnfmServiceProvider.createVnf(vnfmId, vnfmRequest);
+ final Optional<InlineResponse201> optionalResponse = vnfmServiceProvider.createVnf(vnfmId, vnfmRequest);
try {
return optionalResponse.get();
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
index a339b9be70..c09aa0cd48 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
@@ -20,9 +20,14 @@
package org.onap.so.adapters.vnfmadapter.notificationhandling;
+import static org.slf4j.LoggerFactory.getLogger;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
@@ -30,16 +35,13 @@ import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource;
import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo;
import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager;
import org.slf4j.Logger;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import static org.slf4j.LoggerFactory.getLogger;
/**
* Performs updates to AAI based on a received notification. The updates are executed in a separate thread so as the
@@ -93,15 +95,14 @@ public class NotificationHandler implements Runnable {
}
private void handleVnfInstantiateCompleted() {
- final GenericVnf genericVnf =
- aaiServiceProvider.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).get(0);
+ final GenericVnf genericVnf = aaiServiceProvider
+ .invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
setOamIpAddress(genericVnf, vnfInstance);
genericVnf.setOrchestrationStatus("Created");
aaiServiceProvider.invokePutGenericVnf(genericVnf);
- updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
- vnfInstance.getVimConnectionInfo());
+ addVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(), vnfInstance.getVimConnectionInfo());
logger.debug("Finished handling notification for vnfm: " + vnfInstance.getId());
}
@@ -114,16 +115,17 @@ public class NotificationHandler implements Runnable {
}
if (oamIpAddressSource.getType().equals(OamIpAddressType.LITERAL)) {
genericVnf.setIpv4OamAddress(oamIpAddressSource.getValue());
- }
- try {
- logger.debug("ConfigurableProperties: " + vnfInstance.getVnfConfigurableProperties());
- if (vnfInstance.getVnfConfigurableProperties() == null) {
- logger.warn("No ConfigurableProperties, cannot set OAM IP Address");
+ } else {
+ try {
+ logger.debug("ConfigurableProperties: " + vnfInstance.getVnfConfigurableProperties());
+ if (vnfInstance.getVnfConfigurableProperties() == null) {
+ logger.warn("No ConfigurableProperties, cannot set OAM IP Address");
+ }
+ final JSONObject properties = new JSONObject((Map) vnfInstance.getVnfConfigurableProperties());
+ genericVnf.setIpv4OamAddress(properties.get(oamIpAddressSource.getValue()).toString());
+ } catch (final JSONException jsonException) {
+ logger.error("Error getting vnfIpAddress", jsonException);
}
- final JSONObject properties = new JSONObject((Map) vnfInstance.getVnfConfigurableProperties());
- genericVnf.setIpv4OamAddress(properties.get(oamIpAddressSource.getValue()).toString());
- } catch (final JSONException jsonException) {
- logger.error("Error getting vnfIpAddress", jsonException);
}
}
@@ -141,32 +143,31 @@ public class NotificationHandler implements Runnable {
}
private void handleVnfTerminateFailed() {
- final GenericVnf genericVnf =
- aaiServiceProvider.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).get(0);
- updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
- vnfInstance.getVimConnectionInfo());
- jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getId(), false);
+ final GenericVnf genericVnf = aaiServiceProvider
+ .invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
+ deleteVservers(vnfLcmOperationOccurrenceNotification, genericVnf);
+ jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId(), false);
}
private void handleVnfTerminateCompleted() {
- final GenericVnf genericVnf =
- aaiServiceProvider.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).get(0);
- updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
- vnfInstance.getVimConnectionInfo());
+ final GenericVnf genericVnf = aaiServiceProvider
+ .invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
+ deleteVservers(vnfLcmOperationOccurrenceNotification, genericVnf);
boolean deleteSuccessful = false;
try {
vnfmServiceProvider.deleteVnf(genericVnf.getSelflink());
deleteSuccessful = true;
} finally {
- jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getId(),
+ jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId(),
deleteSuccessful);
genericVnf.setOrchestrationStatus("Assigned");
+ genericVnf.setSelflink("");
aaiServiceProvider.invokePutGenericVnf(genericVnf);
}
}
- private void updateVservers(final VnfLcmOperationOccurrenceNotification notification, final String vnfId,
+ private void addVservers(final VnfLcmOperationOccurrenceNotification notification, final String vnfId,
final List<InlineResponse201VimConnectionInfo> vnfInstancesVimConnectionInfo) {
final Map<String, InlineResponse201VimConnectionInfo> vimConnectionIdToVimConnectionInfo = new HashMap<>();
for (final InlineResponse201VimConnectionInfo vimConnectionInfo : vnfInstancesVimConnectionInfo) {
@@ -176,22 +177,28 @@ public class NotificationHandler implements Runnable {
for (final LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs vnfc : notification.getAffectedVnfcs()) {
final InlineResponse201VimConnectionInfo vimConnectionInfo =
getVimConnectionInfo(vimConnectionIdToVimConnectionInfo, vnfc);
- switch (vnfc.getChangeType()) {
- case ADDED:
- final Vserver vserver = aaiHelper.createVserver(vnfc);
- aaiHelper.addRelationshipFromVserverVnfToGenericVnf(vserver, vnfId);
-
- aaiServiceProvider.invokePutVserver(getCloudOwner(vimConnectionInfo),
- getCloudRegion(vimConnectionInfo), getTenant(vimConnectionInfo), vserver);
- break;
- case REMOVED:
- aaiServiceProvider.invokeDeleteVserver(getCloudOwner(vimConnectionInfo),
- getCloudRegion(vimConnectionInfo), getTenant(vimConnectionInfo),
- vnfc.getComputeResource().getResourceId());
- break;
- case MODIFIED:
- case TEMPORARY:
- default:
+ if (ChangeTypeEnum.ADDED.equals(vnfc.getChangeType())) {
+ final Vserver vserver = aaiHelper.createVserver(vnfc);
+ aaiHelper.addRelationshipFromVserverVnfToGenericVnf(vserver, vnfId);
+
+ aaiServiceProvider.invokePutVserver(getCloudOwner(vimConnectionInfo), getCloudRegion(vimConnectionInfo),
+ getTenant(vimConnectionInfo), vserver);
+ }
+ }
+ }
+
+ private void deleteVservers(final VnfLcmOperationOccurrenceNotification notification, final GenericVnf vnf) {
+ for (final LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs vnfc : notification.getAffectedVnfcs()) {
+ if (ChangeTypeEnum.REMOVED.equals(vnfc.getChangeType())) {
+
+ final Relationship relationshipToVserver = aaiHelper.deleteRelationshipWithDataValue(vnf, "vserver",
+ "vserver.vserver-id", vnfc.getComputeResource().getResourceId());
+
+ aaiServiceProvider.invokeDeleteVserver(
+ aaiHelper.getRelationshipData(relationshipToVserver, "cloud-region.cloud-owner"),
+ aaiHelper.getRelationshipData(relationshipToVserver, "cloud-region.cloud-region-id"),
+ aaiHelper.getRelationshipData(relationshipToVserver, "tenant.tenant-id"),
+ vnfc.getComputeResource().getResourceId());
}
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
index 6b8802eed2..3ead98fce2 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
@@ -20,6 +20,11 @@
package org.onap.so.adapters.vnfmadapter.rest;
+import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import javax.ws.rs.core.MediaType;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmHelper;
@@ -36,15 +41,10 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
-import javax.ws.rs.core.MediaType;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
+import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping(value = BASE_URL, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@@ -52,9 +52,6 @@ public class Sol003GrantController {
private static final String SEPARATOR = "_";
private static final String VIM_TYPE = "OPENSTACK";
- private static final String CLOUD_OWNER = "myTestCloudOwner";
- private static final String REGION = "myTestRegion";
- private static final String TENANT_ID = "myTestTenantId";
private static final Logger logger = LoggerFactory.getLogger(Sol003GrantController.class);
public final AaiServiceProvider aaiServiceProvider;
public final AaiHelper aaiHelper;
@@ -71,7 +68,7 @@ public class Sol003GrantController {
@GetMapping(value = "/grants/{grantId}")
public ResponseEntity<InlineResponse201> grantsGrantIdGet(@PathVariable("grantId") final String grantId) {
logger.info("Get grant received from VNFM, grant id: " + grantId);
- return new ResponseEntity<InlineResponse201>(HttpStatus.NOT_IMPLEMENTED);
+ return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
@PostMapping(value = "/grants")
@@ -80,7 +77,7 @@ public class Sol003GrantController {
final InlineResponse201 grantResponse = createGrantResponse(grantRequest);
logger.info("Grant request returning to VNFM: " + grantResponse);
- return new ResponseEntity<InlineResponse201>(grantResponse, HttpStatus.CREATED);
+ return new ResponseEntity<>(grantResponse, HttpStatus.CREATED);
}
private InlineResponse201 createGrantResponse(final GrantRequest grantRequest) {
@@ -88,8 +85,9 @@ public class Sol003GrantController {
grantResponse.setId(UUID.randomUUID().toString());
grantResponse.setVnfInstanceId(grantRequest.getVnfInstanceId());
grantResponse.setVnfLcmOpOccId(grantRequest.getVnfLcmOpOccId());
- final Tenant tenant =
- aaiHelper.getAssignedTenant(aaiServiceProvider.invokeGetGenericVnf((grantRequest.getVnfInstanceId())));
+ final String vnfSelfLink = grantRequest.getLinks().getVnfInstance().getHref();
+ final Tenant tenant = aaiHelper
+ .getAssignedTenant(aaiServiceProvider.invokeQueryGenericVnf(vnfSelfLink).getGenericVnf().get(0));
String vimConnectionId = "";
final InlineResponse201VimConnections vimConnection = vnfmHelper.getVimConnections(tenant);
@@ -99,19 +97,11 @@ public class Sol003GrantController {
if (grantRequest.getOperation().equals(GrantRequest.OperationEnum.INSTANTIATE)) {
grantResponse.addResources(getResources(grantRequest.getAddResources(), vimConnectionId));
} else if (grantRequest.getOperation().equals(GrantRequest.OperationEnum.TERMINATE)) {
- grantResponse.addResources(getResources(grantRequest.getRemoveResources(), vimConnectionId));
+ grantResponse.removeResources(getResources(grantRequest.getRemoveResources(), vimConnectionId));
}
return grantResponse;
}
- private InlineResponse201VimConnections getVimConnectionsItem(final Tenant tenant) {
- final InlineResponse201VimConnections vimConnection = new InlineResponse201VimConnections();
- vimConnection.setId(createVimConnectionId(tenant.getCloudOwner(), tenant.getRegionName()));
- vimConnection.setVimId(vimConnection.getId());
- vimConnection.setVimType(VIM_TYPE);
- return vimConnection;
- }
-
private List<InlineResponse201AddResources> getResources(final List<GrantsAddResources> requestResources,
final String vimId) {
final List<InlineResponse201AddResources> resources = new ArrayList<>();
@@ -123,8 +113,4 @@ public class Sol003GrantController {
}
return resources;
}
-
- private String createVimConnectionId(String cloudOwner, String cloudRegionId) {
- return cloudOwner + SEPARATOR + cloudRegionId;
- }
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml
index 4fb110349d..951d4a3bb9 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml
@@ -11,6 +11,19 @@
# 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.
+spring:
+ security:
+ usercredentials:
+ - username: test
+ password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu'
+ role: BPEL-Client
+ - username: vnfm
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: BPEL-Client
+ http:
+ converters:
+ preferred-json-mapper: gson
+
server:
port: 9092
tomcat:
@@ -29,6 +42,9 @@ sdc:
password: sdcPassword
key: adadadadad
endpoint: http://sdc.onap/1234A
+
+vnfmadapter:
+ endpoint: http://so-vnfm-adapter.onap:9092
#Actuator
management:
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
index b7f5e96eab..69223d7922 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
@@ -20,7 +20,15 @@
package org.onap.so.adapters.vnfmadapter.rest;
-import com.google.gson.Gson;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Before;
@@ -30,6 +38,7 @@ import org.mockito.hamcrest.MockitoHamcrest;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
@@ -38,6 +47,8 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest.OperationEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources.TypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinks;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinksVnfLcmOpOcc;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections;
import org.onap.so.client.aai.AAIResourcesClient;
@@ -54,12 +65,6 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
-import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -84,7 +89,6 @@ public class Sol003GrantControllerTest {
@Autowired
private Sol003GrantController controller;
- private final Gson gson = new Gson();
@Before
public void setUp() throws Exception {
@@ -94,17 +98,18 @@ public class Sol003GrantControllerTest {
@Test
public void grantRequest_ValidRequestInstantiate_GrantApproved() {
- GrantRequest grantRequest = createGrantRequest("INSTANTIATE");
+ final GrantRequest grantRequest = createGrantRequest("INSTANTIATE");
setUpGenericVnfWithVnfmRelationshipInMockAai("vnfmType", "vnfm1");
final ResponseEntity<InlineResponse201> response = controller.grantsPost(grantRequest);
assertEquals(HttpStatus.CREATED, response.getStatusCode());
assertEquals(1, response.getBody().getAddResources().size());
+ assertNull(response.getBody().getRemoveResources());
assertEquals(vimConnectionId, response.getBody().getAddResources().get(0).getVimConnectionId());
- assertEquals("myTestVnfId", response.getBody().getVnfInstanceId());
+ assertEquals("myTestVnfIdOnVnfm", response.getBody().getVnfInstanceId());
assertEquals("123456", response.getBody().getVnfLcmOpOccId());
- InlineResponse201VimConnections vimConnections = response.getBody().getVimConnections().get(0);
+ final InlineResponse201VimConnections vimConnections = response.getBody().getVimConnections().get(0);
assertEquals(vimConnectionId, vimConnections.getVimId());
assertEquals("OPENSTACK", vimConnections.getVimType());
assertNotNull(vimConnections.getAccessInfo());
@@ -120,17 +125,18 @@ public class Sol003GrantControllerTest {
@Test
public void grantRequest_ValidRequestTerminate_GrantApproved() {
- GrantRequest grantRequest = createGrantRequest("TERMINATE");
+ final GrantRequest grantRequest = createGrantRequest("TERMINATE");
setUpGenericVnfWithVnfmRelationshipInMockAai("vnfmType", "vnfm1");
final ResponseEntity<InlineResponse201> response = controller.grantsPost(grantRequest);
assertEquals(HttpStatus.CREATED, response.getStatusCode());
- assertEquals(1, response.getBody().getAddResources().size());
- assertEquals(vimConnectionId, response.getBody().getAddResources().get(0).getVimConnectionId());
- assertEquals("myTestVnfId", response.getBody().getVnfInstanceId());
+ assertNull(response.getBody().getAddResources());
+ assertEquals(1, response.getBody().getRemoveResources().size());
+ assertEquals(vimConnectionId, response.getBody().getRemoveResources().get(0).getVimConnectionId());
+ assertEquals("myTestVnfIdOnVnfm", response.getBody().getVnfInstanceId());
assertEquals("123456", response.getBody().getVnfLcmOpOccId());
- InlineResponse201VimConnections vimConnections = response.getBody().getVimConnections().get(0);
+ final InlineResponse201VimConnections vimConnections = response.getBody().getVimConnections().get(0);
assertEquals(vimConnectionId, vimConnections.getVimId());
assertEquals("OPENSTACK", vimConnections.getVimType());
assertNotNull(vimConnections.getAccessInfo());
@@ -139,19 +145,21 @@ public class Sol003GrantControllerTest {
}
- private GrantRequest createGrantRequest(String operation) {
- GrantRequest grantRequest = new GrantRequest();
- grantRequest.setVnfInstanceId("myTestVnfId");
+ private GrantRequest createGrantRequest(final String operation) {
+ final GrantRequest grantRequest = new GrantRequest();
+ grantRequest.setVnfInstanceId("myTestVnfIdOnVnfm");
grantRequest.setVnfLcmOpOccId("123456");
+ grantRequest.links(new GrantsLinks()
+ .vnfInstance(new GrantsLinksVnfLcmOpOcc().href("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm")));
if (operation == "INSTANTIATE") {
grantRequest.setOperation(OperationEnum.INSTANTIATE);
- GrantsAddResources resource = new GrantsAddResources();
+ final GrantsAddResources resource = new GrantsAddResources();
resource.setId("123");
resource.setType(TypeEnum.COMPUTE);
grantRequest.addAddResourcesItem(resource);
} else if (operation == "TERMINATE") {
grantRequest.setOperation(OperationEnum.TERMINATE);
- GrantsAddResources resource = new GrantsAddResources();
+ final GrantsAddResources resource = new GrantsAddResources();
resource.setId("123");
resource.setType(TypeEnum.COMPUTE);
grantRequest.addRemoveResourcesItem(resource);
@@ -210,6 +218,14 @@ public class Sol003GrantControllerTest {
doReturn(Optional.of(genericVnf)).when(aaiResourcesClient).get(eq(GenericVnf.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher("/network/generic-vnfs/generic-vnf/myTestVnfId")));
+
+ final List<GenericVnf> listOfGenericVnfs = new ArrayList<>();
+ listOfGenericVnfs.add(genericVnf);
+ final GenericVnfs genericVnfs = new GenericVnfs();
+ genericVnfs.getGenericVnf().addAll(listOfGenericVnfs);
+ doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class),
+ MockitoHamcrest.argThat(new AaiResourceUriMatcher(
+ "/network/generic-vnfs?selflink=http%3A%2F%2Fvnfm%3A8080%2Fvnfs%2FmyTestVnfIdOnVnfm")));
}
private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> {
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
index 66e8e99f72..aeb7cd3540 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
@@ -20,7 +20,25 @@
package org.onap.so.adapters.vnfmadapter.rest;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
import com.google.gson.Gson;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import javax.inject.Inject;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Before;
@@ -29,7 +47,10 @@ import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.hamcrest.MockitoHamcrest;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
+import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
@@ -64,24 +85,6 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
-import javax.inject.Inject;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.timeout;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
-import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
-import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -166,9 +169,11 @@ public class Sol003LcnControllerTest {
.andRespond(withSuccess(gson.toJson(vnfInstance), MediaType.APPLICATION_JSON));
final GenericVnf genericVnf = createGenericVnf("vnfmType1");
- final List<GenericVnf> genericVnfs = new ArrayList<>();
- genericVnfs.add(genericVnf);
- doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(List.class),
+ final List<GenericVnf> listOfGenericVnfs = new ArrayList<>();
+ listOfGenericVnfs.add(genericVnf);
+ final GenericVnfs genericVnfs = new GenericVnfs();
+ genericVnfs.getGenericVnf().addAll(listOfGenericVnfs);
+ doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher(
"/network/generic-vnfs?selflink=http%3A%2F%2Fvnfm%3A8080%2Fvnfs%2FmyTestVnfIdOnVnfm")));
@@ -176,23 +181,27 @@ public class Sol003LcnControllerTest {
controller.lcnVnfLcmOperationOccurrenceNotificationPost(vnfLcmOperationOccurrenceNotification);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
- final ArgumentCaptor<Object> bodyArgument = ArgumentCaptor.forClass(Object.class);
- final ArgumentCaptor<AAIResourceUri> uriArgument = ArgumentCaptor.forClass(AAIResourceUri.class);
+ final ArgumentCaptor<Object> bodyArgument1 = ArgumentCaptor.forClass(Object.class);
+ final ArgumentCaptor<AAIResourceUri> uriArgument1 = ArgumentCaptor.forClass(AAIResourceUri.class);
- verify(aaiResourcesClient, timeout(1000).times(2)).update(uriArgument.capture(), bodyArgument.capture());
+ verify(aaiResourcesClient, timeout(1000)).update(uriArgument1.capture(), bodyArgument1.capture());
assertEquals("/network/generic-vnfs/generic-vnf/myTestVnfId",
- uriArgument.getAllValues().get(0).build().toString());
- final GenericVnf updatedGenericVnf = (GenericVnf) bodyArgument.getAllValues().get(0);
+ uriArgument1.getAllValues().get(0).build().toString());
+ final GenericVnf updatedGenericVnf = (GenericVnf) bodyArgument1.getAllValues().get(0);
assertEquals("10.10.10.10", updatedGenericVnf.getIpv4OamAddress());
assertEquals("Created", updatedGenericVnf.getOrchestrationStatus());
+ final ArgumentCaptor<Object> bodyArgument2 = ArgumentCaptor.forClass(Object.class);
+ final ArgumentCaptor<AAIResourceUri> uriArgument2 = ArgumentCaptor.forClass(AAIResourceUri.class);
+ verify(aaiResourcesClient, timeout(1000)).create(uriArgument2.capture(), bodyArgument2.capture());
+
assertEquals(
"/cloud-infrastructure/cloud-regions/cloud-region/" + CLOUD_OWNER + "/" + REGION + "/tenants/tenant/"
+ TENANT_ID + "/vservers/vserver/myVnfc1",
- uriArgument.getAllValues().get(1).build().toString());
+ uriArgument2.getAllValues().get(0).build().toString());
- final Vserver vserver = (Vserver) bodyArgument.getAllValues().get(1);
+ final Vserver vserver = (Vserver) bodyArgument2.getAllValues().get(0);
assertEquals("myVnfc1", vserver.getVserverId());
final Relationship relationship = vserver.getRelationshipList().getRelationship().get(0);
assertEquals("generic-vnf", relationship.getRelatedTo());
@@ -214,13 +223,17 @@ public class Sol003LcnControllerTest {
.andRespond(withSuccess(gson.toJson(vnfInstance), MediaType.APPLICATION_JSON));
mockRestServer.expect(requestTo(new URI("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm")))
- .andRespond(withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON));
+ .andRespond(withStatus(HttpStatus.NO_CONTENT).contentType(MediaType.APPLICATION_JSON));
final GenericVnf genericVnf = createGenericVnf("vnfmType1");
genericVnf.setSelflink("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm");
- final List<GenericVnf> genericVnfs = new ArrayList<>();
- genericVnfs.add(genericVnf);
- doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(List.class),
+ final List<GenericVnf> listOfGenericVnfs = new ArrayList<>();
+ listOfGenericVnfs.add(genericVnf);
+ final GenericVnfs genericVnfs = new GenericVnfs();
+ genericVnfs.getGenericVnf().addAll(listOfGenericVnfs);
+ addRelationshipFromGenericVnfToVserver(genericVnf, "myVnfc1");
+
+ doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher(
"/network/generic-vnfs?selflink=http%3A%2F%2Fvnfm%3A8080%2Fvnfs%2FmyTestVnfIdOnVnfm")));
@@ -310,6 +323,31 @@ public class Sol003LcnControllerTest {
return genericVnf;
}
+ private void addRelationshipFromGenericVnfToVserver(final GenericVnf genericVnf, final String vserverId) {
+ final Relationship relationshipToVserver = new Relationship();
+ relationshipToVserver.setRelatedTo("vserver");
+ final RelationshipData relationshipData1 = new RelationshipData();
+ relationshipData1.setRelationshipKey("vserver.vserver-id");
+ relationshipData1.setRelationshipValue(vserverId);
+ relationshipToVserver.getRelationshipData().add(relationshipData1);
+ final RelationshipData relationshipData2 = new RelationshipData();
+ relationshipData2.setRelationshipKey("cloud-region.cloud-owner");
+ relationshipData2.setRelationshipValue(CLOUD_OWNER);
+ relationshipToVserver.getRelationshipData().add(relationshipData2);
+ final RelationshipData relationshipData3 = new RelationshipData();
+ relationshipData3.setRelationshipKey("cloud-region.cloud-region-id");
+ relationshipData3.setRelationshipValue(REGION);
+ relationshipToVserver.getRelationshipData().add(relationshipData3);
+ final RelationshipData relationshipData4 = new RelationshipData();
+ relationshipData4.setRelationshipKey("tenant.tenant-id");
+ relationshipData4.setRelationshipValue(TENANT_ID);
+ relationshipToVserver.getRelationshipData().add(relationshipData4);
+
+ final RelationshipList relationshipList = new RelationshipList();
+ relationshipList.getRelationship().add(relationshipToVserver);
+ genericVnf.setRelationshipList(relationshipList);
+ }
+
private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> {
final String uriAsString;
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java
index 20a074b2ba..73a49e9c40 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java
@@ -20,7 +20,21 @@
package org.onap.so.adapters.vnfmadapter.rest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withBadRequest;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
import com.google.gson.Gson;
+import java.net.URI;
+import java.util.Optional;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Before;
@@ -36,24 +50,23 @@ import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
+import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
+import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201Links;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201LinksSelf;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.CreateVnfResponse;
import org.onap.vnfmadapter.v1.model.DeleteVnfResponse;
import org.onap.vnfmadapter.v1.model.OperationEnum;
import org.onap.vnfmadapter.v1.model.OperationStateEnum;
import org.onap.vnfmadapter.v1.model.QueryJobResponse;
-import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
-import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.Tenant;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
@@ -72,18 +85,6 @@ import org.springframework.web.client.RestTemplate;
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZoneOffset;
-import java.net.URI;
-import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
-import static org.springframework.test.web.client.response.MockRestResponseCreators.*;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -131,7 +132,7 @@ public class VnfmAdapterControllerTest {
setUpVimInMockAai();
final String expectedsubscriptionRequest =
- "{\"filter\":{\"vnfInstanceSubscriptionFilter\":{\"vnfInstanceIds\":[\"vnfId\"]},\"notificationTypes\":[\"VnfLcmOperationOccurrenceNotification\"]},\"callbackUri\":\"https://so-vnfm-adapter.onap:30406/so/vnfm-adapter/v1/lcn/VnfLcmOperationOccurrenceNotification\",\"authentication\":{\"authType\":[\"BASIC\"],\"paramsBasic\":{\"userName\":\"vnfm\",\"password\":\"$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke\"}}}";
+ "{\"filter\":{\"vnfInstanceSubscriptionFilter\":{\"vnfInstanceIds\":[\"vnfId\"]},\"notificationTypes\":[\"VnfLcmOperationOccurrenceNotification\"]},\"callbackUri\":\"https://so-vnfm-adapter.onap:30406/so/vnfm-adapter/v1/lcn/VnfLcmOperationOccurrenceNotification\",\"authentication\":{\"authType\":[\"BASIC\"],\"paramsBasic\":{\"userName\":\"vnfm\",\"password\":\"password1$\"}}}";
final InlineResponse2001 subscriptionResponse = new InlineResponse2001();
final InlineResponse201 createResponse = createCreateResponse();
diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml
index 8317b660a6..60c517d944 100644
--- a/asdc-controller/pom.xml
+++ b/asdc-controller/pom.xml
@@ -16,8 +16,8 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<antlr.version>4.7.1</antlr.version>
<java.version>1.8</java.version>
- <sdc.tosca.version>1.5.0</sdc.tosca.version>
- <jtosca.version>1.5.0</jtosca.version>
+ <sdc.tosca.version>1.5.1</sdc.tosca.version>
+ <jtosca.version>1.5.1</jtosca.version>
</properties>
<build>
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 4e97b5f290..ad3e2d8161 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -85,6 +85,7 @@ import org.onap.so.db.catalog.beans.HeatEnvironment;
import org.onap.so.db.catalog.beans.HeatFiles;
import org.onap.so.db.catalog.beans.HeatTemplate;
import org.onap.so.db.catalog.beans.HeatTemplateParam;
+import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.InstanceGroupType;
import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.NetworkInstanceGroup;
@@ -1180,6 +1181,8 @@ public class ToscaResourceInstaller {
vfModuleArtifact.getArtifactInfo().getArtifactUUID());
heatTemplate.setParameters(heatParam);
vfModuleArtifact.setHeatTemplate(heatTemplate);
+ } else {
+ vfModuleArtifact.setHeatTemplate(existingHeatTemplate);
}
}
@@ -1208,6 +1211,8 @@ public class ToscaResourceInstaller {
heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
}
vfModuleArtifact.setHeatEnvironment(heatEnvironment);
+ } else {
+ vfModuleArtifact.setHeatEnvironment(existingHeatEnvironment);
}
}
@@ -1232,7 +1237,8 @@ public class ToscaResourceInstaller {
heatFile.setArtifactChecksum(MANUAL_RECORD);
}
vfModuleArtifact.setHeatFiles(heatFile);
-
+ } else {
+ vfModuleArtifact.setHeatFiles(existingHeatFiles);
}
}
@@ -1724,16 +1730,25 @@ public class ToscaResourceInstaller {
VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) {
Metadata instanceMetadata = group.getMetadata();
- // Populate InstanceGroup
+
+ InstanceGroup existingInstanceGroup =
+ instanceGroupRepo.findByModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
- vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- vfcInstanceGroup.setToscaNodeType(group.getType());
- vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
- vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
+ if (existingInstanceGroup == null) {
+ // Populate InstanceGroup
+ vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ vfcInstanceGroup
+ .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ vfcInstanceGroup.setToscaNodeType(group.getType());
+ vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
+ vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
+ } else {
+ vfcInstanceGroup = (VFCInstanceGroup) existingInstanceGroup;
+ }
// Populate VNFCInstanceGroupCustomization
VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml
index 891a57d0f2..20be69c006 100644
--- a/bpmn/MSOCommonBPMN/pom.xml
+++ b/bpmn/MSOCommonBPMN/pom.xml
@@ -364,16 +364,6 @@
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
- <groupId>org.onap.sdc.sdc-tosca</groupId>
- <artifactId>sdc-tosca</artifactId>
- <version>1.4.4</version>
- </dependency>
- <dependency>
- <groupId>org.onap.sdc.jtosca</groupId>
- <artifactId>jtosca</artifactId>
- <version>1.4.4</version>
- </dependency>
- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
diff --git a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
index 8e6ebab43a..a627e82802 100644
--- a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
+++ b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
@@ -96,7 +96,7 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider {
private <T> Optional<T> createOptional(final ResponseEntity<T> response, final String url,
final HttpMethod httpMethod) {
- if (!response.getStatusCode().equals(HttpStatus.OK)) {
+ if (!response.getStatusCode().equals(HttpStatus.OK) && !response.getStatusCode().equals(HttpStatus.CREATED)) {
final String message = "Unable to invoke HTTP " + httpMethod + " using URL: " + url + ", Response Code: "
+ response.getStatusCode();
LOGGER.error(message);
diff --git a/docs/architecture/SO Internal Arc.pptx b/docs/architecture/SO Internal Arc.pptx
index bff3e352e0..ee4b112b3b 100644
--- a/docs/architecture/SO Internal Arc.pptx
+++ b/docs/architecture/SO Internal Arc.pptx
Binary files differ
diff --git a/vnfm-simulator/vnf-service/pom.xml b/vnfm-simulator/vnf-service/pom.xml
deleted file mode 100644
index 9a6825cf43..0000000000
--- a/vnfm-simulator/vnf-service/pom.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.vnfm</groupId>
- <artifactId>vnfm-simulator</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>vnf-service</artifactId>
-
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <java.version>1.8</java.version>
- </properties>
-
- <dependencies>
-
- <dependency>
- <groupId>org.onap.vnfm</groupId>
- <artifactId>vnfm-api</artifactId>
- <version>${project.version}</version>
-
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-jaxrs</artifactId>
- <version>1.5.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.directory.studio</groupId>
- <artifactId>org.apache.commons.io</artifactId>
- <version>2.4</version>
- </dependency>
- <dependency>
- <groupId>com.googlecode.json-simple</groupId>
- <artifactId>json-simple</artifactId>
- <version>1.1.1</version>
- </dependency>
-
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger-ui</artifactId>
- <version>2.6.1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>2.6.1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.9.8</version>
- </dependency>
-
- </dependencies>
-</project> \ No newline at end of file
diff --git a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java b/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java
deleted file mode 100644
index b9703b3a13..0000000000
--- a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.svnfm.simulator.controller;
-
-import javax.ws.rs.core.MediaType;
-
-import org.onap.svnfm.simulator.services.SvnfmService;
-import org.onap.vnfm.v1.model.CreateVnfRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * This class contains the VNF life cycle management operations
- *
- * @author ronan.kenny@est.tech
- *
- */
-
-/**
- * TO DO
- *
- * Implement Exception handling Implement VNFM adaptor call Identify the Create
- * VNF response Test itwith the VNFM Adaptor
- */
-
-@RestController
-@RequestMapping("/svnfm")
-
-public class SvnfmController {
-
- @Autowired
- private SvnfmService svnfmService;
-
- private static final Logger LOGGER = LoggerFactory.getLogger(SvnfmController.class);
-
- @RequestMapping(method = RequestMethod.POST, value = "/vnf_instances")
- public ResponseEntity<Object> createVNFInstance(@RequestBody final CreateVnfRequest createVNFRequest) {
- LOGGER.info("Start createVNFInstance");
- HttpHeaders headers = new HttpHeaders();
- headers.add("Content-Type", MediaType.APPLICATION_JSON);
- return new ResponseEntity<>(svnfmService.createVNF(), headers, HttpStatus.CREATED);
- }
-}
diff --git a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmHealthcheck.java b/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmHealthcheck.java
deleted file mode 100644
index e6f55f6c5d..0000000000
--- a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmHealthcheck.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.svnfm.simulator.controller;
-
-import org.onap.svnfm.simulator.exception.InvalidRestRequestException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-
-/**
- * TO DO
- *
- * Implement Exception handling
- * Implement VNFM adaptor call
- * Identify the Create VNF response
- * Test it with the VNFM Adaptor
- */
-
-@RestController
-@RequestMapping("/svnfm")
-public class SvnfmHealthcheck {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(SvnfmHealthcheck.class);
-
- @RequestMapping(method = RequestMethod.GET, value = "/healthcheck")
- public ResponseEntity<String> healthCheck() {
- try {
- return new ResponseEntity<>(HttpStatus.OK);
- } catch (final InvalidRestRequestException extensions) {
- final String message = "Not Found";
- LOGGER.error(message);
- return new ResponseEntity<>(message, HttpStatus.NOT_FOUND);
- }
- }
-}
diff --git a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/GlobalExceptionHandler.java b/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/GlobalExceptionHandler.java
deleted file mode 100644
index a06f2d22ad..0000000000
--- a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/GlobalExceptionHandler.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.onap.svnfm.simulator.exception;
-
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.http.converter.HttpMessageNotReadableException;
-import org.springframework.web.HttpMediaTypeNotSupportedException;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.context.request.WebRequest;
-import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
-
-@ControllerAdvice
-public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
- @Override
- protected ResponseEntity<Object> handleHttpMessageNotReadable(HttpMessageNotReadableException ex,
- HttpHeaders headers, HttpStatus status, WebRequest request) {
- String error = "Malformed JSON request";
- return new ResponseEntity<>(error, HttpStatus.BAD_REQUEST);
- }
-
- @Override
- protected ResponseEntity<Object> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex,
- HttpHeaders headers, HttpStatus status, WebRequest request) {
- String error = "Media type Not Supported";
- return new ResponseEntity<>(error, HttpStatus.UNSUPPORTED_MEDIA_TYPE);
- }
-}
diff --git a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/InvalidRestRequestException.java b/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/InvalidRestRequestException.java
deleted file mode 100644
index eabd4ec414..0000000000
--- a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/InvalidRestRequestException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.svnfm.simulator.exception;
-
-/**
- * @author ronan.kenny@est.tech
- *
- */
-public class InvalidRestRequestException extends RuntimeException {
-
- private static final long serialVersionUID = 3977807111893986938L;
-
- public InvalidRestRequestException(final String message) {
- super(message);
- }
-
- public InvalidRestRequestException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/RestProcessingException.java b/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/RestProcessingException.java
deleted file mode 100644
index c84416e245..0000000000
--- a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/exception/RestProcessingException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.svnfm.simulator.exception;
-
-/**
- * @author ronan.kenny@est.tech
- *
- */
-public class RestProcessingException extends RuntimeException {
-
- private static final long serialVersionUID = 16862313537198441L;
-
- public RestProcessingException(final String message) {
- super(message);
- }
-
- public RestProcessingException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java b/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java
deleted file mode 100644
index e2dc43a24b..0000000000
--- a/vnfm-simulator/vnf-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Ericsson. All rights reserved.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.svnfm.simulator.services;
-
-import java.io.IOException;
-
-import org.apache.commons.io.IOUtils;
-import org.onap.svnfm.simulator.notifications.VnfmAdapterCreationNotification;
-import org.onap.vnfm.v1.model.InlineResponse201;
-import org.springframework.stereotype.Service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * This class handles the logic of VNF lifecycle
- *
- * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
- *
- */
-@Service
-public class SvnfmService {
-
- /**
- * This method read the create VNF response from the json file and return it
- * to the VNFM Adaptor
- *
- * @return
- */
- public InlineResponse201 createVNF() {
- Thread creationNodtification = new Thread(new VnfmAdapterCreationNotification());
- creationNodtification.start();
- ObjectMapper mapper = new ObjectMapper();
- InlineResponse201 inlineResponse201 = null;
- try {
- inlineResponse201 = mapper.readValue(
- IOUtils.toString(getClass().getClassLoader().getResource("json/createVNFResponse.json")),
- InlineResponse201.class);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return inlineResponse201;
- }
-}
diff --git a/vnfm-simulator/vnf-service/src/main/resources/json/createVNFResponse.json b/vnfm-simulator/vnf-service/src/main/resources/json/createVNFResponse.json
deleted file mode 100644
index a66bcc1334..0000000000
--- a/vnfm-simulator/vnf-service/src/main/resources/json/createVNFResponse.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "id": "147d9468-4646-11e9-80af-fa163e169afd",
- "vnfInstanceName": "MME85_8.EricssonMMEVSPV2_0",
- "vnfInstanceDescription": "2f3e21dd-99ba-45b1-b4da-1f71283c46f6",
- "vnfdId": "sgsn-mme_onapmme01_cxp9025898_4r85d01",
- "vnfProvider": "Ericsson",
- "vnfProductName": "SGSN-MME",
- "vnfSoftwareVersion": "1.24 (CXS101289_R85D01)",
- "vnfdVersion": "onapmme01_cxp9025898_4r85d01",
- "vnfPkgId": null,
- "vnfConfigurableProperties": null,
- "vimConnectionInfo": null,
- "instantiationState": "NOT_INSTANTIATED",
- "instantiatedVnfInfo": null,
- "metadata": null,
- "extensions": null,
- "links": null
-
-}
diff --git a/vnfm-simulator/vnfm-service/pom.xml b/vnfm-simulator/vnfm-service/pom.xml
index 3f4f4512b3..380381f53b 100644
--- a/vnfm-simulator/vnfm-service/pom.xml
+++ b/vnfm-simulator/vnfm-service/pom.xml
@@ -1,116 +1,149 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.so.vnfm</groupId>
- <artifactId>vnfm-simulator</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- </parent>
- <artifactId>vnfm-service</artifactId>
- <name>${project.artifactId}</name>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.so.vnfm</groupId>
+ <artifactId>vnfm-simulator</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>vnfm-service</artifactId>
+ <name>${project.artifactId}</name>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <java.version>1.8</java.version>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.onap.so.vnfm</groupId>
- <artifactId>vnfm-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-devtools</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-jaxrs</artifactId>
- <version>1.5.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.directory.studio</groupId>
- <artifactId>org.apache.commons.io</artifactId>
- <version>2.4</version>
- </dependency>
- <dependency>
- <groupId>com.googlecode.json-simple</groupId>
- <artifactId>json-simple</artifactId>
- <version>1.1.1</version>
- </dependency>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <java.version>1.8</java.version>
+ <okhttp-version>2.7.5</okhttp-version>
+ <gson-version>2.8.1</gson-version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.so.adapters</groupId>
+ <artifactId>mso-vnfm-adapter-ext-clients</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-devtools</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jaxrs</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.studio</groupId>
+ <artifactId>org.apache.commons.io</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>com.googlecode.json-simple</groupId>
+ <artifactId>json-simple</artifactId>
+ <version>1.1.1</version>
+ </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger-ui</artifactId>
- <version>2.6.1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>2.6.1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.9.8</version>
- </dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- </dependency>
- <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.9.3</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>${springboot.version}</version>
- <configuration>
- <mainClass>org.onap.svnfm.simulator.config.SvnfmApplication</mainClass>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project> \ No newline at end of file
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ <version>2.6.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <version>2.6.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.9.8</version>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+ <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.9.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.modelmapper</groupId>
+ <artifactId>modelmapper</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okio</groupId>
+ <artifactId>okio</artifactId>
+ <version>1.13.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp</groupId>
+ <artifactId>okhttp</artifactId>
+ <version>${okhttp-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp</groupId>
+ <artifactId>logging-interceptor</artifactId>
+ <version>${okhttp-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${gson-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${springboot.version}</version>
+ <configuration>
+ <mainClass>org.onap.svnfm.simulator.config.SvnfmApplication</mainClass>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/ApplicationConfig.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/ApplicationConfig.java
new file mode 100644
index 0000000000..91b79754a5
--- /dev/null
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/ApplicationConfig.java
@@ -0,0 +1,43 @@
+package org.onap.svnfm.simulator.config;
+
+import java.net.InetAddress;
+import java.util.Arrays;
+import org.onap.svnfm.simulator.constants.Constant;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.concurrent.ConcurrentMapCache;
+import org.springframework.cache.support.SimpleCacheManager;
+import org.springframework.context.annotation.Bean;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ApplicationConfig implements ApplicationRunner {
+
+ private static final String PORT = "local.server.port";
+
+ @Autowired
+ private Environment environment;
+
+ private String baseUrl;
+
+ @Override
+ public void run(final ApplicationArguments args) throws Exception {
+ baseUrl = "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + environment.getProperty(PORT);
+ }
+
+ public String getBaseUrl() {
+ return baseUrl;
+ }
+
+ @Bean
+ public CacheManager cacheManager() {
+ Cache inlineResponse201 = new ConcurrentMapCache(Constant.IN_LINE_RESPONSE_201_CACHE);
+ SimpleCacheManager manager = new SimpleCacheManager();
+ manager.setCaches(Arrays.asList(inlineResponse201));
+ return manager;
+ }
+}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/SvnfmApplication.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/SvnfmApplication.java
index 84b45d0bac..723ae906e6 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/SvnfmApplication.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/SvnfmApplication.java
@@ -20,6 +20,7 @@
package org.onap.svnfm.simulator.config;
+import org.onap.svnfm.simulator.controller.SvnfmController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
@@ -27,7 +28,10 @@ import org.springframework.cache.annotation.EnableCaching;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
/**
- *
+ * The spring boot application for the VNF LCM.
+ * <p>
+ * The VNFM receives requests through its REST API {@link SvnfmController}
+ *
* @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
* @author ronan.kenny@est.tech
*/
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/WebSecurityConfigImpl.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/WebSecurityConfigImpl.java
new file mode 100644
index 0000000000..18eadd2fc3
--- /dev/null
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/config/WebSecurityConfigImpl.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.svnfm.simulator.config;
+
+import org.onap.so.security.MSOSpringFirewall;
+import org.onap.so.security.WebSecurityConfig;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.builders.WebSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.web.firewall.StrictHttpFirewall;
+
+/**
+ * Configure the web security for the application.
+ */
+@EnableWebSecurity
+public class WebSecurityConfigImpl extends WebSecurityConfig {
+
+ @Override
+ protected void configure(final HttpSecurity http) throws Exception {
+ http.csrf().disable().authorizeRequests().antMatchers("/**").permitAll();
+ }
+
+ @Override
+ public void configure(final WebSecurity web) throws Exception {
+ super.configure(web);
+ final StrictHttpFirewall firewall = new MSOSpringFirewall();
+ web.httpFirewall(firewall);
+ }
+
+}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/constants/Constant.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/constants/Constant.java
index bd380903d5..98f47bf455 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/constants/Constant.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/constants/Constant.java
@@ -27,9 +27,13 @@ package org.onap.svnfm.simulator.constants;
*/
public class Constant {
+ public static final String BASE_URL = "/vnflcm/v1";
public static final String VNF_PROVIDER = "XYZ";
- public static final String VNF_PROVIDER_NAME = "SGSN-MME";
+ public static final String VNF_PROVIDER_NAME = "vCPE";
public static final String VNF_SOFTWARE_VERSION = "1.24";
- public static final String VNFD_VERSION = "onapmme01_cxp9025898_4r85d01";
+ public static final String VNFD_VERSION = "onapvcpe01_cxp9025898_4r85d01";
public static final String VNF_NOT_INSTANTIATED = "NOT_INSTANTIATED";
+ public static final String VNF_CONFIG_PROPERTIES =
+ "{\"isAutoScaleEnabled\": \"true\",\"isAutoHealingEnabled\": \"true\"}";
+ public static final String IN_LINE_RESPONSE_201_CACHE = "inlineResponse201";
}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java
index 11099a24fc..9c3a02d4e6 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java
@@ -22,30 +22,37 @@ package org.onap.svnfm.simulator.controller;
import java.util.UUID;
import javax.ws.rs.core.MediaType;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
+import org.onap.svnfm.simulator.constants.Constant;
import org.onap.svnfm.simulator.repository.VnfmCacheRepository;
import org.onap.svnfm.simulator.services.SvnfmService;
-import org.onap.vnfm.v1.model.CreateVnfRequest;
-import org.onap.vnfm.v1.model.InlineResponse201;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
/**
- *
+ *
* @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
* @author Ronan Kenny (ronan.kenny@est.tech)
*/
@RestController
-@RequestMapping("/svnfm")
+@RequestMapping(path = Constant.BASE_URL, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
public class SvnfmController {
@Autowired
@@ -57,25 +64,30 @@ public class SvnfmController {
private static final Logger LOGGER = LoggerFactory.getLogger(SvnfmController.class);
/**
- *
- * @param createVNFRequest
- * @return
+ * To create the Vnf and stores the response in cache
+ *
+ * @param CreateVnfRequest
+ * @return InlineResponse201
*/
- @RequestMapping(method = RequestMethod.POST, value = "/vnf_instances")
+ @PostMapping(value = "/vnf_instances")
public ResponseEntity<InlineResponse201> createVnf(@RequestBody final CreateVnfRequest createVNFRequest) {
- LOGGER.info("Start createVnf------");
+ LOGGER.info("Start createVnf {}", createVNFRequest);
+ final String id = UUID.randomUUID().toString();
final HttpHeaders headers = new HttpHeaders();
- headers.add("Content-Type", MediaType.APPLICATION_JSON);
- return new ResponseEntity<>(vnfmCacheRepository.createVnf(createVNFRequest), headers, HttpStatus.CREATED);
+ headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ final ResponseEntity<InlineResponse201> responseEntity =
+ new ResponseEntity<>(vnfmCacheRepository.createVnf(createVNFRequest, id), headers, HttpStatus.CREATED);
+ LOGGER.info("Finished create {}", responseEntity);
+ return responseEntity;
}
/**
- *
+ * Get the vnf by id from cache
+ *
* @param vnfId
- * @return vnfm cache repository
+ * @return InlineResponse201
*/
- @RequestMapping(method = RequestMethod.GET, value = "/vnf_instances/{vnfInstanceId}",
- produces = MediaType.APPLICATION_JSON)
+ @GetMapping(value = "/vnf_instances/{vnfInstanceId}")
@ResponseStatus(code = HttpStatus.OK)
public InlineResponse201 getVnf(@PathVariable("vnfInstanceId") final String vnfId) {
LOGGER.info("Start getVnf------");
@@ -83,60 +95,79 @@ public class SvnfmController {
}
/**
- *
+ * To instantiate the vnf and returns the operation id
+ *
* @param vnfId
- * @return response entity
* @throws InterruptedException
*/
- @RequestMapping(method = RequestMethod.POST, value = "/vnf_instances/{vnfInstanceId}/instantiate")
- public ResponseEntity<Object> instantiateVnf(@PathVariable("vnfInstanceId") final String vnfId)
- throws InterruptedException {
- LOGGER.info("Start instantiateVNFRequest");
- final String instantiateJobId = UUID.randomUUID().toString();
+ @PostMapping(value = "/vnf_instances/{vnfInstanceId}/instantiate")
+ public ResponseEntity<Void> instantiateVnf(@PathVariable("vnfInstanceId") final String vnfId,
+ @RequestBody final InstantiateVnfRequest instantiateVNFRequest) {
+ LOGGER.info("Start instantiateVNFRequest {} ", instantiateVNFRequest);
+
final HttpHeaders headers = new HttpHeaders();
- headers.add("Content-Type", MediaType.APPLICATION_JSON);
- headers.add("Location", instantiateJobId);
- return new ResponseEntity<>(svnfmService.instatiateVnf(vnfId, instantiateJobId), headers, HttpStatus.ACCEPTED);
+ headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ headers.add(HttpHeaders.LOCATION, svnfmService.instantiateVnf(vnfId, instantiateVNFRequest));
+ return new ResponseEntity<>(headers, HttpStatus.ACCEPTED);
}
/**
- *
- * @param jobId
- * @return response entity
- * @throws InterruptedException
+ * To delete the vnf by id
+ *
+ * @param vnfId
+ * @return InlineResponse201
*/
- public ResponseEntity<Object> getJobStatus(@PathVariable("jobId") final String jobId) throws InterruptedException {
- LOGGER.info("Start getJobStatus");
+ @DeleteMapping(value = "/vnf_instances/{vnfInstanceId}")
+ @ResponseStatus(code = HttpStatus.OK)
+ public ResponseEntity<Void> deleteVnf(@PathVariable("vnfInstanceId") final String vnfId) {
+ LOGGER.info("Start deleting Vnf------");
+ vnfmCacheRepository.deleteVnf(vnfId);
final HttpHeaders headers = new HttpHeaders();
- headers.add("Content-Type", MediaType.APPLICATION_JSON);
- return new ResponseEntity<>(svnfmService.getJobStatus(jobId), headers, HttpStatus.ACCEPTED);
+ headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ return new ResponseEntity<>(headers, HttpStatus.NO_CONTENT);
}
/**
- *
+ * To terminate the vnf by id
+ *
* @param vnfId
- * @return delete VNF
+ * @throws InterruptedException
*/
- @RequestMapping(method = RequestMethod.DELETE, value = "/vnf_instances/{vnfInstanceId}",
- produces = MediaType.APPLICATION_JSON)
- @ResponseStatus(code = HttpStatus.OK)
- public InlineResponse201 deleteVnf(@PathVariable("vnfInstanceId") final String vnfId) {
- LOGGER.info("Start deleting Vnf------");
- return vnfmCacheRepository.deleteVnf(vnfId);
+ @PostMapping(value = "/vnf_instances/{vnfInstanceId}/terminate")
+ public ResponseEntity<Object> terminateVnf(@PathVariable("vnfInstanceId") final String vnfId) {
+ LOGGER.info("Start terminateVNFRequest {}", vnfId);
+ final HttpHeaders headers = new HttpHeaders();
+ headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ headers.add(HttpHeaders.LOCATION, svnfmService.terminateVnf(vnfId));
+ return new ResponseEntity<>(headers, HttpStatus.ACCEPTED);
}
+
/**
- *
- * @param vnfId
+ * To get the status of the operation by id
+ *
+ * @param operationId
* @return response entity
* @throws InterruptedException
*/
- @RequestMapping(method = RequestMethod.POST, value = "/vnf_instances/{vnfInstanceId}/terminate")
- public ResponseEntity<Object> terminateVnf(@PathVariable("vnfInstanceId") final String vnfId)
- throws InterruptedException {
- LOGGER.info("Start terminateVNFRequest");
+ @GetMapping(value = "/vnf_lcm_op_occs/{vnfLcmOpOccId}")
+ public ResponseEntity<InlineResponse200> getOperationStatus(
+ @PathVariable("vnfLcmOpOccId") final String operationId) {
+ LOGGER.info("Start getOperationStatus");
final HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", MediaType.APPLICATION_JSON);
- return new ResponseEntity<>(svnfmService.terminateVnf(vnfId), headers, HttpStatus.ACCEPTED);
+ return new ResponseEntity<>(svnfmService.getOperationStatus(operationId), headers, HttpStatus.OK);
+ }
+
+ @PostMapping(value = "/subscriptions")
+ public ResponseEntity<InlineResponse2001> subscribeForNotifications(
+ @RequestBody final LccnSubscriptionRequest lccnSubscriptionRequest) {
+ LOGGER.info("Subscription request received: {}", lccnSubscriptionRequest);
+ svnfmService.registerSubscription(lccnSubscriptionRequest);
+ final InlineResponse2001 response = new InlineResponse2001();
+
+ final HttpHeaders headers = new HttpHeaders();
+ headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ return new ResponseEntity<>(response, headers, HttpStatus.OK);
}
}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/model/VnfJob.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/model/VnfOperation.java
index 575223c700..c37f433668 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/model/VnfJob.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/model/VnfOperation.java
@@ -21,30 +21,37 @@ package org.onap.svnfm.simulator.model;
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
/**
- *
+ *
* @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
* @author Ronan Kenny (ronan.kenny@est.tech)
*/
@Entity
-@Table(name = "VNF_JOB")
-public class VnfJob {
+@Table(name = "VNF_OPERATION")
+public class VnfOperation {
@Id
- @Column(name = "jobId", nullable = false)
- private String jobId;
+ @Column(name = "operationId", nullable = false)
+ private String id;
private String vnfInstanceId;
- private String vnfId;
- private String status;
- public String getJobId() {
- return jobId;
+ @Enumerated(EnumType.STRING)
+ private InlineResponse200.OperationEnum operation;
+
+ @Enumerated(EnumType.STRING)
+ private InlineResponse200.OperationStateEnum operationState;
+
+ public String getId() {
+ return id;
}
- public void setJobId(final String jobId) {
- this.jobId = jobId;
+ public void setId(final String id) {
+ this.id = id;
}
public String getVnfInstanceId() {
@@ -55,19 +62,19 @@ public class VnfJob {
this.vnfInstanceId = vnfInstanceId;
}
- public String getVnfId() {
- return vnfId;
+ public InlineResponse200.OperationEnum getOperation() {
+ return operation;
}
- public void setVnfId(final String vnfId) {
- this.vnfId = vnfId;
+ public void setOperation(final InlineResponse200.OperationEnum operation) {
+ this.operation = operation;
}
- public String getStatus() {
- return status;
+ public InlineResponse200.OperationStateEnum getOperationState() {
+ return operationState;
}
- public void setStatus(final String status) {
- this.status = status;
+ public void setOperationState(final InlineResponse200.OperationStateEnum operationState) {
+ this.operationState = operationState;
}
}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/model/Vnfds.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/model/Vnfds.java
new file mode 100644
index 0000000000..ea171f0fce
--- /dev/null
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/model/Vnfds.java
@@ -0,0 +1,97 @@
+package org.onap.svnfm.simulator.model;
+
+import java.util.List;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@ConfigurationProperties(prefix = "vnfds")
+@Component
+public class Vnfds {
+
+ private List<Vnfd> vnfdList;
+
+ public static class Vnfd {
+
+ private String vnfdId;
+ private List<Vnfc> vnfclist;
+
+
+ public String getVnfdId() {
+ return vnfdId;
+ }
+
+ public void setVnfdId(final String vnfdId) {
+ this.vnfdId = vnfdId;
+ }
+
+ public List<Vnfc> getVnfcList() {
+ return vnfclist;
+ }
+
+ public void setVnfcList(final List<Vnfc> vnfclist) {
+ this.vnfclist = vnfclist;
+ }
+ }
+
+
+ public static class Vnfc {
+
+ private String vnfcId;
+ private String type;
+ private String vduId;
+ private String resourceTemplateId;
+ private String grantResourceId;
+
+ public String getVnfcId() {
+ return vnfcId;
+ }
+
+ public void setVnfcId(final String vnfcId) {
+ this.vnfcId = vnfcId;
+ }
+
+ public String getVduId() {
+ return vduId;
+ }
+
+ public void setVduId(final String vduId) {
+ this.vduId = vduId;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ public String getResourceTemplateId() {
+ return resourceTemplateId;
+ }
+
+ public void setResourceTemplateId(final String resourceTemplateId) {
+ this.resourceTemplateId = resourceTemplateId;
+ }
+
+ public String getGrantResourceId() {
+ return grantResourceId;
+ }
+
+ public void setGrantResourceId(final String grantResourceId) {
+ this.grantResourceId = grantResourceId;
+ }
+
+ }
+
+
+ public List<Vnfd> getVnfdList() {
+ return vnfdList;
+ }
+
+
+ public void setVnfdList(final List<Vnfd> vnfdList) {
+ this.vnfdList = vnfdList;
+ }
+
+}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfJobRepository.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfOperationRepository.java
index b3b39bfdf1..43c201734f 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfJobRepository.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfOperationRepository.java
@@ -20,7 +20,7 @@
package org.onap.svnfm.simulator.repository;
-import org.onap.svnfm.simulator.model.VnfJob;
+import org.onap.svnfm.simulator.model.VnfOperation;
import org.springframework.data.repository.CrudRepository;
/**
@@ -28,6 +28,6 @@ import org.springframework.data.repository.CrudRepository;
* @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
* @author Ronan Kenny (ronan.kenny@est.tech)
*/
-public interface VnfJobRepository extends CrudRepository<VnfJob, String> {
+public interface VnfOperationRepository extends CrudRepository<VnfOperation, String> {
}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfmCacheRepository.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfmCacheRepository.java
index e41cbe1e3a..fbdbf744d0 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfmCacheRepository.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfmCacheRepository.java
@@ -20,15 +20,17 @@
package org.onap.svnfm.simulator.repository;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
+import org.onap.svnfm.simulator.constants.Constant;
import org.onap.svnfm.simulator.services.SvnfmService;
-import org.onap.vnfm.v1.model.CreateVnfRequest;
-import org.onap.vnfm.v1.model.InlineResponse201;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;
/**
- *
+ *
* @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
* @author Ronan Kenny (ronan.kenny@est.tech)
*/
@@ -38,12 +40,13 @@ public class VnfmCacheRepository {
@Autowired
private SvnfmService svnfmService;
- @Cacheable(value = "inlineResponse201", key = "#createVnfRequest.vnfdId")
- public InlineResponse201 createVnf(final CreateVnfRequest createVnfRequest) {
- return svnfmService.createVnf(createVnfRequest);
+ @Cacheable(value = Constant.IN_LINE_RESPONSE_201_CACHE, key = "#id")
+ public InlineResponse201 createVnf(final CreateVnfRequest createVnfRequest, final String id) {
+ return svnfmService.createVnf(createVnfRequest, id);
}
- @Cacheable(value = "inlineResponse201", key = "#id")
+
+
public InlineResponse201 getVnf(final String id) {
return svnfmService.getVnf(id);
}
@@ -52,8 +55,6 @@ public class VnfmCacheRepository {
* @param vnfId
* @return
*/
- public InlineResponse201 deleteVnf(String vnfId) {
- // TODO
- return null;
- }
+ @CacheEvict(value = Constant.IN_LINE_RESPONSE_201_CACHE, key = "#id")
+ public void deleteVnf(final String id) {}
}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/InstantiateOperationProgressor.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/InstantiateOperationProgressor.java
new file mode 100644
index 0000000000..020fa0390d
--- /dev/null
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/InstantiateOperationProgressor.java
@@ -0,0 +1,123 @@
+package org.onap.svnfm.simulator.services;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.modelmapper.ModelMapper;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources.TypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201AddResources;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoResourceHandle;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoVnfcResourceInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo;
+import org.onap.svnfm.simulator.config.ApplicationConfig;
+import org.onap.svnfm.simulator.model.VnfOperation;
+import org.onap.svnfm.simulator.model.Vnfds;
+import org.onap.svnfm.simulator.model.Vnfds.Vnfc;
+import org.onap.svnfm.simulator.model.Vnfds.Vnfd;
+import org.onap.svnfm.simulator.repository.VnfOperationRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class InstantiateOperationProgressor extends OperationProgressor {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(InstantiateOperationProgressor.class);
+
+ public InstantiateOperationProgressor(final VnfOperation operation, final SvnfmService svnfmService,
+ final VnfOperationRepository vnfOperationRepository, final ApplicationConfig applicationConfig,
+ final Vnfds vnfds, final SubscriptionService subscriptionService) {
+ super(operation, svnfmService, vnfOperationRepository, applicationConfig, vnfds, subscriptionService);
+ }
+
+ @Override
+ protected List<GrantsAddResources> getAddResources(final String vnfdId) {
+ final List<GrantsAddResources> resources = new ArrayList<>();
+
+ for (final Vnfd vnfd : vnfds.getVnfdList()) {
+ if (vnfd.getVnfdId().equals(vnfdId)) {
+ for (final Vnfc vnfc : vnfd.getVnfcList()) {
+ final GrantsAddResources addResource = new GrantsAddResources();
+ vnfc.setGrantResourceId(UUID.randomUUID().toString());
+ addResource.setId(vnfc.getGrantResourceId());
+ addResource.setType(TypeEnum.fromValue(vnfc.getType()));
+ addResource.setResourceTemplateId(vnfc.getResourceTemplateId());
+ addResource.setVduId(vnfc.getVduId());
+ resources.add(addResource);
+ }
+ }
+ }
+ return resources;
+ }
+
+ @Override
+ protected List<GrantsAddResources> getRemoveResources(final String vnfdId) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ protected List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> handleGrantResponse(
+ final InlineResponse201 grantResponse) {
+ final InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo = createInstantiatedVnfInfo(grantResponse);
+ svnfmService.updateVnf(InstantiationStateEnum.INSTANTIATED, instantiatedVnfInfo, operation.getVnfInstanceId(),
+ getVimConnections(grantResponse));
+ return instantiatedVnfInfo.getVnfcResourceInfo();
+ }
+
+ private InlineResponse201InstantiatedVnfInfo createInstantiatedVnfInfo(final InlineResponse201 grantResponse) {
+ final InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo = new InlineResponse201InstantiatedVnfInfo();
+
+ final Map<String, String> mapOfGrantResourceIdToVimConnectionId = new HashMap<>();
+ for (final InlineResponse201AddResources addResource : grantResponse.getAddResources()) {
+ mapOfGrantResourceIdToVimConnectionId.put(addResource.getResourceDefinitionId(),
+ addResource.getVimConnectionId());
+ }
+ LOGGER.info("VIM connections in grant response: {}", mapOfGrantResourceIdToVimConnectionId);
+
+ for (final Vnfd vnfd : vnfds.getVnfdList()) {
+ if (vnfd.getVnfdId().equals(svnfmService.getVnf(operation.getVnfInstanceId()).getVnfdId())) {
+ for (final Vnfc vnfc : vnfd.getVnfcList()) {
+ final InlineResponse201InstantiatedVnfInfoVnfcResourceInfo vnfcResourceInfoItem =
+ new InlineResponse201InstantiatedVnfInfoVnfcResourceInfo();
+ vnfcResourceInfoItem.setId(vnfc.getVnfcId());
+ vnfcResourceInfoItem.setVduId(vnfc.getVduId());
+ final InlineResponse201InstantiatedVnfInfoResourceHandle computeResource =
+ new InlineResponse201InstantiatedVnfInfoResourceHandle();
+ computeResource.setResourceId(UUID.randomUUID().toString());
+ LOGGER.info("Checking for VIM connection id for : {}", vnfc.getGrantResourceId());
+ computeResource
+ .setVimConnectionId(mapOfGrantResourceIdToVimConnectionId.get(vnfc.getGrantResourceId()));
+
+ computeResource.setVimLevelResourceType("OS::Nova::Server");
+ vnfcResourceInfoItem.setComputeResource(computeResource);
+ instantiatedVnfInfo.addVnfcResourceInfoItem(vnfcResourceInfoItem);
+ }
+ }
+ }
+
+ return instantiatedVnfInfo;
+ }
+
+
+ private List<InlineResponse201VimConnectionInfo> getVimConnections(final InlineResponse201 grantResponse) {
+ final List<InlineResponse201VimConnectionInfo> vimConnectionInfo = new ArrayList<>();
+ for (final InlineResponse201VimConnections vimConnection : grantResponse.getVimConnections()) {
+ final ModelMapper modelMapper = new ModelMapper();
+ vimConnectionInfo.add(modelMapper.map(vimConnection, InlineResponse201VimConnectionInfo.class));
+ }
+ return vimConnectionInfo;
+ }
+
+ @Override
+ protected ChangeTypeEnum getVnfcChangeType() {
+ return ChangeTypeEnum.ADDED;
+ }
+
+}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java
new file mode 100644
index 0000000000..1e31ab2fdb
--- /dev/null
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java
@@ -0,0 +1,239 @@
+package org.onap.svnfm.simulator.services;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.codec.binary.Base64;
+import org.modelmapper.ModelMapper;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.ApiResponse;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinks;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinksVnfLcmOpOcc;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.ApiClient;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.ApiException;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.api.DefaultApi;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinks;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinksVnfInstance;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.NotificationStatusEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.NotificationTypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoVnfcResourceInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic;
+import org.onap.svnfm.simulator.config.ApplicationConfig;
+import org.onap.svnfm.simulator.model.VnfOperation;
+import org.onap.svnfm.simulator.model.Vnfds;
+import org.onap.svnfm.simulator.repository.VnfOperationRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class OperationProgressor implements Runnable {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OperationProgressor.class);
+ protected final VnfOperation operation;
+ protected final SvnfmService svnfmService;
+ private final VnfOperationRepository vnfOperationRepository;
+ private final ApplicationConfig applicationConfig;
+ protected final Vnfds vnfds;
+ private final SubscriptionService subscriptionService;
+ private final DefaultApi notificationClient;
+ private final org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.api.DefaultApi grantClient;
+
+ public OperationProgressor(final VnfOperation operation, final SvnfmService svnfmService,
+ final VnfOperationRepository vnfOperationRepository, final ApplicationConfig applicationConfig,
+ final Vnfds vnfds, final SubscriptionService subscriptionService) {
+ this.operation = operation;
+ this.svnfmService = svnfmService;
+ this.vnfOperationRepository = vnfOperationRepository;
+ this.applicationConfig = applicationConfig;
+ this.vnfds = vnfds;
+ this.subscriptionService = subscriptionService;
+
+ final ApiClient apiClient = new ApiClient();
+ String callBackUrl = subscriptionService.getSubscriptions().iterator().next().getCallbackUri();
+ callBackUrl = callBackUrl.substring(0, callBackUrl.indexOf("/lcn/"));
+ apiClient.setBasePath(callBackUrl);
+ notificationClient = new DefaultApi(apiClient);
+
+ final org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.ApiClient grantApiClient =
+ new org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.ApiClient();
+ grantApiClient.setBasePath(callBackUrl);
+ grantClient = new org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.api.DefaultApi(grantApiClient);
+ }
+
+ @Override
+ public void run() {
+ try {
+ final VnfLcmOperationOccurrenceNotification notificationOfStarting =
+ buildNotification(NotificationStatusEnum.START, OperationStateEnum.STARTING);
+ sendNotification(notificationOfStarting);
+
+ sleep(2000);
+ setState(InlineResponse200.OperationStateEnum.PROCESSING);
+ final VnfLcmOperationOccurrenceNotification notificationOfProcessing =
+ buildNotification(NotificationStatusEnum.START, OperationStateEnum.PROCESSING);
+ sendNotification(notificationOfProcessing);
+
+
+ final GrantRequest grantRequest = buildGrantRequest();
+ final InlineResponse201 grantResponse = sendGrantRequest(grantRequest);
+ final List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> vnfcs = handleGrantResponse(grantResponse);
+
+ svnfmService.getVnf(operation.getVnfInstanceId()).getInstantiatedVnfInfo();
+
+ sleep(10000);
+ setState(InlineResponse200.OperationStateEnum.COMPLETED);
+ final VnfLcmOperationOccurrenceNotification notificationOfCompleted =
+ buildNotification(NotificationStatusEnum.RESULT, OperationStateEnum.COMPLETED);
+ notificationOfCompleted.setAffectedVnfcs(getVnfcs(vnfcs));
+
+ sendNotification(notificationOfCompleted);
+ } catch (final Exception exception) {
+ LOGGER.error("Error in OperationProgressor ", exception);
+ }
+
+ }
+
+ private void sleep(final long milliSeconds) {
+ try {
+ Thread.sleep(milliSeconds);
+ } catch (final InterruptedException e) {
+ operation.setOperationState(InlineResponse200.OperationStateEnum.FAILED);
+ }
+ }
+
+ private void setState(final InlineResponse200.OperationStateEnum state) {
+ LOGGER.info("Setting state to {} for operation {}", state, operation.getId());
+ operation.setOperationState(state);
+ vnfOperationRepository.save(operation);
+ }
+
+ private VnfLcmOperationOccurrenceNotification buildNotification(final NotificationStatusEnum status,
+ final OperationStateEnum operationState) {
+ final VnfLcmOperationOccurrenceNotification notification = new VnfLcmOperationOccurrenceNotification();
+ notification.setId(UUID.randomUUID().toString());
+ notification.setNotificationType(NotificationTypeEnum.VNFLCMOPERATIONOCCURRENCENOTIFICATION);
+ notification.setNotificationStatus(status);
+ notification.setOperationState(operationState);
+ notification.setOperation(OperationEnum.fromValue(operation.getOperation().toString()));
+ notification.setVnfInstanceId(operation.getVnfInstanceId());
+ notification.setVnfLcmOpOccId(operation.getId());
+
+ final LcnVnfLcmOperationOccurrenceNotificationLinks links = new LcnVnfLcmOperationOccurrenceNotificationLinks();
+ final LcnVnfLcmOperationOccurrenceNotificationLinksVnfInstance vnfInstanceLink =
+ new LcnVnfLcmOperationOccurrenceNotificationLinksVnfInstance();
+ vnfInstanceLink.setHref(getVnfLink());
+ links.setVnfInstance(vnfInstanceLink);
+
+
+ final LcnVnfLcmOperationOccurrenceNotificationLinksVnfInstance operationLink =
+ new LcnVnfLcmOperationOccurrenceNotificationLinksVnfInstance();
+ operationLink.setHref(getOperationLink());
+ links.setVnfLcmOpOcc(operationLink);
+
+ notification.setLinks(links);
+
+ return notification;
+ }
+
+ private List<LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs> getVnfcs(
+ final List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> instantiatedVnfcs) {
+ final List<LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs> vnfcs = new ArrayList<>();
+ if (instantiatedVnfcs != null) {
+ for (final InlineResponse201InstantiatedVnfInfoVnfcResourceInfo instantiatedVnfc : instantiatedVnfcs) {
+ LOGGER.info("VNFC TO BE CONVERTED: {}", instantiatedVnfc);
+ final ModelMapper mapper = new ModelMapper();
+ final LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs vnfc =
+ mapper.map(instantiatedVnfc, LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.class);
+ LOGGER.info("VNFC FROM CONVERSION: {}", vnfc);
+ vnfc.setChangeType(getVnfcChangeType());
+ vnfcs.add(vnfc);
+ }
+ }
+ return vnfcs;
+ }
+
+ private void sendNotification(final VnfLcmOperationOccurrenceNotification notification) {
+ LOGGER.info("Sending notification: {}", notification);
+ try {
+ final SubscriptionsAuthenticationParamsBasic subscriptionAuthentication =
+ subscriptionService.getSubscriptions().iterator().next().getAuthentication().getParamsBasic();
+ final String auth =
+ subscriptionAuthentication.getUserName() + ":" + subscriptionAuthentication.getPassword();
+ final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
+ final String authHeader = "Basic " + new String(encodedAuth);
+ notificationClient.lcnVnfLcmOperationOccurrenceNotificationPostWithHttpInfo(notification,
+ MediaType.APPLICATION_JSON, authHeader);
+ } catch (final ApiException exception) {
+ LOGGER.error("Error sending notification: " + notification, exception);
+ }
+ }
+
+
+ public GrantRequest buildGrantRequest() {
+ final GrantRequest grantRequest = new GrantRequest();
+ grantRequest.setVnfInstanceId(operation.getVnfInstanceId());
+ final String vnfdId = svnfmService.getVnf(operation.getVnfInstanceId()).getVnfdId();
+ grantRequest.setVnfdId(vnfdId);
+ grantRequest.setAddResources(getAddResources(vnfdId));
+ grantRequest.setRemoveResources(getRemoveResources(vnfdId));
+ grantRequest.setVnfLcmOpOccId(operation.getId());
+ grantRequest
+ .setOperation(org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest.OperationEnum
+ .fromValue(operation.getOperation().getValue()));
+ grantRequest.setIsAutomaticInvocation(false);
+
+ final GrantsLinksVnfLcmOpOcc vnfInstanceLink = new GrantsLinksVnfLcmOpOcc();
+ vnfInstanceLink.setHref(getVnfLink());
+ final GrantsLinksVnfLcmOpOcc operationInstanceLink = new GrantsLinksVnfLcmOpOcc();
+ operationInstanceLink.setHref(getOperationLink());
+ final GrantsLinks links = new GrantsLinks();
+ links.setVnfInstance(vnfInstanceLink);
+ links.setVnfLcmOpOcc(operationInstanceLink);
+ grantRequest.setLinks(links);
+ return grantRequest;
+ }
+
+ protected abstract List<GrantsAddResources> getAddResources(final String vnfdId);
+
+ protected abstract List<GrantsAddResources> getRemoveResources(final String vnfdId);
+
+ protected abstract List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> handleGrantResponse(
+ InlineResponse201 grantResponse);
+
+ protected abstract ChangeTypeEnum getVnfcChangeType();
+
+ private InlineResponse201 sendGrantRequest(final GrantRequest grantRequest) {
+ LOGGER.info("Sending grant request: {}", grantRequest);
+ try {
+ final ApiResponse<InlineResponse201> response = grantClient.grantsPostWithHttpInfo(grantRequest,
+ MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON, "Basic dm5mbTpwYXNzd29yZDEk");
+ LOGGER.info("Grant Response: {}", response);
+ return response.getData();
+ } catch (final org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.ApiException exception) {
+ LOGGER.error("Error sending notification: " + grantRequest, exception);
+ return null;
+ }
+ }
+
+ private String getVnfLink() {
+ return getLinkBaseUrl() + "/vnf_instances/" + operation.getVnfInstanceId();
+ }
+
+ private String getOperationLink() {
+ return getLinkBaseUrl() + "/vnf_lcm_op_occs/" + operation.getId();
+ }
+
+ private String getLinkBaseUrl() {
+ return applicationConfig.getBaseUrl() + "/vnflcm/v1";
+ }
+
+}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SubscriptionService.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SubscriptionService.java
new file mode 100644
index 0000000000..6a2340bdf6
--- /dev/null
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SubscriptionService.java
@@ -0,0 +1,21 @@
+package org.onap.svnfm.simulator.services;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SubscriptionService {
+
+ Collection<LccnSubscriptionRequest> subscriptions = new ArrayList<>();
+
+ public void registerSubscription(final LccnSubscriptionRequest subscription) {
+ subscriptions.add(subscription);
+ }
+
+ public Collection<LccnSubscriptionRequest> getSubscriptions() {
+ return Collections.unmodifiableCollection(subscriptions);
+ }
+}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java
index f7f4eaa4a2..21bb00dba7 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java
@@ -21,22 +21,39 @@
package org.onap.svnfm.simulator.services;
import java.lang.reflect.InvocationTargetException;
-import java.util.Optional;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import org.modelmapper.ModelMapper;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
+import org.onap.svnfm.simulator.config.ApplicationConfig;
+import org.onap.svnfm.simulator.constants.Constant;
import org.onap.svnfm.simulator.model.VnfInstance;
-import org.onap.svnfm.simulator.model.VnfJob;
+import org.onap.svnfm.simulator.model.VnfOperation;
+import org.onap.svnfm.simulator.model.Vnfds;
import org.onap.svnfm.simulator.notifications.VnfInstantiationNotification;
import org.onap.svnfm.simulator.notifications.VnfmAdapterCreationNotification;
-import org.onap.svnfm.simulator.repository.VnfJobRepository;
+import org.onap.svnfm.simulator.repository.VnfOperationRepository;
import org.onap.svnfm.simulator.repository.VnfmRepository;
-import org.onap.vnfm.v1.model.CreateVnfRequest;
-import org.onap.vnfm.v1.model.InlineResponse201;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.annotation.CachePut;
+import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.stereotype.Service;
/**
- *
+ *
* @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
* @author Ronan Kenny (ronan.kenny@est.tech)
*/
@@ -47,122 +64,136 @@ public class SvnfmService {
VnfmRepository vnfmRepository;
@Autowired
- VnfJobRepository vnfJobRepository;
+ VnfOperationRepository vnfOperationRepository;
@Autowired
private VnfmHelper vnfmHelper;
+ @Autowired
+ ApplicationConfig applicationConfig;
+
+ @Autowired
+ CacheManager cacheManager;
+
+ @Autowired
+ Vnfds vnfds;
+
+ @Autowired
+ SubscriptionService subscriptionService;
+
+ private final ExecutorService executor = Executors.newCachedThreadPool();
+
private static final Logger LOGGER = LoggerFactory.getLogger(SvnfmService.class);
/**
- *
+ *
* @param createVNFRequest
* @return inlineResponse201
*/
- public InlineResponse201 createVnf(final CreateVnfRequest createVNFRequest) {
+ public InlineResponse201 createVnf(final CreateVnfRequest createVNFRequest, final String id) {
InlineResponse201 inlineResponse201 = null;
try {
- final VnfInstance vnfInstance = vnfmHelper.createVnfInstance(createVNFRequest);
+ final VnfInstance vnfInstance = vnfmHelper.createVnfInstance(createVNFRequest, id);
vnfmRepository.save(vnfInstance);
final Thread creationNotification = new Thread(new VnfmAdapterCreationNotification());
creationNotification.start();
inlineResponse201 = vnfmHelper.getInlineResponse201(vnfInstance);
- LOGGER.debug("Response from Create VNF", inlineResponse201);
+ LOGGER.debug("Response from Create VNF {}", inlineResponse201);
} catch (IllegalAccessException | InvocationTargetException e) {
LOGGER.error("Failed in Create Vnf", e);
}
return inlineResponse201;
}
+ @CachePut(value = Constant.IN_LINE_RESPONSE_201_CACHE, key = "#id")
+ public InlineResponse201 updateVnf(final InstantiationStateEnum instantiationState,
+ final InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo, final String id,
+ final List<InlineResponse201VimConnectionInfo> vimConnectionInfo) {
+ final InlineResponse201 vnf = getVnf(id);
+ vnf.setInstantiatedVnfInfo(instantiatedVnfInfo);
+ vnf.setInstantiationState(instantiationState);
+ vnf.setVimConnectionInfo(vimConnectionInfo);
+ return vnf;
+ }
+
/**
- *
+ *
* @param vnfId
- * @param instantiateJobId
+ * @param instantiateVNFRequest
+ * @param operationId
* @throws InterruptedException
*/
- public Object instatiateVnf(final String vnfId, final String instantiateJobId) throws InterruptedException {
- final VnfJob vnfJob = buildVnfInstantiation(vnfId, instantiateJobId);
- vnfJobRepository.save(vnfJob);
- getJobStatus(vnfJob.getJobId());
- return null;
+ public String instantiateVnf(final String vnfId, final InstantiateVnfRequest instantiateVNFRequest) {
+ final VnfOperation vnfOperation = buildVnfOperation(InlineResponse200.OperationEnum.INSTANTIATE, vnfId);
+ vnfOperationRepository.save(vnfOperation);
+ executor.submit(new InstantiateOperationProgressor(vnfOperation, this, vnfOperationRepository,
+ applicationConfig, vnfds, subscriptionService));
+ return vnfOperation.getId();
}
/**
- *
+ * vnfOperationRepository
+ *
* @param vnfId
- * @param instantiateJobId
+ * @param instantiateOperationId
*/
- public VnfJob buildVnfInstantiation(final String vnfId, final String instantiateJobId) {
- final VnfJob vnfJob = new VnfJob();
- final Optional<VnfInstance> vnfInstance = vnfmRepository.findById(vnfId);
-
- if (vnfInstance.isPresent()) {
- vnfJob.setJobId(instantiateJobId);
- for (final VnfInstance instance : vnfmRepository.findAll()) {
- if (instance.getId().equals(vnfId)) {
- vnfJob.setVnfInstanceId(instance.getVnfInstanceDescription());
- }
- }
- vnfJob.setVnfId(vnfId);
- vnfJob.setStatus("STARTING");
- }
- return vnfJob;
+ public VnfOperation buildVnfOperation(final InlineResponse200.OperationEnum operation, final String vnfId) {
+ final VnfOperation vnfOperation = new VnfOperation();
+ vnfOperation.setId(UUID.randomUUID().toString());
+ vnfOperation.setOperation(operation);
+ vnfOperation.setOperationState(InlineResponse200.OperationStateEnum.STARTING);
+ vnfOperation.setVnfInstanceId(vnfId);
+ return vnfOperation;
}
/**
- *
- * @param jobId
+ *
+ * @param operationId
* @throws InterruptedException
*/
- public Object getJobStatus(final String jobId) throws InterruptedException {
- LOGGER.info("Getting job status with id: " + jobId);
- for (int i = 0; i < 5; i++) {
- LOGGER.info("Instantiation status: RUNNING");
- Thread.sleep(5000);
- for (final VnfJob job : vnfJobRepository.findAll()) {
- if (job.getJobId().equals(jobId)) {
- job.setStatus("RUNNING");
- vnfJobRepository.save(job);
- }
- }
- }
+ public InlineResponse200 getOperationStatus(final String operationId) {
+ LOGGER.info("Getting operation status with id: {}", operationId);
final Thread instantiationNotification = new Thread(new VnfInstantiationNotification());
instantiationNotification.start();
- for (final VnfJob job : vnfJobRepository.findAll()) {
- if (job.getJobId().equals(jobId)) {
- job.setStatus("COMPLETE");
- vnfJobRepository.save(job);
+ for (final VnfOperation operation : vnfOperationRepository.findAll()) {
+ LOGGER.info("Operation found: {}", operation);
+ if (operation.getId().equals(operationId)) {
+ final ModelMapper modelMapper = new ModelMapper();
+ return modelMapper.map(operation, InlineResponse200.class);
}
}
return null;
}
/**
- *
+ *
* @param vnfId
* @return inlineResponse201
*/
public InlineResponse201 getVnf(final String vnfId) {
- InlineResponse201 inlineResponse201 = null;
-
- final Optional<VnfInstance> vnfInstance = vnfmRepository.findById(vnfId);
- try {
- if (vnfInstance.isPresent()) {
- inlineResponse201 = vnfmHelper.getInlineResponse201(vnfInstance.get());
- LOGGER.debug("Response from get VNF", inlineResponse201);
- }
- } catch (IllegalAccessException | InvocationTargetException e) {
- LOGGER.error("Failed in get Vnf", e);
+ final Cache ca = cacheManager.getCache(Constant.IN_LINE_RESPONSE_201_CACHE);
+ final SimpleValueWrapper wrapper = (SimpleValueWrapper) ca.get(vnfId);
+ final InlineResponse201 inlineResponse201 = (InlineResponse201) wrapper.get();
+ if (inlineResponse201 != null) {
+ LOGGER.info("Cache Read Successful");
+ return inlineResponse201;
}
- return inlineResponse201;
+ return null;
}
/**
* @param vnfId
* @return
*/
- public Object terminateVnf(String vnfId) {
- // TODO
- return null;
+ public String terminateVnf(final String vnfId) {
+ final VnfOperation vnfOperation = buildVnfOperation(InlineResponse200.OperationEnum.TERMINATE, vnfId);
+ vnfOperationRepository.save(vnfOperation);
+ executor.submit(new TerminateOperationProgressor(vnfOperation, this, vnfOperationRepository, applicationConfig,
+ vnfds, subscriptionService));
+ return vnfOperation.getId();
+ }
+
+ public void registerSubscription(final LccnSubscriptionRequest subscription) {
+ subscriptionService.registerSubscription(subscription);
}
}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/TerminateOperationProgressor.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/TerminateOperationProgressor.java
new file mode 100644
index 0000000000..c829be9a4f
--- /dev/null
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/TerminateOperationProgressor.java
@@ -0,0 +1,74 @@
+package org.onap.svnfm.simulator.services;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources.TypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsResource;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoResourceHandle;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoVnfcResourceInfo;
+import org.onap.svnfm.simulator.config.ApplicationConfig;
+import org.onap.svnfm.simulator.model.VnfOperation;
+import org.onap.svnfm.simulator.model.Vnfds;
+import org.onap.svnfm.simulator.repository.VnfOperationRepository;
+
+public class TerminateOperationProgressor extends OperationProgressor {
+
+ public TerminateOperationProgressor(final VnfOperation operation, final SvnfmService svnfmService,
+ final VnfOperationRepository vnfOperationRepository, final ApplicationConfig applicationConfig,
+ final Vnfds vnfds, final SubscriptionService subscriptionService) {
+ super(operation, svnfmService, vnfOperationRepository, applicationConfig, vnfds, subscriptionService);
+ }
+
+ @Override
+ protected List<GrantsAddResources> getAddResources(final String vnfdId) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ protected List<GrantsAddResources> getRemoveResources(final String vnfdId) {
+ final List<GrantsAddResources> resources = new ArrayList<>();
+
+ final org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201 vnf =
+ svnfmService.getVnf(operation.getVnfInstanceId());
+ for (final InlineResponse201InstantiatedVnfInfoVnfcResourceInfo vnfc : vnf.getInstantiatedVnfInfo()
+ .getVnfcResourceInfo()) {
+ final GrantsAddResources addResource = new GrantsAddResources();
+ addResource.setId(UUID.randomUUID().toString());
+ addResource.setType(TypeEnum.COMPUTE);
+ addResource.setVduId(vnfc.getVduId());
+ final GrantsResource resource = new GrantsResource();
+
+ final InlineResponse201InstantiatedVnfInfoResourceHandle computeResource = vnfc.getComputeResource();
+ resource.setResourceId(computeResource.getResourceId());
+ resource.setVimConnectionId(computeResource.getVimConnectionId());
+ resource.setVimLevelResourceType(computeResource.getVimLevelResourceType());
+ addResource.setResource(resource);
+ resources.add(addResource);
+
+ }
+ return resources;
+ }
+
+ @Override
+ protected List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> handleGrantResponse(
+ final InlineResponse201 grantResponse) {
+ final List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> vnfcs =
+ svnfmService.getVnf(operation.getVnfInstanceId()).getInstantiatedVnfInfo().getVnfcResourceInfo();
+ svnfmService.updateVnf(InstantiationStateEnum.NOT_INSTANTIATED, null, operation.getVnfInstanceId(), null);
+ return vnfcs;
+ }
+
+ @Override
+ protected ChangeTypeEnum getVnfcChangeType() {
+ return ChangeTypeEnum.REMOVED;
+ }
+
+
+
+}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java
index f35cbf2f49..60b251c4d4 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java
@@ -21,31 +21,39 @@
package org.onap.svnfm.simulator.services;
import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.commons.beanutils.BeanUtils;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201Links;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201LinksSelf;
+import org.onap.svnfm.simulator.config.ApplicationConfig;
import org.onap.svnfm.simulator.constants.Constant;
import org.onap.svnfm.simulator.model.VnfInstance;
-import org.onap.vnfm.v1.model.CreateVnfRequest;
-import org.onap.vnfm.v1.model.InlineResponse201;
-import org.onap.vnfm.v1.model.InlineResponse201.InstantiationStateEnum;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
- *
+ *
* @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
* @author Ronan Kenny (ronan.kenny@est.tech)
*/
@Component
public class VnfmHelper {
+ @Autowired
+ private ApplicationConfig applicationConfig;
+
/**
- *
+ *
* @param createVNFRequest
* @return vnfInstance
*/
- public VnfInstance createVnfInstance(final CreateVnfRequest createVNFRequest) {
+ public VnfInstance createVnfInstance(final CreateVnfRequest createVNFRequest, final String id) {
final VnfInstance vnfInstance = new VnfInstance();
- final String vnfId = createVNFRequest.getVnfdId();
- vnfInstance.setId(vnfId);
+ vnfInstance.setId(id);
vnfInstance.setVnfInstanceName(createVNFRequest.getVnfInstanceName());
vnfInstance.setVnfInstanceDescription(createVNFRequest.getVnfInstanceDescription());
vnfInstance.setVnfdId(createVNFRequest.getVnfdId());
@@ -55,7 +63,7 @@ public class VnfmHelper {
}
/**
- *
+ *
* @param vnfInstance
* @return inlineResponse201
* @throws IllegalAccessException
@@ -68,6 +76,27 @@ public class VnfmHelper {
inlineResponse201.setVnfdVersion(Constant.VNFD_VERSION);
inlineResponse201.setVnfSoftwareVersion(Constant.VNF_SOFTWARE_VERSION);
inlineResponse201.setInstantiationState(InstantiationStateEnum.NOT_INSTANTIATED);
+ inlineResponse201.setVnfConfigurableProperties(getConfigProperties());
+ addAdditionalPRopertyInlineResponse201(inlineResponse201);
return inlineResponse201;
}
+
+ private Map<String, String> getConfigProperties() {
+ final Map<String, String> configProperties = new HashMap<>();
+ configProperties.put("ipAddress", "10.11.12.13");
+ return configProperties;
+ }
+
+ private void addAdditionalPRopertyInlineResponse201(final InlineResponse201 inlineResponse201) {
+ final InlineResponse201LinksSelf VnfInstancesLinksSelf = new InlineResponse201LinksSelf();
+ VnfInstancesLinksSelf
+ .setHref(applicationConfig.getBaseUrl() + "/vnflcm/v1/vnf_instances/" + inlineResponse201.getId());
+ final InlineResponse201LinksSelf VnfInstancesLinksSelfInstantiate = new InlineResponse201LinksSelf();
+ VnfInstancesLinksSelfInstantiate.setHref(applicationConfig.getBaseUrl() + "/vnflcm/v1/vnf_instances/"
+ + inlineResponse201.getId() + "/instantiate");
+ final InlineResponse201Links inlineResponse201Links = new InlineResponse201Links();
+ inlineResponse201Links.setSelf(VnfInstancesLinksSelf);
+ inlineResponse201Links.setInstantiate(VnfInstancesLinksSelfInstantiate);
+ inlineResponse201.setLinks(inlineResponse201Links);
+ }
}
diff --git a/vnfm-simulator/vnfm-service/src/main/resources/application.properties b/vnfm-simulator/vnfm-service/src/main/resources/application.properties
deleted file mode 100644
index c5b36d77f4..0000000000
--- a/vnfm-simulator/vnfm-service/src/main/resources/application.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-# Enabling H2 Console
-spring.h2.console.enabled=true
-spring.h2.console.path=/console
-spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
-spring.datasource.username=admin
-spring.datasource.password=admin
-spring.datasource.driverClassName=org.h2.Driver
-spring.jpa.hibernate.ddl-auto = update
-spring.jpa.show-sql=true
-logging.level.org.hibernate.SQL=DEBUG
-logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
-
-server.port=9081 \ No newline at end of file
diff --git a/vnfm-simulator/vnfm-service/src/main/resources/application.yaml b/vnfm-simulator/vnfm-service/src/main/resources/application.yaml
new file mode 100644
index 0000000000..2ef302ce25
--- /dev/null
+++ b/vnfm-simulator/vnfm-service/src/main/resources/application.yaml
@@ -0,0 +1,59 @@
+# Copyright © 2019 Nordix Foundation
+#
+# 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.
+
+spring:
+ h2:
+ console:
+ enabled: true
+ path: console
+ datasource:
+ url: jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+ username: admin
+ password: admin
+ http:
+ converters:
+ preferred-json-mapper: gson
+ security:
+ usercredentials:
+ - username: vnfm
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: BPEL-Client
+
+server:
+ port: 9093
+ tomcat:
+ max-threads: 50
+
+vnfds:
+ vnfdlist:
+ - vnfdid: 1
+ vnfclist:
+ - vnfcid: VNFC1
+ resourceTemplateId: vnfd1_vnfc1
+ vduId: vnfd1_vduForVnfc1
+ type: COMPUTE
+ - vnfcid: VNFC2
+ resourceTemplateId: vnfd1_vnfc2
+ vduId: vnfd1_vduForVnfc2
+ type: COMPUTE
+ - vnfdid: 2
+ vnfclist:
+ - vnfcid: VNFC3
+ resourceTemplateId: vnfd2_vnfc3
+ vduId: vnfd2_vduForVnfc3
+ type: COMPUTE
+ - vnfcid: VNFC4
+ resourceTemplateId: vnfd2_vnfc4
+ vduId: vnfd2_vduForVnfc4
+ type: COMPUTE \ No newline at end of file
diff --git a/vnfm-simulator/vnfm-service/src/test/java/org/onap/svnfm/simulator/controllers/TestSvnfmController.java b/vnfm-simulator/vnfm-service/src/test/java/org/onap/svnfm/simulator/controllers/TestSvnfmController.java
index f338b5828e..9cb0702ee0 100644
--- a/vnfm-simulator/vnfm-service/src/test/java/org/onap/svnfm/simulator/controllers/TestSvnfmController.java
+++ b/vnfm-simulator/vnfm-service/src/test/java/org/onap/svnfm/simulator/controllers/TestSvnfmController.java
@@ -20,10 +20,13 @@
package org.onap.svnfm.simulator.controllers;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -31,15 +34,15 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
+import org.onap.svnfm.simulator.constants.Constant;
import org.onap.svnfm.simulator.controller.SvnfmController;
import org.onap.svnfm.simulator.repository.VnfmCacheRepository;
import org.onap.svnfm.simulator.services.SvnfmService;
-import org.onap.vnfm.v1.model.CreateVnfRequest;
-import org.onap.vnfm.v1.model.InlineResponse201;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
public class TestSvnfmController {
@@ -69,14 +72,12 @@ public class TestSvnfmController {
createVnfRequest.setVnfInstanceName("createVnfInstanceTest");
createVnfRequest.setVnfInstanceDescription("createVnfInstanceTest");
- when(vnfmCacheRepository.createVnf(createVnfRequest)).thenReturn(new InlineResponse201());
-
- svnfmService.createVnf(createVnfRequest);
+ when(vnfmCacheRepository.createVnf(eq(createVnfRequest), anyString())).thenReturn(new InlineResponse201());
final String body = (new ObjectMapper()).valueToTree(createVnfRequest).toString();
this.mockMvc
- .perform(post("/svnfm/vnf_instances").content(body).contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
+ .perform(post(Constant.BASE_URL + "/vnf_instances").content(body)
+ .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andExpect(status().isCreated()).andExpect(content().contentType(MediaType.APPLICATION_JSON));
}
}