aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy10
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java46
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java24
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiPnf.json31
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java28
10 files changed, 149 insertions, 13 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy
index 89c3ab7c8b..12cd0dde0b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy
@@ -293,11 +293,11 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor {
//2. profile info
- Integer expDataRateDL = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.expDataRateDL")
- Integer expDataRateUL = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.expDataRateUL")
- Integer latency = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.latency")
- Integer maxNumberOfUEs = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.maxNumberofUEs")
- String uEMobilityLevel = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.uemobilityLevel")
+ Integer expDataRateDL = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.expDataRateDL") as Integer
+ Integer expDataRateUL = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.expDataRateUL") as Integer
+ Integer latency = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.latency") as Integer
+ Integer maxNumberOfUEs = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.maxNumberofUEs") as Integer
+ String uEMobilityLevel = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.uEMobilityLevel")
String resourceSharingLevel = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.resourceSharingLevel")
String coverageArea = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.coverageAreaList")
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 b8562ba6b5..7184bba377 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
@@ -22,6 +22,9 @@ package org.onap.so.client.orchestration;
import com.google.common.base.Strings;
import java.util.Optional;
+import org.onap.aai.domain.yang.RelatedToProperty;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
@@ -68,8 +71,15 @@ public class AAIPnfResources {
public void checkIfPnfExistsInAaiAndCanBeUsed(String pnfName) throws Exception {
Optional<org.onap.aai.domain.yang.Pnf> pnfFromAai = injectionHelper.getAaiClient()
.get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfName));
- if (pnfFromAai.isPresent() && isOrchestrationStatusSet(pnfFromAai.get())) {
- checkOrchestrationStatusOfExistingPnf(pnfFromAai.get());
+ if (pnfFromAai.isPresent()) {
+ checkIfPnfCanBeUsed(pnfFromAai.get());
+ }
+ }
+
+ private void checkIfPnfCanBeUsed(org.onap.aai.domain.yang.Pnf pnfFromAai) throws Exception {
+ isRelatedToService(pnfFromAai);
+ if (isOrchestrationStatusSet(pnfFromAai)) {
+ checkOrchestrationStatusOfExistingPnf(pnfFromAai);
}
}
@@ -92,7 +102,39 @@ public class AAIPnfResources {
pnfFromAai.getPnfName(), pnfFromAai.getOrchestrationStatus());
logger.error(errorMessage);
throw new Exception(errorMessage);
+ }
+ }
+ private void isRelatedToService(org.onap.aai.domain.yang.Pnf pnfFromAai) throws Exception {
+ if (pnfFromAai.getRelationshipList() != null) {
+ for (Relationship relationship : pnfFromAai.getRelationshipList().getRelationship()) {
+ if (relationship.getRelatedTo().equals("service-instance")) {
+ String errorMessage = prepareRelationErrorMessage(pnfFromAai, relationship);
+ logger.error(errorMessage);
+ throw new Exception(errorMessage);
+ }
+ }
+ }
+ }
+
+ private String prepareRelationErrorMessage(org.onap.aai.domain.yang.Pnf pnfFromAai, Relationship relationship) {
+ String serviceInstanceName = "";
+ String serviceInstanceId = "";
+
+ for (RelationshipData relationshipData : relationship.getRelationshipData()) {
+ if (relationshipData.getRelationshipKey().equals("service-instance.service-instance-id")) {
+ serviceInstanceId = relationshipData.getRelationshipValue();
+ break;
+ }
+ }
+ for (RelatedToProperty relatedToProperty : relationship.getRelatedToProperty()) {
+ if (relatedToProperty.getPropertyKey().equals("service-instance.service-instance-name")) {
+ serviceInstanceName = relatedToProperty.getPropertyValue();
+ break;
+ }
}
+ return String.format(
+ "Pnf with name %s exist with orchestration status %s and is related to %s service with certain service-instance-id: %s",
+ pnfFromAai.getPnfName(), pnfFromAai.getOrchestrationStatus(), serviceInstanceName, serviceInstanceId);
}
}
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 15c4b48d66..5e9b4c7592 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
@@ -29,7 +29,10 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.io.File;
+import java.io.IOException;
import java.util.Optional;
+import com.fasterxml.jackson.databind.ObjectMapper;
import joptsimple.internal.Strings;
import org.junit.Before;
import org.junit.Test;
@@ -151,6 +154,27 @@ public class AAIPnfResourcesTest extends TestDataSetup {
}
}
+ @Test
+ public void existingPnfInAaiIsRelatedToService() throws IOException {
+ // given
+ final String relatedTo = "service-instance";
+ final String serviceInstanceId = "service-instance-id";
+ final String path = "src/test/resources/__files/BuildingBlocks/aaiPnf.json";
+ org.onap.aai.domain.yang.Pnf pnfFromAai =
+ new ObjectMapper().readValue(new File(path), org.onap.aai.domain.yang.Pnf.class);
+ when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai));
+ // when
+ try {
+ testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME);
+ } catch (Exception e) {
+ // then
+ assertThat(e.getMessage()).isEqualTo(String.format(
+ "Pnf with name %s exist with orchestration status %s and is related to %s service with certain service-instance-id: %s",
+ PNF_NAME, OrchestrationStatus.ACTIVE, relatedTo, serviceInstanceId));
+ }
+ }
+
private org.onap.aai.domain.yang.Pnf createPnf(String orchestrationStatus) {
org.onap.aai.domain.yang.Pnf pnfFromAai = new org.onap.aai.domain.yang.Pnf();
pnfFromAai.setPnfName(PNF_NAME);
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiPnf.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiPnf.json
new file mode 100644
index 0000000000..c4600d94a0
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiPnf.json
@@ -0,0 +1,31 @@
+{
+ "pnfName": "pnfTest",
+ "pnfId": "pnfId",
+ "orchestrationStatus": "Active",
+ "resourceVersion": "resourceVersion",
+ "relationshipList": {
+ "relationship": [
+ {
+ "relatedTo": "service-instance",
+ "relationshipLabel": "org.onap.relationships.inventory.ComposedOf",
+ "relatedLink": "relatedLink",
+ "relationshipData": [
+ {
+ "relationshipKey": "relationshipKey",
+ "relationshipValue": "relationshipValue"
+ },
+ {
+ "relationshipKey": "service-instance.service-instance-id",
+ "relationshipValue": "service-instance-id"
+ }
+ ],
+ "relatedToProperty": [
+ {
+ "propertyKey": "service-instance.service-instance-name",
+ "propertyValue": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java
index f75897dda1..89c5cbed9b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java
@@ -8,8 +8,9 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
-
+@Component
public class NetworkDeleteValidator implements RequestValidator {
@Autowired
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java
index 1dea57ad9c..50938e6826 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java
@@ -24,7 +24,9 @@ import java.util.Map;
import java.util.Optional;
import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.springframework.stereotype.Component;
+@Component
public interface RequestValidator {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java
index 61f757ba64..843d94ce6c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java
@@ -8,8 +8,10 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+@Component
public class ServiceInstanceDeleteValidator implements RequestValidator {
@Autowired
@@ -17,8 +19,17 @@ public class ServiceInstanceDeleteValidator implements RequestValidator {
@Override
public boolean shouldRunFor(String requestUri, ServiceInstancesRequest request, Actions action) {
+ boolean isALaCarte = false;
+ if (request.getRequestDetails() != null && request.getRequestDetails().getRequestParameters() != null) {
+ if (request.getRequestDetails().getRequestParameters().getALaCarte() == null) {
+ isALaCarte = false;
+ } else {
+ isALaCarte = request.getRequestDetails().getRequestParameters().getALaCarte();
+ }
+
+ }
return Pattern.compile("[Vv][5-8]/serviceInstances/[^/]+").matcher(requestUri).matches()
- && action.equals(Action.deleteInstance);
+ && action.equals(Action.deleteInstance) && isALaCarte;
}
@Override
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 d54e60d153..37e3f0cb2e 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
@@ -8,8 +8,9 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
-
+@Component
public class VnfDeleteValidator implements RequestValidator {
@Autowired
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
index f010d47f70..e3598af31d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
@@ -8,7 +8,9 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+@Component
public class VolumeGroupDeleteValidator implements RequestValidator {
@Autowired
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java
index c334d522b6..f461df3720 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java
@@ -5,6 +5,7 @@ import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -14,6 +15,8 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.apihandlerinfra.infra.rest.validators.ServiceInstanceDeleteValidator;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@@ -30,22 +33,41 @@ public class ServiceInstanceDeleteValidatorTest {
private Map<String, String> instanceIdMap = new HashMap<>();
+ private ServiceInstancesRequest serviceInstancesRequest;
+
+ @Before
+ public void before() {
+ serviceInstancesRequest = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setaLaCarte(true);
+ requestDetails.setRequestParameters(requestParameters);
+ serviceInstancesRequest.setRequestDetails(requestDetails);
+ }
+
@Test
public void validateURIMatchTest() {
- assertEquals(true, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", new ServiceInstancesRequest(),
+ assertEquals(true, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", serviceInstancesRequest,
Action.deleteInstance));
}
@Test
public void validateURINotMatchTest() {
assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf/vnfs/asdfasdf",
- new ServiceInstancesRequest(), Action.deleteInstance));
+ serviceInstancesRequest, Action.deleteInstance));
}
@Test
public void validateURINotMatch2Test() {
assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf/update",
- new ServiceInstancesRequest(), Action.deleteInstance));
+ serviceInstancesRequest, Action.deleteInstance));
+ }
+
+ @Test
+ public void validateNotALaCarteTest() {
+ serviceInstancesRequest.getRequestDetails().getRequestParameters().setaLaCarte(false);
+ assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", serviceInstancesRequest,
+ Action.deleteInstance));
}
@Test