summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java4
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java7
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java6
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java2
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java1
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java23
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java3
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java13
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java31
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy65
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java27
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java6
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java72
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy67
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java39
-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.java121
-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.java31
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java296
-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.java148
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java39
-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
43 files changed, 1293 insertions, 727 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
index c61306fb77..9fd5c2adeb 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
@@ -124,7 +124,7 @@ public class NotificationDataImpl implements INotificationData {
@Override
public List<IResourceInstance> getResources() {
- List<IResourceInstance> ret = new ArrayList<IResourceInstance>();
+ List<IResourceInstance> ret = new ArrayList<>();
if (resources != null) {
ret.addAll(resources);
}
@@ -145,7 +145,7 @@ public class NotificationDataImpl implements INotificationData {
@Override
public List<IArtifactInfo> getServiceArtifacts() {
- List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
+ List<IArtifactInfo> temp = new ArrayList<>();
if (serviceArtifacts != null) {
temp.addAll(serviceArtifacts);
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
index 62d11ffec9..2f109cd9d3 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
@@ -31,7 +31,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResourceInfoImpl implements IResourceInstance {
- public ResourceInfoImpl() {}
private String resourceInstanceName;
private String resourceCustomizationUUID;
@@ -44,6 +43,8 @@ public class ResourceInfoImpl implements IResourceInstance {
private String subcategory;
private List<ArtifactInfoImpl> artifacts;
+ public ResourceInfoImpl() {}
+
private ResourceInfoImpl(IResourceInstance resourceInstance) {
resourceInstanceName = resourceInstance.getResourceInstanceName();
resourceCustomizationUUID = resourceInstance.getResourceCustomizationUUID();
@@ -58,7 +59,7 @@ public class ResourceInfoImpl implements IResourceInstance {
}
public static List<ResourceInfoImpl> convertToJsonContainer(List<IResourceInstance> resources) {
- List<ResourceInfoImpl> buildResources = new ArrayList<ResourceInfoImpl>();
+ List<ResourceInfoImpl> buildResources = new ArrayList<>();
if (resources != null) {
for (IResourceInstance resourceInstance : resources) {
buildResources.add(new ResourceInfoImpl(resourceInstance));
@@ -114,7 +115,7 @@ public class ResourceInfoImpl implements IResourceInstance {
@Override
public List<IArtifactInfo> getArtifacts() {
- List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
+ List<IArtifactInfo> temp = new ArrayList<>();
if (artifacts != null) {
temp.addAll(artifacts);
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java
index 14ea0cde4b..46ec34e8d3 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java
@@ -103,10 +103,10 @@ public class ASDCRestInterface {
distributionClientEmulator = new DistributionClientEmulator("resource-examples/");
statusData = JsonStatusData.instantiateNotifFromJsonFile("resource-examples/");
- ASDCController asdcController = new ASDCController("asdc-controller1", distributionClientEmulator);
- asdcController.initASDC();
+ ASDCController controller = new ASDCController("asdc-controller1", distributionClientEmulator);
+ controller.initASDC();
toscaInstaller.installTheComponentStatus(statusData);
- asdcController.closeASDC();
+ controller.closeASDC();
} catch (Exception e) {
logger.info("Error caught " + e.getMessage());
logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION.toString(),
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
index 043055e23c..81b0843671 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
@@ -47,7 +47,7 @@ public class ASDCElementInfo {
* <li>{@link ASDCElementTypeEnum#VNF_RESOURCE}</li>
* <ul>
*/
- public static enum ASDCElementTypeEnum {
+ public enum ASDCElementTypeEnum {
/**
* The type VNF_RESOURCE. Represents a VNF_RESOURCE element.
*/
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
index 897cbe3573..309b053589 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.core.domain;
import java.io.Serializable;
-import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonRootName;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java
index 602172f8a4..bf53c880e9 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
*/
@JsonInclude(Include.NON_NULL)
public abstract class JsonWrapper implements Serializable {
+ private static final String EXCEPTION = "Exception :";
private static final Logger logger = LoggerFactory.getLogger(JsonWrapper.class);
@@ -63,7 +64,7 @@ public abstract class JsonWrapper implements Serializable {
jsonString = ow.writeValueAsString(this);
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
}
return jsonString;
}
@@ -76,14 +77,10 @@ public abstract class JsonWrapper implements Serializable {
JSONObject json = new JSONObject();
try {
json = new JSONObject(mapper.writeValueAsString(this));
- } catch (JsonGenerationException e) {
- logger.debug("Exception :", e);
- } catch (JsonMappingException e) {
- logger.debug("Exception :", e);
- } catch (JSONException e) {
- logger.debug("Exception :", e);
+ } catch (JsonGenerationException | JsonMappingException | JSONException e) {
+ logger.debug(EXCEPTION, e);
} catch (IOException e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
}
return json;
}
@@ -95,12 +92,10 @@ public abstract class JsonWrapper implements Serializable {
String jsonString = "";
try {
jsonString = mapper.writeValueAsString(list);
- } catch (JsonGenerationException e) {
- logger.debug("Exception :", e);
- } catch (JsonMappingException e) {
- logger.debug("Exception :", e);
+ } catch (JsonGenerationException | JsonMappingException e) {
+ logger.debug(EXCEPTION, e);
} catch (IOException e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
}
return jsonString;
}
@@ -118,7 +113,7 @@ public abstract class JsonWrapper implements Serializable {
jsonString = ow.writeValueAsString(this);
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
}
return jsonString;
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java
index f66ad36058..a69a49b89a 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java
@@ -32,6 +32,7 @@ import com.fasterxml.jackson.annotation.JsonRootName;
* Encapsulates VNF resource data set
*
*/
+@JsonIgnoreProperties(ignoreUnknown = true)
@JsonRootName("vnfResource")
public class VnfResource extends Resource {
@@ -59,7 +60,7 @@ public class VnfResource extends Resource {
private String multiStageDesign;
private String orchestrationStatus;
- @JsonIgnore
+ @JsonProperty("resourceInput")
private String resourceInput;
/*
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
index 09bcfe8470..b23633b4d8 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
@@ -58,6 +58,19 @@ public class VnfResourceTest {
VnfResource vnfResource = objectMapper.readValue(jsonStr, VnfResource.class);
assertTrue(vnfResource != null);
+ assertEquals("sample", vnfResource.getResourceInput());
+ assertEquals("home", vnfResource.getVnfHostname());
+ }
+
+ @Test
+ public void vnfResourceMapperTestNoResourceInput() throws IOException {
+ String jsonStr = "{\"vnfHostname\": \"home\"}";
+ ObjectMapper objectMapper = new ObjectMapper();
+ VnfResource vnfResource = objectMapper.readValue(jsonStr, VnfResource.class);
+
+ assertTrue(vnfResource != null);
+ assertEquals(null, vnfResource.getResourceInput());
+ assertEquals("home", vnfResource.getVnfHostname());
}
@Test
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java
index 3734510eed..3ff240ebc2 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java
@@ -34,6 +34,8 @@ import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.junit.Before;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
+import org.onap.so.bpmn.common.recipe.ResourceInput;
+import org.onap.so.bpmn.common.resource.ResourceRequestBuilder;
import org.springframework.beans.factory.annotation.Autowired;
public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
@@ -61,6 +63,7 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() {
// given
variables.put(PNF_CORRELATION_ID, PnfManagementTestImpl.ID_WITH_ENTRY);
+ variables.put("resourceInput", getUpdateResInputObj("OLT").toString());
// when
ProcessInstance instance =
runtimeService.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
@@ -79,6 +82,7 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() {
// given
variables.put(PNF_CORRELATION_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY);
+ variables.put("resourceInput", getUpdateResInputObj("OLT").toString());
// when
ProcessInstance instance =
runtimeService.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
@@ -93,4 +97,31 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
Assertions.assertThat(pnfManagementTest.getServiceAndPnfRelationMap())
.containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY));
}
+
+ private ResourceInput getUpdateResInputObj(String modelName) {
+
+ String resourceInput = "{\n" + "\t\"resourceInstanceName\": \"SotnFc-wan-connection_wanconnection-37\",\n"
+ + "\t\"resourceInstanceDes\": null,\n" + "\t\"globalSubscriberId\": \"sdwandemo\",\n"
+ + "\t\"serviceType\": \"CCVPN\",\n" + "\t\"operationId\": \"df3387b5-4fbf-41bd-82a0-13a955ac178a\",\n"
+ + "\t\"serviceModelInfo\": {\n" + "\t\t\"modelName\": \"WanConnectionSvc03\",\n"
+ + "\t\t\"modelUuid\": \"198b066c-0771-4157-9594-1824adfdda7e\",\n"
+ + "\t\t\"modelInvariantUuid\": \"43fb5165-7d03-4009-8951-a8f45d3f0148\",\n"
+ + "\t\t\"modelVersion\": \"1.0\",\n" + "\t\t\"modelCustomizationUuid\": \"\",\n"
+ + "\t\t\"modelCustomizationName\": \"\",\n" + "\t\t\"modelInstanceName\": \"\",\n"
+ + "\t\t\"modelType\": \"\"\n" + "\t},\n" + "\t\"resourceModelInfo\": {\n" + "\t\t\"modelName\": \""
+ + modelName + "\",\n" + "\t\t\"modelUuid\": \"6a0bf88b-343c-415b-88c1-6f73702452c4\",\n"
+ + "\t\t\"modelInvariantUuid\": \"50bc3415-2e01-4e50-a9e1-ec9584599bb3\",\n"
+ + "\t\t\"modelCustomizationUuid\": \"b205d620-84bd-4058-afa0-e3aeee8bb712\",\n"
+ + "\t\t\"modelCustomizationName\": \"\",\n"
+ + "\t\t\"modelInstanceName\": \"SotnFc-wan-connection 0\",\n" + "\t\t\"modelType\": \"\"\n" + "\t},\n"
+ + "\t\"resourceInstancenUuid\": null,\n"
+ + "\t\"resourceParameters\": \"{\\n\\\"locationConstraints\\\":[],\\n\\\"requestInputs\\\":{\\\"sotnfcspecwanconnection0_route-objective-function\\\":null,\\\"sotnfcspecwanconnection0_colorAware\\\":null,\\\"3rdctlspecwanconnection0_thirdPartyAdaptorRpc\\\":null,\\\"sotnfcspecwanconnection0_couplingFlag\\\":null,\\\"sotnfcspecwanconnection0_pbs\\\":null,\\\"3rdctlspecwanconnection0_thirdPartySdncId\\\":null,\\\"sotnfcspecwanconnection0_cbs\\\":null,\\\"3rdctlspecwanconnection0_thirdpartySdncName\\\":null,\\\"sotnfcspecwanconnection0_total-size\\\":null,\\\"3rdctlspecwanconnection0_templateFileName\\\":\\\"sotn_create_zte_template.json\\\",\\\"fcwanconnection0_type\\\":null,\\\"sotnfcspecwanconnection0_cir\\\":null,\\\"fcwanconnection0_uuid\\\":null,\\\"sotnfcspecwanconnection0_diversity-policy\\\":null,\\\"nf_naming\\\":true,\\\"multi_stage_design\\\":false,\\\"availability_zone_max_count\\\":1,\\\"3rdctlspecwanconnection0_restapiUrl\\\":\\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\\"max_instances\\\":null,\\\"sotnfcspecwanconnection0_reroute\\\":null,\\\"fcwanconnection0_name\\\":null,\\\"sotnfcspecwanconnection0_dualLink\\\":null,\\\"min_instances\\\":null,\\\"sotnfcspecwanconnection0_pir\\\":null,\\\"sotnfcspecwanconnection0_service-type\\\":null}\\n}\",\n"
+ + "\t\"operationType\": \"createInstance\",\n"
+ + "\t\"serviceInstanceId\": \"ffa07ae4-f820-45af-9439-1416b3bc1d39\",\n"
+ + "\t\"requestsInputs\": \"{\\r\\n\\t\\\"service\\\": {\\r\\n\\t\\t\\\"name\\\": \\\"wanconnection-37\\\",\\r\\n\\t\\t\\\"description\\\": \\\"deafe\\\",\\r\\n\\t\\t\\\"serviceInvariantUuid\\\": \\\"43fb5165-7d03-4009-8951-a8f45d3f0148\\\",\\r\\n\\t\\t\\\"serviceUuid\\\": \\\"198b066c-0771-4157-9594-1824adfdda7e\\\",\\r\\n\\t\\t\\\"globalSubscriberId\\\": \\\"sdwandemo\\\",\\r\\n\\t\\t\\\"serviceType\\\": \\\"CCVPN\\\",\\r\\n\\t\\t\\\"parameters\\\": {\\r\\n\\t\\t\\t\\\"resources\\\": [\\r\\n\\t\\t\\t],\\r\\n\\t\\t\\t\\\"requestInputs\\\": {\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sotn_create_zte_template.json\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sdwan_create_zte_template.json\\\",\\\"ont_ont_manufacturer\\\":\\\"huawei\\\",\\\"ont_ont_serial_num\\\":\\\"123\\\"\\r\\n\\t\\t\\t}\\r\\n\\t\\t}\\r\\n\\t}\\r\\n}\"\n"
+ + "}";
+
+ ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class);
+ return resourceInputObj;
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
index e7ff69ab3b..dd993bca51 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
@@ -20,7 +20,9 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
+import java.util.HashMap;
import java.util.Objects;
+import java.util.Optional;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
@@ -33,7 +35,8 @@ public class DmaapClientTestImpl implements DmaapClient {
private Runnable informConsumer;
@Override
- public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) {
+ public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer,
+ Optional<HashMap<String, String>> updateInfo) {
this.pnfCorrelationId = pnfCorrelationId;
this.informConsumer = informConsumer;
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
index 3e059e53bf..6a5a9021b2 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
@@ -216,7 +216,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
* This method updates the resource input by collecting required info from AAI
* @param execution
*/
- public void updateResourceInput(DelegateExecution execution) {
+ public ResourceInput updateResourceInput(DelegateExecution execution) {
ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(execution.getVariable(Prefix + "resourceInput"), ResourceInput.class)
String modelName = resourceInputObj.getResourceModelInfo().getModelName()
@@ -232,9 +232,29 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
String incomingRequest = resourceInputObj.getRequestsInputs()
String serviceParameters = JsonUtils.getJsonValue(incomingRequest, "service.parameters")
String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs")
- String cvlan = "10"
- String svlan = "100"
- String accessId = "AC9.0234.0337"
+ String cvlan
+ String svlan
+ String remoteId
+
+ List<Metadatum> metadatum = getMetaDatum(resourceInputObj.getGlobalSubscriberId(),
+ resourceInputObj.getServiceType(),
+ resourceInputObj.getServiceInstanceId())
+ for(Metadatum datum: metadatum) {
+ if (datum.getMetaname().equalsIgnoreCase("cvlan")) {
+ cvlan = datum.getMetaval()
+ }
+
+ if (datum.getMetaname().equalsIgnoreCase("svlan")) {
+ svlan = datum.getMetaval()
+ }
+
+ if (datum.getMetaname().equalsIgnoreCase("remoteId")) {
+ remoteId = datum.getMetaval()
+ }
+ }
+
+ logger.debug("cvlan: "+cvlan+" | svlan: "+svlan+" | remoteId: "+remoteId)
+
String manufacturer = jsonUtil.getJsonValue(serInput,
"service.parameters.requestInputs.ont_ont_manufacturer")
String ontsn = jsonUtil.getJsonValue(serInput,
@@ -242,14 +262,14 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
String uResourceInput = jsonUtil.addJsonValue(resourceInput, "requestInputs.CVLAN", cvlan)
uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.SVLAN", svlan)
- uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.accessID", accessId)
+ uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.accessID", remoteId)
uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.manufacturer", manufacturer)
uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ONTSN", ontsn)
- msoLogger.debug("old resource input:" + resourceInputObj.toString())
+ logger.debug("old resource input:" + resourceInputObj.toString())
resourceInputObj.setResourceParameters(uResourceInput)
execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString())
- msoLogger.debug("new resource Input :" + resourceInputObj.toString())
+ logger.debug("new resource Input :" + resourceInputObj.toString())
break
case ~/[\w\s\W]*EdgeInternetProfile[\w\s\W]*/ :
@@ -260,23 +280,41 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs")
JSONObject inputParameters = new JSONObject(requestInputs)
- String cvlan = "100"
- String svlan = "1000"
+ String cvlan
+ String svlan
+ String remoteId
String manufacturer = jsonUtil.getJsonValue(serInput,
"service.parameters.requestInputs.ont_ont_manufacturer")
- String accessId = "AC9.0234.0337"
+
String ontsn = jsonUtil.getJsonValue(serInput,
"service.parameters.requestInputs.ont_ont_serial_num")
+ List<Metadatum> metadatum = getMetaDatum(resourceInputObj.getGlobalSubscriberId(),
+ resourceInputObj.getServiceType(),
+ resourceInputObj.getServiceInstanceId())
+ for(Metadatum datum: metadatum) {
+ if (datum.getMetaname().equalsIgnoreCase("cvlan")) {
+ cvlan = datum.getMetaval()
+ }
+
+ if (datum.getMetaname().equalsIgnoreCase("svlan")) {
+ svlan = datum.getMetaval()
+ }
+
+ if (datum.getMetaname().equalsIgnoreCase("remoteId")) {
+ remoteId = datum.getMetaval()
+ }
+ }
+
String uResourceInput = jsonUtil.addJsonValue(resourceInput, "requestInputs.c_vlan", cvlan)
uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.s_vlan", svlan)
uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.manufacturer", manufacturer)
- uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_access_id", accessId)
+ uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_access_id", remoteId)
uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ont_sn", ontsn)
- msoLogger.debug("old resource input:" + resourceInputObj.toString())
+ logger.debug("old resource input:" + resourceInputObj.toString())
resourceInputObj.setResourceParameters(uResourceInput)
execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString())
- msoLogger.debug("new resource Input :" + resourceInputObj.toString())
+ logger.debug("new resource Input :" + resourceInputObj.toString())
break
@@ -320,6 +358,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
default:
break
}
+ return resourceInputObj
}
/**
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
index 94ceddae97..2ababac7e3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
@@ -24,11 +24,17 @@ import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.camunda.bpm.engine.runtime.Execution;
+import org.onap.aai.domain.yang.v13.Metadatum;
+import org.onap.so.bpmn.common.recipe.ResourceInput;
+import org.onap.so.bpmn.common.resource.ResourceRequestBuilder;
+import org.onap.so.bpmn.core.json.JsonUtils;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.util.HashMap;
+import java.util.Optional;
@Component
public class InformDmaapClient implements JavaDelegate {
@@ -41,8 +47,25 @@ public class InformDmaapClient implements JavaDelegate {
String pnfCorrelationId = (String) execution.getVariable(ExecutionVariableNames.PNF_CORRELATION_ID);
RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
String processBusinessKey = execution.getProcessBusinessKey();
- dmaapClient.registerForUpdate(pnfCorrelationId, () -> runtimeService.createMessageCorrelation("WorkflowMessage")
- .processInstanceBusinessKey(processBusinessKey).correlateWithResult());
+ HashMap<String, String> updateInfo = createUpdateInfo(execution);
+ updateInfo.put("pnfCorrelationId", pnfCorrelationId);
+ dmaapClient
+ .registerForUpdate(pnfCorrelationId,
+ () -> runtimeService.createMessageCorrelation("WorkflowMessage")
+ .processInstanceBusinessKey(processBusinessKey).correlateWithResult(),
+ Optional.of(updateInfo));
+ }
+
+ private HashMap<String, String> createUpdateInfo(DelegateExecution execution) {
+ HashMap<String, String> map = new HashMap();
+
+ ResourceInput resourceInputObj = ResourceRequestBuilder
+
+ .getJsonObject((String) execution.getVariable("resourceInput"), ResourceInput.class);
+ map.put("globalSubscriberID", resourceInputObj.getGlobalSubscriberId());
+ map.put("serviceType", resourceInputObj.getServiceType());
+ map.put("serviceInstanceId", resourceInputObj.getServiceInstanceId());
+ return map;
}
@Autowired
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java
index fbf86cc411..d513684659 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java
@@ -20,9 +20,13 @@
package org.onap.so.bpmn.infrastructure.pnf.dmaap;
+import java.util.HashMap;
+import java.util.Optional;
+
public interface DmaapClient {
- void registerForUpdate(String pnfCorrelationId, Runnable informConsumer);
+ void registerForUpdate(String pnfCorrelationId, Runnable informConsumer,
+ Optional<HashMap<String, String>> updateInfo);
Runnable unregister(String pnfCorrelationId);
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
index 96562fe90f..cce476f4d8 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
@@ -23,9 +23,7 @@
package org.onap.so.bpmn.infrastructure.pnf.dmaap;
import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -40,6 +38,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.AAIObjectType;
@Component
public class PnfEventReadyDmaapClient implements DmaapClient {
@@ -53,6 +55,8 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
private volatile ScheduledThreadPoolExecutor executor;
private volatile boolean dmaapThreadListenerIsRunning;
+ public volatile List<HashMap<String, String>> updateInfoMap;
+
@Autowired
public PnfEventReadyDmaapClient(Environment env) {
httpClient = HttpClientBuilder.create().build();
@@ -64,11 +68,19 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
.port(env.getProperty("pnf.dmaap.port", Integer.class)).path(env.getProperty("pnf.dmaap.topicName"))
.path(env.getProperty("pnf.dmaap.consumerGroup")).path(env.getProperty("pnf.dmaap.consumerId"))
.build());
+ updateInfoMap = new ArrayList<>();
}
@Override
- public synchronized void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) {
+ public synchronized void registerForUpdate(String pnfCorrelationId, Runnable informConsumer,
+ Optional<HashMap<String, String>> updateInfo) {
logger.debug("registering for pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId);
+ HashMap<String, String> map = updateInfo.get();
+ if (map != null && map.size() > 0) {
+ synchronized (updateInfoMap) {
+ updateInfoMap.add(map);
+ }
+ }
pnfCorrelationIdToThreadMap.put(pnfCorrelationId, informConsumer);
if (!dmaapThreadListenerIsRunning) {
startDmaapThreadListener();
@@ -78,7 +90,17 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
@Override
public synchronized Runnable unregister(String pnfCorrelationId) {
logger.debug("unregistering from pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId);
- Runnable runnable = pnfCorrelationIdToThreadMap.remove(pnfCorrelationId);
+ Runnable runnable = runnable = pnfCorrelationIdToThreadMap.remove(pnfCorrelationId);
+ synchronized (updateInfoMap) {
+ for (int i = updateInfoMap.size() - 1; i >= 0; i--) {
+ if (!updateInfoMap.get(i).containsKey("pnfCorrelationId"))
+ continue;
+ String id = updateInfoMap.get(i).get("pnfCorrelationId");
+ if (id != pnfCorrelationId)
+ continue;
+ updateInfoMap.remove(i);
+ }
+ }
if (pnfCorrelationIdToThreadMap.isEmpty()) {
stopDmaapThreadListener();
}
@@ -111,7 +133,14 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
try {
logger.debug("dmaap listener starts listening pnf ready dmaap topic");
HttpResponse response = httpClient.execute(getRequest);
- getPnfCorrelationIdListFromResponse(response).forEach(this::informAboutPnfReadyIfPnfCorrelationIdFound);
+ List<String> idList = getPnfCorrelationIdListFromResponse(response);
+
+ if (idList != null && idList.size() > 0) {
+ // send only body of response
+ registerClientResponse(idList.get(0), EntityUtils.toString(response.getEntity(), "UTF-8"));
+ }
+
+ idList.forEach(this::informAboutPnfReadyIfPnfCorrelationIdFound);
} catch (IOException e) {
logger.error("Exception caught during sending rest request to dmaap for listening event topic", e);
} finally {
@@ -136,5 +165,36 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
runnable.run();
}
}
+
+ private void registerClientResponse(String pnfCorrelationId, String response) {
+
+ String customerId = null;
+ String serviceType = null;
+ String serId = null;
+ synchronized (updateInfoMap) {
+ for (HashMap<String, String> map : updateInfoMap) {
+ if (!map.containsKey("pnfCorrelationId"))
+ continue;
+ if (pnfCorrelationId != map.get("pnfCorrelationId"))
+ continue;
+ if (!map.containsKey("globalSubscriberID"))
+ continue;
+ if (!map.containsKey("serviceType"))
+ continue;
+ if (!map.containsKey("serviceInstanceId"))
+ continue;
+ customerId = map.get("pnfCorrelationId");
+ serviceType = map.get("serviceType");
+ serId = map.get("serviceInstanceId");
+ }
+ }
+ if (customerId == null || serviceType == null || serId == null)
+ return;
+ AAIResourcesClient client = new AAIResourcesClient();
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE_METADATA, customerId,
+ serviceType, serId);
+ client.update(uri, response);
+ }
+
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy
index 8dde45be81..e547981b2d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy
@@ -27,6 +27,7 @@ import org.junit.Test
import org.mockito.MockitoAnnotations
import org.onap.so.bpmn.common.recipe.ResourceInput
import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
+import org.onap.so.bpmn.core.json.JsonUtils
import static org.mockito.Mockito.*
/**
@@ -106,6 +107,46 @@ class CreateSDNCNetworkResourceTest extends GroovyTestCase {
return resourceInputObj
}
+ private ResourceInput getUpdateResInputObj(String modelName) {
+
+ String resourceInput = "{\n" +
+ "\t\"resourceInstanceName\": \"SotnFc-wan-connection_wanconnection-37\",\n" +
+ "\t\"resourceInstanceDes\": null,\n" +
+ "\t\"globalSubscriberId\": \"sdwandemo\",\n" +
+ "\t\"serviceType\": \"CCVPN\",\n" +
+ "\t\"operationId\": \"df3387b5-4fbf-41bd-82a0-13a955ac178a\",\n" +
+ "\t\"serviceModelInfo\": {\n" +
+ "\t\t\"modelName\": \"WanConnectionSvc03\",\n" +
+ "\t\t\"modelUuid\": \"198b066c-0771-4157-9594-1824adfdda7e\",\n" +
+ "\t\t\"modelInvariantUuid\": \"43fb5165-7d03-4009-8951-a8f45d3f0148\",\n" +
+ "\t\t\"modelVersion\": \"1.0\",\n" +
+ "\t\t\"modelCustomizationUuid\": \"\",\n" +
+ "\t\t\"modelCustomizationName\": \"\",\n" +
+ "\t\t\"modelInstanceName\": \"\",\n" +
+ "\t\t\"modelType\": \"\"\n" +
+ "\t},\n" +
+ "\t\"resourceModelInfo\": {\n" +
+ "\t\t\"modelName\": \"" +
+ modelName +
+ "\",\n" +
+ "\t\t\"modelUuid\": \"6a0bf88b-343c-415b-88c1-6f73702452c4\",\n" +
+ "\t\t\"modelInvariantUuid\": \"50bc3415-2e01-4e50-a9e1-ec9584599bb3\",\n" +
+ "\t\t\"modelCustomizationUuid\": \"b205d620-84bd-4058-afa0-e3aeee8bb712\",\n" +
+ "\t\t\"modelCustomizationName\": \"\",\n" +
+ "\t\t\"modelInstanceName\": \"SotnFc-wan-connection 0\",\n" +
+ "\t\t\"modelType\": \"\"\n" +
+ "\t},\n" +
+ "\t\"resourceInstancenUuid\": null,\n" +
+ "\t\"resourceParameters\": \"{\\n\\\"locationConstraints\\\":[],\\n\\\"requestInputs\\\":{\\\"sotnfcspecwanconnection0_route-objective-function\\\":null,\\\"sotnfcspecwanconnection0_colorAware\\\":null,\\\"3rdctlspecwanconnection0_thirdPartyAdaptorRpc\\\":null,\\\"sotnfcspecwanconnection0_couplingFlag\\\":null,\\\"sotnfcspecwanconnection0_pbs\\\":null,\\\"3rdctlspecwanconnection0_thirdPartySdncId\\\":null,\\\"sotnfcspecwanconnection0_cbs\\\":null,\\\"3rdctlspecwanconnection0_thirdpartySdncName\\\":null,\\\"sotnfcspecwanconnection0_total-size\\\":null,\\\"3rdctlspecwanconnection0_templateFileName\\\":\\\"sotn_create_zte_template.json\\\",\\\"fcwanconnection0_type\\\":null,\\\"sotnfcspecwanconnection0_cir\\\":null,\\\"fcwanconnection0_uuid\\\":null,\\\"sotnfcspecwanconnection0_diversity-policy\\\":null,\\\"nf_naming\\\":true,\\\"multi_stage_design\\\":false,\\\"availability_zone_max_count\\\":1,\\\"3rdctlspecwanconnection0_restapiUrl\\\":\\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\\"max_instances\\\":null,\\\"sotnfcspecwanconnection0_reroute\\\":null,\\\"fcwanconnection0_name\\\":null,\\\"sotnfcspecwanconnection0_dualLink\\\":null,\\\"min_instances\\\":null,\\\"sotnfcspecwanconnection0_pir\\\":null,\\\"sotnfcspecwanconnection0_service-type\\\":null}\\n}\",\n" +
+ "\t\"operationType\": \"createInstance\",\n" +
+ "\t\"serviceInstanceId\": \"ffa07ae4-f820-45af-9439-1416b3bc1d39\",\n" +
+ "\t\"requestsInputs\": \"{\\r\\n\\t\\\"service\\\": {\\r\\n\\t\\t\\\"name\\\": \\\"wanconnection-37\\\",\\r\\n\\t\\t\\\"description\\\": \\\"deafe\\\",\\r\\n\\t\\t\\\"serviceInvariantUuid\\\": \\\"43fb5165-7d03-4009-8951-a8f45d3f0148\\\",\\r\\n\\t\\t\\\"serviceUuid\\\": \\\"198b066c-0771-4157-9594-1824adfdda7e\\\",\\r\\n\\t\\t\\\"globalSubscriberId\\\": \\\"sdwandemo\\\",\\r\\n\\t\\t\\\"serviceType\\\": \\\"CCVPN\\\",\\r\\n\\t\\t\\\"parameters\\\": {\\r\\n\\t\\t\\t\\\"resources\\\": [\\r\\n\\t\\t\\t],\\r\\n\\t\\t\\t\\\"requestInputs\\\": {\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sotn_create_zte_template.json\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sdwan_create_zte_template.json\\\",\\\"ont_ont_manufacturer\\\":\\\"huawei\\\",\\\"ont_ont_serial_num\\\":\\\"123\\\"\\r\\n\\t\\t\\t}\\r\\n\\t\\t}\\r\\n\\t}\\r\\n}\"\n" +
+ "}"
+
+ ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
+ return resourceInputObj
+ }
+
@Test
void testAfterCreateSDNCCall() {
init()
@@ -132,4 +173,30 @@ class CreateSDNCNetworkResourceTest extends GroovyTestCase {
def instanceId = response."response-data"."RequestData"."output"."network-response-information"."instance-id"
return instanceId
}
+
+ @Test
+ void testUpdateResourceInput() {
+ init()
+
+ def execution = getExecutionDelegate("OLT")
+ CreateSDNCNetworkResource createSDNCNetworkResource = new CreateSDNCNetworkResource()
+ def inputObject = createSDNCNetworkResource.updateResourceInput(execution)
+
+ println(inputObject.getResourceParameters())
+ assert JsonUtils.jsonElementExist(inputObject.getResourceParameters(), "requestInputs.SVLAN")
+ assert JsonUtils.jsonElementExist(inputObject.getResourceParameters(), "requestInputs.CVLAN")
+ assert JsonUtils.jsonElementExist(inputObject.getResourceParameters(), "requestInputs.manufacturer")
+ assert JsonUtils.jsonElementExist(inputObject.getResourceParameters(), "requestInputs.ONTSN")
+ }
+
+ private ExecutionEntity getExecutionDelegate(String modelName) {
+ def input = getUpdateResInputObj(modelName)
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable(Prefix + "sdncCreateReturnCode")).thenReturn("200")
+ when(mockExecution.getVariable(Prefix + "SuccessIndicator")).thenReturn("false")
+ when(mockExecution.getVariable("isActivateRequired")).thenReturn("true")
+ when(mockExecution.getVariable("CRENWKI_createSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse)
+ when(mockExecution.getVariable(Prefix + "resourceInput")).thenReturn(input.toString())
+ return mockExecution
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java
index e755214362..bfaf9cfee0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java
@@ -42,7 +42,7 @@ public class CancelDmaapSubscriptionTest {
.thenReturn(TEST_PNF_CORRELATION_ID);
when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey");
dmaapClientTest.registerForUpdate("testPnfCorrelationId", () -> {
- });
+ }, null);
// when
delegate.execute(delegateExecution);
// then
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
index 19ba18f6de..2634f03d4b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
@@ -21,7 +21,9 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
+import java.util.HashMap;
import java.util.Objects;
+import java.util.Optional;
public class DmaapClientTestImpl implements DmaapClient {
@@ -29,7 +31,8 @@ public class DmaapClientTestImpl implements DmaapClient {
private Runnable informConsumer;
@Override
- public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) {
+ public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer,
+ Optional<HashMap<String, String>> updateInfo) {
this.pnfCorrelationId = pnfCorrelationId;
this.informConsumer = informConsumer;
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
index df060ed014..93a71b31ec 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
@@ -34,10 +34,12 @@ import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
+import org.onap.so.bpmn.common.recipe.ResourceInput;
+import org.onap.so.bpmn.common.resource.ResourceRequestBuilder;
public class InformDmaapClientTest {
@Before
- public void setUp() throws Exception {
+ public void setUp() {
informDmaapClient = new InformDmaapClient();
dmaapClientTest = new DmaapClientTestImpl();
informDmaapClient.setDmaapClient(dmaapClientTest);
@@ -53,7 +55,7 @@ public class InformDmaapClientTest {
private MessageCorrelationBuilder messageCorrelationBuilder;
@Test
- public void shouldSendListenerToDmaapClient() throws Exception {
+ public void shouldSendListenerToDmaapClient() {
// when
informDmaapClient.execute(delegateExecution);
// then
@@ -63,7 +65,7 @@ public class InformDmaapClientTest {
}
@Test
- public void shouldSendListenerToDmaapClientAndSendMessageToCamunda() throws Exception {
+ public void shouldSendListenerToDmaapClientAndSendMessageToCamunda() {
// when
informDmaapClient.execute(delegateExecution);
dmaapClientTest.getInformConsumer().run();
@@ -74,11 +76,41 @@ public class InformDmaapClientTest {
inOrder.verify(messageCorrelationBuilder).correlateWithResult();
}
+ private ResourceInput getUpdateResInputObj(String modelName) {
+
+ String resourceInput = "{\n" + "\t\"resourceInstanceName\": \"SotnFc-wan-connection_wanconnection-37\",\n"
+ + "\t\"resourceInstanceDes\": null,\n" + "\t\"globalSubscriberId\": \"sdwandemo\",\n"
+ + "\t\"serviceType\": \"CCVPN\",\n" + "\t\"operationId\": \"df3387b5-4fbf-41bd-82a0-13a955ac178a\",\n"
+ + "\t\"serviceModelInfo\": {\n" + "\t\t\"modelName\": \"WanConnectionSvc03\",\n"
+ + "\t\t\"modelUuid\": \"198b066c-0771-4157-9594-1824adfdda7e\",\n"
+ + "\t\t\"modelInvariantUuid\": \"43fb5165-7d03-4009-8951-a8f45d3f0148\",\n"
+ + "\t\t\"modelVersion\": \"1.0\",\n" + "\t\t\"modelCustomizationUuid\": \"\",\n"
+ + "\t\t\"modelCustomizationName\": \"\",\n" + "\t\t\"modelInstanceName\": \"\",\n"
+ + "\t\t\"modelType\": \"\"\n" + "\t},\n" + "\t\"resourceModelInfo\": {\n" + "\t\t\"modelName\": \""
+ + modelName + "\",\n" + "\t\t\"modelUuid\": \"6a0bf88b-343c-415b-88c1-6f73702452c4\",\n"
+ + "\t\t\"modelInvariantUuid\": \"50bc3415-2e01-4e50-a9e1-ec9584599bb3\",\n"
+ + "\t\t\"modelCustomizationUuid\": \"b205d620-84bd-4058-afa0-e3aeee8bb712\",\n"
+ + "\t\t\"modelCustomizationName\": \"\",\n"
+ + "\t\t\"modelInstanceName\": \"SotnFc-wan-connection 0\",\n" + "\t\t\"modelType\": \"\"\n" + "\t},\n"
+ + "\t\"resourceInstancenUuid\": null,\n"
+ + "\t\"resourceParameters\": \"{\\n\\\"locationConstraints\\\":[],\\n\\\"requestInputs\\\":{\\\"sotnfcspecwanconnection0_route-objective-function\\\":null,\\\"sotnfcspecwanconnection0_colorAware\\\":null,\\\"3rdctlspecwanconnection0_thirdPartyAdaptorRpc\\\":null,\\\"sotnfcspecwanconnection0_couplingFlag\\\":null,\\\"sotnfcspecwanconnection0_pbs\\\":null,\\\"3rdctlspecwanconnection0_thirdPartySdncId\\\":null,\\\"sotnfcspecwanconnection0_cbs\\\":null,\\\"3rdctlspecwanconnection0_thirdpartySdncName\\\":null,\\\"sotnfcspecwanconnection0_total-size\\\":null,\\\"3rdctlspecwanconnection0_templateFileName\\\":\\\"sotn_create_zte_template.json\\\",\\\"fcwanconnection0_type\\\":null,\\\"sotnfcspecwanconnection0_cir\\\":null,\\\"fcwanconnection0_uuid\\\":null,\\\"sotnfcspecwanconnection0_diversity-policy\\\":null,\\\"nf_naming\\\":true,\\\"multi_stage_design\\\":false,\\\"availability_zone_max_count\\\":1,\\\"3rdctlspecwanconnection0_restapiUrl\\\":\\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\\"max_instances\\\":null,\\\"sotnfcspecwanconnection0_reroute\\\":null,\\\"fcwanconnection0_name\\\":null,\\\"sotnfcspecwanconnection0_dualLink\\\":null,\\\"min_instances\\\":null,\\\"sotnfcspecwanconnection0_pir\\\":null,\\\"sotnfcspecwanconnection0_service-type\\\":null}\\n}\",\n"
+ + "\t\"operationType\": \"createInstance\",\n"
+ + "\t\"serviceInstanceId\": \"ffa07ae4-f820-45af-9439-1416b3bc1d39\",\n"
+ + "\t\"requestsInputs\": \"{\\r\\n\\t\\\"service\\\": {\\r\\n\\t\\t\\\"name\\\": \\\"wanconnection-37\\\",\\r\\n\\t\\t\\\"description\\\": \\\"deafe\\\",\\r\\n\\t\\t\\\"serviceInvariantUuid\\\": \\\"43fb5165-7d03-4009-8951-a8f45d3f0148\\\",\\r\\n\\t\\t\\\"serviceUuid\\\": \\\"198b066c-0771-4157-9594-1824adfdda7e\\\",\\r\\n\\t\\t\\\"globalSubscriberId\\\": \\\"sdwandemo\\\",\\r\\n\\t\\t\\\"serviceType\\\": \\\"CCVPN\\\",\\r\\n\\t\\t\\\"parameters\\\": {\\r\\n\\t\\t\\t\\\"resources\\\": [\\r\\n\\t\\t\\t],\\r\\n\\t\\t\\t\\\"requestInputs\\\": {\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sotn_create_zte_template.json\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sdwan_create_zte_template.json\\\",\\\"ont_ont_manufacturer\\\":\\\"huawei\\\",\\\"ont_ont_serial_num\\\":\\\"123\\\"\\r\\n\\t\\t\\t}\\r\\n\\t\\t}\\r\\n\\t}\\r\\n}\"\n"
+ + "}";
+
+ ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class);
+ return resourceInputObj;
+ }
+
private DelegateExecution mockDelegateExecution() {
+ ResourceInput input = getUpdateResInputObj("OLT");
DelegateExecution delegateExecution = mock(DelegateExecution.class);
+
when(delegateExecution.getVariable(eq(ExecutionVariableNames.PNF_CORRELATION_ID)))
.thenReturn("testPnfCorrelationId");
when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey");
+ when(delegateExecution.getVariable("resourceInput")).thenReturn(input.toString());
ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
when(delegateExecution.getProcessEngineServices()).thenReturn(processEngineServices);
RuntimeService runtimeService = mock(RuntimeService.class);
@@ -86,6 +118,7 @@ public class InformDmaapClientTest {
messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
when(runtimeService.createMessageCorrelation(any())).thenReturn(messageCorrelationBuilder);
when(messageCorrelationBuilder.processInstanceBusinessKey(any())).thenReturn(messageCorrelationBuilder);
+
return delegateExecution;
}
}
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..e6bc06374c 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,42 +95,29 @@ 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();
- 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);
- }
+ @PostMapping(value = "/vnf_instances/{vnfInstanceId}/instantiate")
+ public ResponseEntity<Void> instantiateVnf(@PathVariable("vnfInstanceId") final String vnfId,
+ @RequestBody final InstantiateVnfRequest instantiateVNFRequest) {
+ LOGGER.info("Start instantiateVNFRequest {} ", instantiateVNFRequest);
- /**
- *
- * @param jobId
- * @return response entity
- * @throws InterruptedException
- */
- public ResponseEntity<Object> getJobStatus(@PathVariable("jobId") final String jobId) throws InterruptedException {
- LOGGER.info("Start getJobStatus");
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);
+ headers.add(HttpHeaders.LOCATION, svnfmService.instantiateVnf(vnfId, instantiateVNFRequest));
+ return new ResponseEntity<>(headers, HttpStatus.ACCEPTED);
}
/**
- *
+ * To delete the vnf by id
+ *
* @param vnfId
- * @return delete VNF
+ * @return InlineResponse201
*/
- @RequestMapping(method = RequestMethod.DELETE, value = "/vnf_instances/{vnfInstanceId}",
- produces = MediaType.APPLICATION_JSON)
+ @DeleteMapping(value = "/vnf_instances/{vnfInstanceId}")
@ResponseStatus(code = HttpStatus.OK)
public InlineResponse201 deleteVnf(@PathVariable("vnfInstanceId") final String vnfId) {
LOGGER.info("Start deleting Vnf------");
@@ -126,17 +125,45 @@ public class SvnfmController {
}
/**
- *
+ * To terminate the vnf by id
+ *
* @param vnfId
- * @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 {
+ @PostMapping(value = "/vnf_instances/{vnfInstanceId}/terminate")
+ public ResponseEntity<Object> terminateVnf(@PathVariable("vnfInstanceId") final String vnfId) {
LOGGER.info("Start terminateVNFRequest");
final HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", MediaType.APPLICATION_JSON);
return new ResponseEntity<>(svnfmService.terminateVnf(vnfId), headers, HttpStatus.ACCEPTED);
}
+
+
+ /**
+ * To get the status of the operation by id
+ *
+ * @param operationId
+ * @return response entity
+ * @throws InterruptedException
+ */
+ @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.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..030b073da4 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,21 @@
package org.onap.svnfm.simulator.repository;
+import java.util.List;
+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.InlineResponse201InstantiatedVnfInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo;
+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.CachePut;
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 +44,21 @@ 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);
+ }
+
+ @CachePut(value = Constant.IN_LINE_RESPONSE_201_CACHE, key = "#id")
+ public InlineResponse201 updateVnf(final InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo, final String id,
+ final List<InlineResponse201VimConnectionInfo> vimConnectionInfo) {
+ final InlineResponse201 vnf = getVnf(id);
+ vnf.setInstantiatedVnfInfo(instantiatedVnfInfo);
+ vnf.setInstantiationState(InstantiationStateEnum.INSTANTIATED);
+ vnf.setVimConnectionInfo(vimConnectionInfo);
+ return vnf;
}
- @Cacheable(value = "inlineResponse201", key = "#id")
public InlineResponse201 getVnf(final String id) {
return svnfmService.getVnf(id);
}
@@ -52,7 +67,7 @@ public class VnfmCacheRepository {
* @param vnfId
* @return
*/
- public InlineResponse201 deleteVnf(String vnfId) {
+ public InlineResponse201 deleteVnf(final String vnfId) {
// TODO
return null;
}
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..d231e1b098
--- /dev/null
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java
@@ -0,0 +1,296 @@
+package org.onap.svnfm.simulator.services;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+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.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.InlineResponse201AddResources;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections;
+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.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.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.model.Vnfds.Vnfc;
+import org.onap.svnfm.simulator.model.Vnfds.Vnfd;
+import org.onap.svnfm.simulator.repository.VnfOperationRepository;
+import org.onap.svnfm.simulator.repository.VnfmCacheRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OperationProgressor implements Runnable {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OperationProgressor.class);
+ private final VnfOperation operation;
+ private final VnfmCacheRepository vnfRepository;
+ private final VnfOperationRepository vnfOperationRepository;
+ private final ApplicationConfig applicationConfig;
+ private 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 VnfmCacheRepository vnfRepository,
+ final VnfOperationRepository vnfOperationRepository, final ApplicationConfig applicationConfig,
+ final Vnfds vnfds, final SubscriptionService subscriptionService) {
+ this.operation = operation;
+ this.vnfRepository = vnfRepository;
+ 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 InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo = createInstantiatedVnfInfo(grantResponse);
+ vnfRepository.updateVnf(instantiatedVnfInfo, operation.getVnfInstanceId(),
+ getVimConnections(grantResponse));
+
+ sleep(10000);
+ setState(InlineResponse200.OperationStateEnum.COMPLETED);
+ final VnfLcmOperationOccurrenceNotification notificationOfCompleted =
+ buildNotification(NotificationStatusEnum.RESULT, OperationStateEnum.COMPLETED);
+ notificationOfCompleted.setAffectedVnfcs(getVnfcs(instantiatedVnfInfo.getVnfcResourceInfo()));
+
+ 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());
+
+ 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<>();
+ 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(ChangeTypeEnum.ADDED);
+ 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 = vnfRepository.getVnf(operation.getVnfInstanceId()).getVnfdId();
+ grantRequest.setVnfdId(vnfdId);
+ grantRequest.setAddResources(getAddResources(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;
+ }
+
+ private 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;
+ }
+
+ 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 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());
+ }
+
+ for (final Vnfd vnfd : vnfds.getVnfdList()) {
+ if (vnfd.getVnfdId().equals(vnfRepository.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());
+ 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;
+ }
+
+ 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..cac5075682 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,35 @@
package org.onap.svnfm.simulator.services;
import java.lang.reflect.InvocationTargetException;
-import java.util.Optional;
+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.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.VnfmCacheRepository;
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.support.SimpleValueWrapper;
import org.springframework.stereotype.Service;
/**
- *
+ *
* @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
* @author Ronan Kenny (ronan.kenny@est.tech)
*/
@@ -47,27 +60,44 @@ public class SvnfmService {
VnfmRepository vnfmRepository;
@Autowired
- VnfJobRepository vnfJobRepository;
+ VnfmCacheRepository vnfRepository;
+
+ @Autowired
+ 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);
}
@@ -75,94 +105,80 @@ public class SvnfmService {
}
/**
- *
+ *
* @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 OperationProgressor(vnfOperation, vnfRepository, 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) {
+ public Object terminateVnf(final String vnfId) {
// TODO
return null;
}
+
+ public void registerSubscription(final LccnSubscriptionRequest subscription) {
+ subscriptionService.registerSubscription(subscription);
+ }
}
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..7c038b823f 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
@@ -22,30 +22,36 @@ package org.onap.svnfm.simulator.services;
import java.lang.reflect.InvocationTargetException;
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 +61,7 @@ public class VnfmHelper {
}
/**
- *
+ *
* @param vnfInstance
* @return inlineResponse201
* @throws IllegalAccessException
@@ -68,6 +74,21 @@ public class VnfmHelper {
inlineResponse201.setVnfdVersion(Constant.VNFD_VERSION);
inlineResponse201.setVnfSoftwareVersion(Constant.VNF_SOFTWARE_VERSION);
inlineResponse201.setInstantiationState(InstantiationStateEnum.NOT_INSTANTIATED);
+ inlineResponse201.setVnfConfigurableProperties(Constant.VNF_CONFIG_PROPERTIES);
+ addAdditionalPRopertyInlineResponse201(inlineResponse201);
return inlineResponse201;
}
+
+ 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));
}
}