aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java1
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java1
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java1
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/MsoTenantTest.java2
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentParameterTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy12
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn3
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java55
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java54
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java122
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java24
20 files changed, 274 insertions, 43 deletions
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java
index d45f685795..1506fda817 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java
@@ -28,6 +28,7 @@ public class MsoCloudifyExceptionTest {
MsoCloudifyException mcl = new MsoCloudifyException(200, "message", "detail", e);
mce.setPendingWorkflow(pendingWorkflow);
assert (mcl.toString() != null);
+ assertNotNull(mce);
}
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java
index 08b2356fdc..25dcae3c2c 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java
@@ -24,6 +24,7 @@ public class MsoCloudifyTest {
MsoBlueprintAlreadyExists mbae = new MsoBlueprintAlreadyExists("blueprintId", "cloud");
MsoCloudifyManagerNotFound mcm = new MsoCloudifyManagerNotFound("cloudSiteId");
MsoDeploymentAlreadyExists mdae = new MsoDeploymentAlreadyExists("deploymentId", "cloud");
+ assertNotNull((mbae));
}
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java
index 48c5c877a5..dc74d83d04 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java
@@ -27,6 +27,7 @@ public class MsoCloudifyTimeoutTest {
MsoCloudifyTimeout mct = new MsoCloudifyTimeout(execution);
mct.getExecution();
assert (mct.toString() != null);
+ assertNotNull(mct);
}
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/MsoTenantTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/MsoTenantTest.java
index ece5b21f19..3f2a6263d3 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/MsoTenantTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/MsoTenantTest.java
@@ -15,6 +15,7 @@
package org.onap.so.openstack.beans;
+import static org.junit.Assert.*;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
@@ -32,5 +33,6 @@ public class MsoTenantTest {
assert (ms.getMetadata().equals(map));
assert (ms.getTenantId().equals("tenantId"));
assert (ms.getTenantName().equals("tenantName"));
+ assertNotNull(map);
}
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentParameterTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentParameterTest.java
index 954f237ffe..de39df7b35 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentParameterTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentParameterTest.java
@@ -17,6 +17,7 @@ package org.onap.so.openstack.utils;
import static org.mockito.Mockito.mock;
import org.junit.Test;
+import static org.junit.Assert.*;
public class MsoHeatEnvironmentParameterTest {
@@ -35,6 +36,7 @@ public class MsoHeatEnvironmentParameterTest {
// assertTrue(op.equals(hep));
meo.equals(op);
meo.hashCode();
+ assertNotNull(mea);
}
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java
index 6e3312b1d3..106a96a091 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java
@@ -16,6 +16,7 @@
package org.onap.so.adapters.tenant.exceptions;
import org.junit.Test;
+import static org.junit.Assert.*;
public class TenantAlreadyExistsTest {
@@ -23,5 +24,6 @@ public class TenantAlreadyExistsTest {
public void test() {
TenantAlreadyExists tar = new TenantAlreadyExists("name", "cloudId", "tenantId");
assert (tar != null);
+ assertNotNull(tar);
}
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java
index 7314a9f1e2..ece92b4ac0 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java
@@ -19,6 +19,7 @@ import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.so.openstack.exceptions.MsoExceptionCategory;
+import static org.junit.Assert.*;
public class TenantExceptionBeanTest {
@@ -38,5 +39,6 @@ public class TenantExceptionBeanTest {
teb.setCategory(MsoExceptionCategory.USERDATA);
assert (teb.getMessage().equals("message"));
assert (teb.getCategory() != null);
+ assertNotNull(teb);
}
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java
index 83eb1f1bdc..1ce4c664ac 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java
@@ -19,6 +19,7 @@ import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.so.openstack.exceptions.MsoExceptionCategory;
+import static org.junit.Assert.*;
public class TenantExceptionTest {
@@ -40,5 +41,6 @@ public class TenantExceptionTest {
te.setFaultInfo(teb);
assert (te.getFaultInfo() != null);
assert (te.getFaultInfo().equals(teb));
+ assertNotNull(teb);
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
index 84da1e4ec9..26936bfd71 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
@@ -199,7 +199,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor {
* 再次调用deleteE2EServiceInstance接口,然后获取到operationid,
*/
void sendRequest2NSMFWF(DelegateExecution execution) {
- LOGGER.trace("begin preRequestSend2NSMF")
+ LOGGER.debug("begin preRequestSend2NSMF")
try {
//url:/onap/so/infra/e2eServiceInstances/v3/{serviceInstanceId}"
def NSMF_endpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution)
@@ -213,9 +213,13 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor {
"""
requestBody.replaceAll("\\s+", "")
- String basicAuthValue = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
+ String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
+ String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
+ String basicAuthValue = utils.encrypt(basicAuth, msoKey)
+ String encodeString = utils.getBasicAuth(basicAuthValue, msoKey)
+
HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO)
- httpClient.addAdditionalHeader("Authorization", basicAuthValue)
+ httpClient.addAdditionalHeader("Authorization", encodeString)
httpClient.addAdditionalHeader("Accept", "application/json")
Response httpResponse = httpClient.delete(requestBody)
handleNSSMFWFResponse(httpResponse, execution)
@@ -228,7 +232,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- LOGGER.trace("exit preRequestSend2NSMF")
+ LOGGER.debug("exit preRequestSend2NSMF")
}
/**
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy
index f5e90000b3..d22ee5e82f 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy
@@ -77,7 +77,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor {
checkAndSetRequestParam(siRequest,"globalSubscriberId",false, execution)
checkAndSetRequestParam(siRequest,"serviceType",false, execution)
checkAndSetRequestParam(siRequest,"operationId",false, execution)
-
+ checkAndSetRequestParam(siRequest,"scriptName",false, execution)
//prepare init operation status
execution.setVariable("progress", "0")
execution.setVariable("result", "processing")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
index 4be6ca7e49..547cb6cad7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
@@ -139,12 +139,14 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
String profileId = currentNSSI['profileId']
String nssiId = currentNSSI['nssiServiceInstanceId']
String nsiId = currentNSSI['nsiServiceInstanceId']
+ String scriptName = execution.getVariable("scriptName")
DeAllocateNssi deAllocateNssi = new DeAllocateNssi()
deAllocateNssi.setNsiId(nsiId)
deAllocateNssi.setNssiId(nssiId)
deAllocateNssi.setTerminateNssiOption(0)
deAllocateNssi.setSnssaiList(Arrays.asList(snssai))
+ deAllocateNssi.setScriptName(scriptName)
NssiDeAllocateRequest deAllocateRequest = new NssiDeAllocateRequest()
deAllocateRequest.setDeAllocateNssi(deAllocateNssi)
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn
index 3024e39c4e..8dd326aa16 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0prw6yo" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0prw6yo" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.3">
<bpmn:process id="DeleteSliceService" name="DeleteSliceService" isExecutable="true">
<bpmn:startEvent id="StartEvent_1" name="start">
<bpmn:outgoing>SequenceFlow_1ti9sxe</bpmn:outgoing>
@@ -102,6 +102,7 @@ dss.deleteSliceServiceInstance(execution)</bpmn:script>
<camunda:in source="operationId" target="operationId" />
<camunda:in source="operationType" target="operationType" />
<camunda:out source="WorkflowException" target="WorkflowException" />
+ <camunda:in source="scriptName" target="scriptName" />
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_16lh6o6</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0nl4kfh</bpmn:outgoing>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java
index ce0f2c7417..6831a656a8 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java
@@ -24,7 +24,6 @@ import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.EXT_V
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.FORWARD_SLASH;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.PRELOAD_VNFS_URL;
import java.io.IOException;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -32,14 +31,14 @@ import java.util.stream.Collectors;
import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
+import org.onap.so.jsonpath.JsonPathUtil;
import org.onap.so.client.sdnc.SDNCClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.jayway.jsonpath.JsonPath;
-import net.minidev.json.JSONArray;
/**
* This class retrieve pre-load data from SDNC using <br/>
@@ -56,9 +55,12 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider
private final SDNCClient sdncClient;
+ private final ObjectMapper mapper;
+
@Autowired
public SdncInputParametersProvider(final SDNCClient sdncClient) {
this.sdncClient = sdncClient;
+ this.mapper = new ObjectMapper();
}
@Override
@@ -70,21 +72,23 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider
try {
LOGGER.debug("Will query sdnc for input parameters using url: {}", url);
final String jsonResponse = sdncClient.get(url);
-
- final JSONArray vnfParametersArray = JsonPath.read(jsonResponse, VNF_PARAMETERS_PATH);
- if (vnfParametersArray != null) {
- for (int index = 0; index < vnfParametersArray.size(); index++) {
- final Object vnfParametersObject = vnfParametersArray.get(index);
- if (vnfParametersObject instanceof JSONArray) {
- final JSONArray vnfParameters = (JSONArray) vnfParametersObject;
- final Map<String, String> vnfParametersMap = getVnfParameterMap(vnfParameters);
- final Map<String, String> additionalParameters = getAdditionalParameters(vnfParametersMap);
- final List<ExternalVirtualLink> extVirtualLinks = getExtVirtualLinks(vnfParametersMap);
- final InputParameter inputParameter = new InputParameter(additionalParameters, extVirtualLinks);
- LOGGER.info("InputParameter found in sdnc response : {}", inputParameter);
- return inputParameter;
- }
+ final String json = JsonPathUtil.getInstance().locateResult(jsonResponse, VNF_PARAMETERS_PATH).orElse(null);
+
+ try {
+
+ if (json != null) {
+ final List<VnfParameter> vnfParametersArray =
+ mapper.readValue(json, new TypeReference<List<VnfParameter>>() {});
+ final Map<String, String> vnfParametersMap = getVnfParameterMap(vnfParametersArray);
+ final Map<String, String> additionalParameters = getAdditionalParameters(vnfParametersMap);
+ final List<ExternalVirtualLink> extVirtualLinks = getExtVirtualLinks(vnfParametersMap);
+ final InputParameter inputParameter = new InputParameter(additionalParameters, extVirtualLinks);
+ LOGGER.info("InputParameter found in sdnc response : {}", inputParameter);
+ return inputParameter;
}
+
+ } catch (final IOException exception) {
+ LOGGER.error("Unable to parse vnf parameters : {}", json, exception);
}
} catch (final Exception exception) {
LOGGER.error("Unable to retrieve/parse input parameters using URL: {} ", url, exception);
@@ -112,19 +116,12 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider
}
- private Map<String, String> getVnfParameterMap(final JSONArray array) {
- try {
- if (array != null) {
- final ObjectMapper mapper = new ObjectMapper();
- final VnfParameter[] readValue = mapper.readValue(array.toJSONString(), VnfParameter[].class);
- LOGGER.debug("Vnf parameters: {}", Arrays.asList(readValue));
- return Arrays.asList(readValue).stream()
- .filter(vnfParam -> vnfParam.getName() != null && vnfParam.getValue() != null)
- .collect(Collectors.toMap(VnfParameter::getName, VnfParameter::getValue));
- }
- } catch (final IOException exception) {
- LOGGER.error("Unable to parse vnf parameters : {}", array, exception);
+ private Map<String, String> getVnfParameterMap(final List<VnfParameter> array) {
+ if (array != null) {
+ return array.stream().filter(vnfParam -> vnfParam.getName() != null && vnfParam.getValue() != null)
+ .collect(Collectors.toMap(VnfParameter::getName, VnfParameter::getValue));
}
+
return Collections.emptyMap();
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java
index 7184bba377..3b22cd9d81 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java
@@ -98,7 +98,8 @@ public class AAIPnfResources {
pnfFromAai.getPnfName());
} else {
String errorMessage = String.format(
- "pnf with name %s already exists with orchestration status %s, only status Inventoried allows to use existing pnf",
+ "pnf with name %s already exists with orchestration status %s, existing pnf can be used only "
+ + "if status is not set or set as Inventoried",
pnfFromAai.getPnfName(), pnfFromAai.getOrchestrationStatus());
logger.error(errorMessage);
throw new Exception(errorMessage);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
index 5e9b4c7592..59cd53edd5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
@@ -149,7 +149,8 @@ public class AAIPnfResourcesTest extends TestDataSetup {
} catch (Exception e) {
// then
assertThat(e.getMessage()).isEqualTo(String.format(
- "pnf with name %s already exists with orchestration status Active, only status Inventoried allows to use existing pnf",
+ "pnf with name %s already exists with orchestration status Active, existing pnf can be used only "
+ + "if status is not set or set as Inventoried",
PNF_NAME));
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java
index 3335410658..21aa89be05 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java
@@ -21,12 +21,17 @@
package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
public class E2EServiceInstanceDeleteRequest {
private String globalSubscriberId;
private String serviceType;
+ @JsonIgnore
+ private String scriptName;
+
public String getGlobalSubscriberId() {
return globalSubscriberId;
}
@@ -43,4 +48,11 @@ public class E2EServiceInstanceDeleteRequest {
this.serviceType = serviceType;
}
+ public String getScriptName() {
+ return scriptName;
+ }
+
+ public void setScriptName(String scriptName) {
+ this.scriptName = scriptName;
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java
index a87e94a6e0..fc0048bacf 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java
@@ -1,7 +1,10 @@
package org.onap.so.apihandlerinfra.infra.rest;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.Optional;
+import java.util.stream.Collectors;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.L3Network;
import org.onap.aai.domain.yang.LInterface;
@@ -9,13 +12,16 @@ import org.onap.aai.domain.yang.Service;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.VfModules;
import org.onap.aai.domain.yang.VolumeGroup;
+import org.onap.aai.domain.yang.VolumeGroups;
import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
import org.onap.aaiclient.client.aai.AAIDSLQueryClient;
import org.onap.aaiclient.client.aai.AAIObjectPlurals;
import org.onap.aaiclient.client.aai.AAIObjectType;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.aaiclient.client.graphinventory.entities.DSLQuery;
import org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder;
@@ -164,4 +170,52 @@ public class AAIDataRetrieval {
return aaiResourcesClient;
}
+ public boolean isVnfRelatedToVFModule(String vnfId) {
+ return !getVfModulesOfVnf(vnfId).isEmpty();
+ }
+
+ public List<VfModule> getVfModulesOfVnf(String vnfId) {
+ List<VfModule> vfModuleList = new ArrayList<VfModule>();
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, vnfId);
+ Optional<VfModules> vfModules = getAaiResourcesClient().get(VfModules.class, uri);
+ if (!vfModules.isPresent() || vfModules.get().getVfModule().isEmpty()) {
+ logger.debug("No VfModules attached to Vnf in AAI : {}", vnfId);
+ } else {
+ vfModuleList = vfModules.get().getVfModule();
+ }
+ return vfModuleList;
+ }
+
+ public Optional<String> getVfModuleIdsByVnfId(String vnfId) {
+ List<VfModule> vfModulesList = getVfModulesOfVnf(vnfId);
+ if (!vfModulesList.isEmpty()) {
+ return Optional.of(vfModulesList.stream().map(item -> item.getVfModuleId()).collect(Collectors.toList())
+ .stream().sorted().collect(Collectors.joining(",")));
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ public List<VolumeGroup> getVolumeGroupsOfVnf(String vnfId) {
+ List<VolumeGroup> volumeGroupList = new ArrayList<VolumeGroup>();
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ .relatedTo(AAIObjectPlurals.VOLUME_GROUP);
+ Optional<VolumeGroups> volumeGroups = getAaiResourcesClient().get(VolumeGroups.class, uri);
+ if (!volumeGroups.isPresent() || volumeGroups.get().getVolumeGroup().isEmpty()) {
+ logger.debug("No VolumeGroups attached to Vnf in AAI : {}", vnfId);
+ } else {
+ volumeGroupList = volumeGroups.get().getVolumeGroup();
+ }
+ return volumeGroupList;
+ }
+
+ public Optional<String> getVolumeGroupIdsByVnfId(String vnfId) {
+ List<VolumeGroup> volumeGroupList = getVolumeGroupsOfVnf(vnfId);
+ if (!volumeGroupList.isEmpty()) {
+ return Optional.of(volumeGroupList.stream().map(item -> item.getVolumeGroupId())
+ .collect(Collectors.toList()).stream().sorted().collect(Collectors.joining(",")));
+ } else {
+ return Optional.empty();
+ }
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
index 37e3f0cb2e..a48fca8d0f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
@@ -25,8 +25,16 @@ public class VnfDeleteValidator implements RequestValidator {
@Override
public Optional<String> validate(Map<String, String> instanceIdMap, ServiceInstancesRequest request,
Map<String, String> queryParams) {
- if (aaiDataRetrieval.isVnfRelatedToVolumes(instanceIdMap.get("vnfInstanceId"))) {
- return Optional.of("Cannot delete vnf it is still related to existing volume groups");
+ final Optional<String> volumeGroupIds =
+ aaiDataRetrieval.getVolumeGroupIdsByVnfId(instanceIdMap.get("vnfInstanceId"));
+ final Optional<String> vfModuleIds = aaiDataRetrieval.getVfModuleIdsByVnfId(instanceIdMap.get("vnfInstanceId"));
+
+ if (volumeGroupIds.isPresent()) {
+ return Optional.of(String.format("Cannot delete vnf it is still related to existing volume group Ids - %s",
+ volumeGroupIds.get()));
+ } else if (vfModuleIds.isPresent()) {
+ return Optional.of(String.format("Cannot delete vnf it is still related to existing vfModule Ids - %s",
+ vfModuleIds.get()));
} else {
return Optional.empty();
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java
new file mode 100644
index 0000000000..9d5d80592d
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.infra.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.VfModules;
+import org.onap.aai.domain.yang.VolumeGroup;
+import org.onap.aai.domain.yang.VolumeGroups;
+import org.onap.aaiclient.client.aai.AAIObjectPlurals;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AAIDataRetrievalTest {
+ @Mock
+ private AAIResourcesClient aaiResourcesClient;
+
+ @InjectMocks
+ private AAIDataRetrieval aaiDataRetrieval = new AAIDataRetrieval();
+
+ @Test
+ public void getVfModulesOfVnfTest() {
+ VfModules vfModules = getVfModules();
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "vnfId");
+ doReturn(Optional.of(vfModules)).when(aaiResourcesClient).get(VfModules.class, uri);
+ List<VfModule> vfModulesList = aaiDataRetrieval.getVfModulesOfVnf("vnfId");
+ assertEquals("vfm1", vfModulesList.get(0).getVfModuleId());
+
+ Optional<String> vfModuleIds = aaiDataRetrieval.getVfModuleIdsByVnfId("vnfId");
+ assertEquals(Optional.of("vfm1,vfm2"), vfModuleIds);
+ }
+
+ @Test
+ public void getVfModulesOfVnfWhenNoneTest() {
+ VfModules vfModules = new VfModules();
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "vnfId");
+ doReturn(Optional.of(vfModules)).when(aaiResourcesClient).get(VfModules.class, uri);
+ List<VfModule> vfModulesList = aaiDataRetrieval.getVfModulesOfVnf("vnfId");
+ assertEquals(true, vfModulesList.isEmpty());
+
+ Optional<String> vfModuleIds = aaiDataRetrieval.getVfModuleIdsByVnfId("vnfId");
+ assertEquals(false, vfModuleIds.isPresent());
+ }
+
+ @Test
+ public void getVolumeGroupsOfVnfTest() throws Exception {
+ VolumeGroups volumeGroups = getVolumeGroups();
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")
+ .relatedTo(AAIObjectPlurals.VOLUME_GROUP);
+ doReturn(Optional.of(volumeGroups)).when(aaiResourcesClient).get(VolumeGroups.class, uri);
+ List<VolumeGroup> volumeGroupList = aaiDataRetrieval.getVolumeGroupsOfVnf("vnfId");
+ assertEquals("vg1", volumeGroupList.get(0).getVolumeGroupId());
+ Optional<String> volumeGroupIds = aaiDataRetrieval.getVolumeGroupIdsByVnfId("vnfId");
+ assertEquals(Optional.of("vg1,vg2"), volumeGroupIds);
+ }
+
+ @Test
+ public void getVolumeGroupsOfVnfWhenNoneTest() throws Exception {
+ VolumeGroups volumeGroups = new VolumeGroups();
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")
+ .relatedTo(AAIObjectPlurals.VOLUME_GROUP);
+ doReturn(Optional.of(volumeGroups)).when(aaiResourcesClient).get(VolumeGroups.class, uri);
+ List<VolumeGroup> volumeGroupList = aaiDataRetrieval.getVolumeGroupsOfVnf("vnfId");
+ assertEquals(true, volumeGroupList.isEmpty());
+ Optional<String> volumeGroupIds = aaiDataRetrieval.getVolumeGroupIdsByVnfId("vnfId");
+ assertEquals(false, volumeGroupIds.isPresent());
+ }
+
+
+ private VfModules getVfModules() {
+ VfModule vfModule1 = new VfModule();
+ VfModule vfModule2 = new VfModule();
+ vfModule1.setVfModuleId("vfm1");
+ vfModule2.setVfModuleId("vfm2");
+ VfModules vfModules = new VfModules();
+ vfModules.getVfModule().add(vfModule1);
+ vfModules.getVfModule().add(vfModule2);
+ return vfModules;
+ }
+
+ private VolumeGroups getVolumeGroups() {
+ VolumeGroup volumeGroup1 = new VolumeGroup();
+ volumeGroup1.setVolumeGroupId("vg1");
+ VolumeGroup volumeGroup2 = new VolumeGroup();
+ volumeGroup2.setVolumeGroupId("vg2");
+ VolumeGroups volumeGroups = new VolumeGroups();
+ volumeGroups.getVolumeGroup().add(volumeGroup1);
+ volumeGroups.getVolumeGroup().add(volumeGroup2);
+ return volumeGroups;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java
index d4f57d3146..65ce355ad1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java
@@ -2,6 +2,7 @@ package org.onap.so.apihandlerinfra.infra.rest.validator;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.doReturn;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@@ -49,19 +50,34 @@ public class VnfDeleteValidatorTest {
}
@Test
- public void validateSuccessTest() {
+ public void validateFailureVfModuleVnfTest() {
instanceIdMap.put("vnfInstanceId", "1");
- when(aaiDataRetrieval.isVnfRelatedToVolumes("1")).thenReturn(false);
+ doReturn(Optional.of("test")).when(aaiDataRetrieval).getVfModuleIdsByVnfId("1");
+ Optional<String> result = vnfValidator.validate(instanceIdMap, null, null);
+ assertEquals(true, result.isPresent());
+ }
+
+ @Test
+ public void validateSuccessVfModuleVnfTest() {
+ instanceIdMap.put("vnfInstanceId", "1");
+ doReturn(Optional.empty()).when(aaiDataRetrieval).getVfModuleIdsByVnfId("1");
Optional<String> result = vnfValidator.validate(instanceIdMap, null, null);
assertEquals(false, result.isPresent());
}
@Test
- public void validateFailureVnfTest() {
+ public void validateFailureVolumeGroupVnfTest() {
instanceIdMap.put("vnfInstanceId", "1");
- when(aaiDataRetrieval.isVnfRelatedToVolumes("1")).thenReturn(true);
+ doReturn(Optional.of("test")).when(aaiDataRetrieval).getVolumeGroupIdsByVnfId("1");
Optional<String> result = vnfValidator.validate(instanceIdMap, null, null);
assertEquals(true, result.isPresent());
}
+ @Test
+ public void validateSuccessVolumeGroupVnfTest() {
+ instanceIdMap.put("vnfInstanceId", "1");
+ doReturn(Optional.empty()).when(aaiDataRetrieval).getVolumeGroupIdsByVnfId("1");
+ Optional<String> result = vnfValidator.validate(instanceIdMap, null, null);
+ assertEquals(false, result.isPresent());
+ }
}