aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java116
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java1
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java40
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/__files/pathed-sriov-pf.json8
-rw-r--r--adapters/mso-requests-db-adapter/pom.xml2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy290
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy308
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy113
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy129
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy32
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy176
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy274
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy100
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy49
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy79
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn42
-rw-r--r--graph-inventory/fluent-builder-maven-plugin/pom.xml30
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java48
-rw-r--r--packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image7
-rw-r--r--so-etsi-nfvo/pom.xml1
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaVariableNameConstants.java3
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/Constants.java1
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProvider.java1
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java12
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java49
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/WorkflowQueryService.java6
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java17
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateNsTask.java8
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/DeleteNsTask.java140
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java7
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java8
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/CreateNs.bpmn4
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/DeleteNs.bpmn260
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/InstantiateNs.bpmn4
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/TerminateNs.bpmn2
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java5
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/CreateNsTaskTest.java12
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/DeleteNsTaskTest.java185
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/MonitorSol003AdapterCreateJobTaskTest.java2
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/TerminateNsTaskTest.java13
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/pom.xml12
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java7
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java10
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java8
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java4
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java18
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java3
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java10
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java2
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/PojoClassesTests.java93
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/lifecycle/NsLifeCycleManager.java5
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java5
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java32
-rw-r--r--version.properties2
55 files changed, 1973 insertions, 824 deletions
diff --git a/.gitignore b/.gitignore
index 79d2c94622..c57b142a05 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,5 @@ packages/root-pack-extras/config-resources/mariadb/db-sql-scripts/main-schemas/M
**/bin/
/tattletale/
/.metadata/
+**/.sts4-cache
+**/.java-version
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
index 7d30c87101..5cb870e0d7 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
@@ -46,6 +46,7 @@ import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.UriBuilder;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.validator.routines.InetAddressValidator;
import org.onap.aai.domain.yang.Flavor;
@@ -59,7 +60,6 @@ import org.onap.aai.domain.yang.Pserver;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.SriovPf;
-import org.onap.aai.domain.yang.SriovPfs;
import org.onap.aai.domain.yang.Subnets;
import org.onap.aai.domain.yang.SriovVf;
import org.onap.aai.domain.yang.VfModule;
@@ -80,12 +80,12 @@ import org.onap.aaiclient.client.graphinventory.entities.DSLQuery;
import org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder;
import org.onap.aaiclient.client.graphinventory.entities.DSLStartNode;
import org.onap.aaiclient.client.graphinventory.entities.Node;
+import org.onap.aaiclient.client.graphinventory.entities.Pathed;
import org.onap.aaiclient.client.graphinventory.entities.Start;
import org.onap.aaiclient.client.graphinventory.entities.TraversalBuilder;
import org.onap.aaiclient.client.graphinventory.entities.__;
import org.onap.aaiclient.client.graphinventory.entities.uri.Depth;
import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed;
-import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.cloud.resource.beans.NodeType;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.ServerType;
@@ -95,8 +95,6 @@ import org.onap.so.heatbridge.helpers.AaiHelper;
import org.onap.so.heatbridge.openstack.api.OpenstackClient;
import org.onap.so.heatbridge.openstack.factory.OpenstackClientFactoryImpl;
import org.onap.so.heatbridge.utils.HeatBridgeUtils;
-import org.onap.so.logger.LoggingAnchor;
-import org.onap.so.logger.MessageEnum;
import org.onap.so.spring.SpringContextHelper;
import org.openstack4j.model.compute.Server;
import org.openstack4j.model.heat.Resource;
@@ -582,69 +580,67 @@ public class HeatBridgeImpl implements HeatBridgeApi {
*
* @param port Openstack port object
* @param lIf AAI l-interface object
+ * @throws HeatBridgeException
*/
- private void updateSriovPfToPserver(final Port port, final LInterface lIf) {
+ protected void updateSriovPfToPserver(final Port port, final LInterface lIf) throws HeatBridgeException {
if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) {
- if (port.getProfile() == null || Strings
- .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) {
- logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update "
- + "sriov-pf object for host pserver: " + port.getHostId());
- return;
- }
- Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName(
- port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString());
- if (matchingPifName.isPresent()) {
- // Update l-interface description
- String pserverHostName = port.getHostId();
- lIf.setInterfaceDescription(
- "Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get());
- try {
- AAIResourceUri pInterfaceUri =
- AAIUriFactory
- .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
- .pserver(pserverHostName).pInterface(matchingPifName.get()))
- .depth(Depth.ONE);
- if (resourcesClient.exists(pInterfaceUri)) {
- PInterface matchingPIf = resourcesClient.get(PInterface.class, pInterfaceUri).get();
-
- String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString();
-
- if (matchingPIf.getSriovPfs() == null
- || CollectionUtils.isEmpty(matchingPIf.getSriovPfs().getSriovPf())
- || matchingPIf.getSriovPfs().getSriovPf().stream()
- .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) {
-
- SriovPf sriovPf = new SriovPf();
- sriovPf.setPfPciId(pfPciId);
-
- AAIResourceUri sriovPfUri = AAIUriFactory.createResourceUri(
- AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverHostName)
- .pInterface(matchingPifName.get()).sriovPf(sriovPf.getPfPciId()));
-
- // TODO if it does exist, should check if relationship is there, if not then create?
- if (!resourcesClient.exists(sriovPfUri)) {
- transaction.create(sriovPfUri, sriovPf);
-
- AAIResourceUri sriovVfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder
- .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId)
- .vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).sriovVf(
- port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()));
- transaction.connect(sriovPfUri, sriovVfUri);
- }
- }
+
+ AAIResourceUri sriovVfUri = AAIUriFactory
+ .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId)
+ .tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName())
+ .sriovVf(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()));
+
+ boolean relationshipExist = sriovVfHasSriovPfRelationship(sriovVfUri);
+
+ String pserverHostName = port.getHostId();
+ lIf.setInterfaceDescription("Attached to SR-IOV port: " + pserverHostName);
+
+ if (!relationshipExist) {
+ AAIResourceUri pserverUri = AAIUriFactory
+ .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverHostName));
+ if (resourcesClient.exists(pserverUri)) {
+ String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PF_PCI_SLOT_KEY).toString();
+
+ DSLQueryBuilder<Start, Node> builder = TraversalBuilder
+ .fragment(new DSLStartNode(Types.PSERVER, __.key("hostname", pserverHostName)))
+ .to(__.node(Types.P_INTERFACE)
+ .to(__.node(Types.SRIOV_PF, __.key("pf-pci-id", pfPciId)).output()));
+
+ List<Pathed> results = getAAIDSLClient().queryPathed(new DSLQuery(builder.build()));
+
+ if (results.size() == 1) {
+
+ AAIResourceUri sriovPfUri = AAIUriFactory.createResourceFromExistingURI(Types.SRIOV_PF,
+ UriBuilder.fromUri(results.get(0).getResourceLink()).build());
+
+ transaction.connect(sriovPfUri, sriovVfUri);
+
} else {
- logger.warn(
- "PInterface {} does not exist in AAI. Unable to build sriov-vf to sriov-pf relationship.",
- matchingPifName.get());
+ throw new HeatBridgeException("Unable to find sriov-pf related link " + pfPciId
+ + ". Unexpected results size" + results.size());
}
- } catch (WebApplicationException e) {
- // Silently log that we failed to update the Pserver p-interface with PCI-ID
- logger.error(LoggingAnchor.NINE, MessageEnum.GENERAL_EXCEPTION, pserverHostName,
- matchingPifName.get(), cloudOwner, tenantId, "OpenStack", "Heatbridge",
- ErrorCode.DataError.getValue(), "Exception - Failed to add sriov-pf object to pserver", e);
+ } else {
+ logger.error("Pserver {} does not exist in AAI. Unable to build sriov-vf to sriov-pf relationship.",
+ pserverHostName);
+ throw new HeatBridgeException("Pserver " + pserverHostName + " does not exist in AAI");
+ }
+ }
+ }
+ }
+
+ protected boolean sriovVfHasSriovPfRelationship(AAIResourceUri sriovVfUri) {
+ boolean pfRelationshipsExist = false;
+ if (resourcesClient.exists(sriovVfUri)) {
+ Optional<Relationships> sriovVfRelationships = resourcesClient.get(sriovVfUri).getRelationships();
+
+ if (sriovVfRelationships.isPresent()) {
+ List<AAIResourceUri> sriovPfUris = sriovVfRelationships.get().getRelatedUris(Types.SRIOV_PF);
+ if (sriovPfUris.size() != 0) {
+ pfRelationshipsExist = true;
}
}
}
+ return pfRelationshipsExist;
}
protected void updateLInterfaceIps(final Port port, final LInterface lIf) {
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java
index 71c6a96cd6..c8a39a5795 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java
@@ -43,6 +43,7 @@ public class HeatBridgeConstants {
public static final String OS_NEUTRON_PROVIDERNET = "OS::Neutron::ProviderNet";
public static final String OS_SRIOV_PORT_TYPE = "direct";
public static final String OS_PCI_SLOT_KEY = "pci_slot";
+ public static final String OS_PF_PCI_SLOT_KEY = "pf_pci_slot";
public static final String OS_PHYSICAL_NETWORK_KEY = "physical_network";
public static final String OS_PHYSICAL_INTERFACE_KEY = "physical-interface";
public static final String OS_VLAN_NETWORK_KEY = "vlan";
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
index a9c31128ad..531496cc8f 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
@@ -42,6 +42,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -49,9 +50,10 @@ import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
@@ -60,7 +62,6 @@ import java.util.Set;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -75,9 +76,12 @@ import org.onap.aai.domain.yang.SriovPf;
import org.onap.aaiclient.client.aai.AAIDSLQueryClient;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.aaiclient.client.aai.AAISingleTransactionClient;
+import org.onap.aaiclient.client.aai.entities.Results;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.graphinventory.entities.DSLQuery;
+import org.onap.aaiclient.client.graphinventory.entities.Pathed;
import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed;
import org.onap.so.cloud.resource.beans.NodeType;
import org.onap.so.db.catalog.beans.CloudIdentity;
@@ -100,6 +104,7 @@ import org.openstack4j.openstack.heat.domain.HeatResource;
import org.openstack4j.openstack.heat.domain.HeatResource.Resources;
import org.springframework.core.env.Environment;
import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
@@ -133,6 +138,9 @@ public class HeatBridgeImplTest {
@Mock
private Server server;
+ @Mock
+ private AAIDSLQueryClient dSLQueryClient;
+
@Spy
@InjectMocks
private HeatBridgeImpl heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID,
@@ -342,11 +350,13 @@ public class HeatBridgeImplTest {
}
@Test
- public void testUpdateVserverLInterfacesToAai() throws HeatBridgeException {
+ public void testUpdateVserverLInterfacesToAai()
+ throws HeatBridgeException, JsonParseException, JsonMappingException, IOException {
// Arrange
List<Resource> stackResources = (List<Resource>) extractTestStackResources();
Port port = mock(Port.class);
when(port.getId()).thenReturn("test-port-id");
+ when(port.getHostId()).thenReturn("pserverId");
when(port.getName()).thenReturn("test-port-name");
when(port.getvNicType()).thenReturn(HeatBridgeConstants.OS_SRIOV_PORT_TYPE);
when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78");
@@ -357,7 +367,7 @@ public class HeatBridgeImplTest {
when(server.getHypervisorHostname()).thenReturn("test.server.name");
String pfPciId = "0000:08:00.0";
when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId,
- HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id"));
+ HeatBridgeConstants.OS_PF_PCI_SLOT_KEY, "testPfPciId"));
IP ip = mock(IP.class);
@@ -386,10 +396,14 @@ public class HeatBridgeImplTest {
SriovPf sriovPf = new SriovPf();
sriovPf.setPfPciId(pfPciId);
- PInterface pIf = mock(PInterface.class);
- when(pIf.getInterfaceName()).thenReturn("test-port-id");
- when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf));
+
+ when(resourcesClient.exists(any(AAIResourceUri.class))).thenReturn(true);
when(env.getProperty("mso.cloudOwner.included", "")).thenReturn("CloudOwner");
+ doReturn(dSLQueryClient).when(heatbridge).getAAIDSLClient();
+ List<Pathed> pathed = ((Results<Pathed>) MAPPER.readValue(getJson("pathed-sriov-pf.json"),
+ new TypeReference<Results<Pathed>>() {})).getResult();
+ when(dSLQueryClient.queryPathed(any(DSLQuery.class))).thenReturn(pathed);
+ doReturn(false).when(heatbridge).sriovVfHasSriovPfRelationship(any());
// Act
heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner");
@@ -399,6 +413,7 @@ public class HeatBridgeImplTest {
verify(osClient, times(5)).getPortById(anyString());
verify(osClient, times(5)).getSubnetById("testSubnetId");
verify(osClient, times(10)).getNetworkById(anyString());
+ verify(transaction, times(5)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
@Test
@@ -571,7 +586,8 @@ public class HeatBridgeImplTest {
}
@Test
- public void testUpdateVserverLInterfacesToAai_skipVlans() throws HeatBridgeException {
+ public void testUpdateVserverLInterfacesToAai_skipVlans()
+ throws HeatBridgeException, JsonParseException, JsonMappingException, IOException {
// Arrange
List<Resource> stackResources = (List<Resource>) extractTestStackResources();
Port port = mock(Port.class);
@@ -597,11 +613,9 @@ public class HeatBridgeImplTest {
when(osClient.getPortById("c54b9f45-b413-4937-bbe4-3c8a5689cfc9")).thenReturn(port);
when(osClient.getNetworkById(anyString())).thenReturn(network);
- SriovPf sriovPf = new SriovPf();
- sriovPf.setPfPciId(pfPciId);
PInterface pIf = mock(PInterface.class);
when(pIf.getInterfaceName()).thenReturn("test-port-id");
- when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf));
+ doNothing().when(heatbridge).updateSriovPfToPserver(any(), any());
// Act
heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner");
@@ -636,5 +650,9 @@ public class HeatBridgeImplTest {
return content;
}
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/" + filename)));
+ }
+
}
diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/pathed-sriov-pf.json b/adapters/mso-openstack-adapters/src/test/resources/__files/pathed-sriov-pf.json
new file mode 100644
index 0000000000..cccad4c6d3
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/resources/__files/pathed-sriov-pf.json
@@ -0,0 +1,8 @@
+{
+ "results" : [
+ {
+ "resource-type" : "sriov-pf",
+ "resource-link" : "/cloud-infrastructure/pservers/pserver/id1/p-interfaces/p-interface/id2/sriov-pfs/sriov-pf/id3"
+ }
+ ]
+} \ No newline at end of file
diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml
index ca13895848..9a2df1bd51 100644
--- a/adapters/mso-requests-db-adapter/pom.xml
+++ b/adapters/mso-requests-db-adapter/pom.xml
@@ -159,7 +159,7 @@
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
- <version>2.4.0-b180725.0644</version>
+ <version>2.4.0-b180830.0438</version>
</dependency>
</dependencies>
<executions>
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy
index c7fe7e36a6..eabe58488e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy
@@ -32,150 +32,148 @@ import org.slf4j.LoggerFactory
import static org.apache.commons.lang3.StringUtils.isBlank
class ActivateSliceSubnet extends AbstractServiceTaskProcessor {
- String Prefix="ActSS"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- RequestDBUtil requestDBUtil = new RequestDBUtil()
-
- private static final Logger logger = LoggerFactory.getLogger(ActivateSliceSubnet.class)
-
- @Override
- void preProcessRequest(DelegateExecution execution) {
- logger.debug(Prefix + "preProcessRequest Start")
- execution.setVariable("prefix", Prefix)
- execution.setVariable("startTime", System.currentTimeMillis())
- def msg
- try {
- // get request input
- String subnetInstanceReq = execution.getVariable("bpmnRequest")
- logger.debug(subnetInstanceReq)
-
- String requestId = execution.getVariable("mso-request-id")
- execution.setVariable("msoRequestId", requestId)
- logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId)
-
- //subscriberInfo
- String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId")
- if (isBlank(globalSubscriberId)) {
- msg = "Input globalSubscriberId' is null"
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
- execution.setVariable("globalSubscriberId", globalSubscriberId)
- }
-
- //NSSI ID
- String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID")
- if (isBlank(serviceInstanceID)) {
- msg = "Input serviceInstanceID is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("serviceInstanceID", serviceInstanceID)
- }
-
- String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId")
- if (isBlank(nsiId)) {
- msg = "Input nsiId is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("nsiId", nsiId)
- }
- String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType")
- if (isBlank(networkType)) {
- msg = "Input networkType is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("networkType", networkType.toUpperCase())
- }
-
- //requestParameters, subscriptionServiceType is 5G
- String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType")
- if (isBlank(subscriptionServiceType)) {
- msg = "Input subscriptionServiceType is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
- execution.setVariable("subscriptionServiceType", subscriptionServiceType)
- }
-
- //operationType = deactivateInstance/activateInstance
- String operationType = execution.getVariable("requestAction")
- if (isBlank(operationType)) {
- msg = "Input operationType is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
- execution.setVariable("operationType", operationType)
- }
-
- String jobId = UUID.randomUUID().toString()
- execution.setVariable("jobId", jobId)
-
- String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties")
- execution.setVariable("sliceParams", sliceParams)
-
- } catch(BpmnError e) {
- throw e
- } catch(Exception ex) {
- msg = "Exception in ActivateSliceSubnet.preProcessRequest " + ex.getMessage()
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- logger.debug(Prefix + "preProcessRequest Exit")
- }
-
-
- /**
- * create operation status in request db
- *
- * Init the Operation Status
- */
- def prepareInitOperationStatus = { DelegateExecution execution ->
- logger.debug(Prefix + "prepareInitOperationStatus Start")
-
- String serviceId = execution.getVariable("serviceInstanceID")
- String jobId = execution.getVariable("jobId")
- String nsiId = execution.getVariable("nsiId")
- String operationType = execution.getVariable("operationType")
- logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId)
-
- ResourceOperationStatus initStatus = new ResourceOperationStatus()
- initStatus.setServiceId(serviceId)
- initStatus.setOperationId(jobId)
- initStatus.setResourceTemplateUUID(nsiId)
- initStatus.setOperType(operationType)
- requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
-
- logger.debug(Prefix + "prepareInitOperationStatus Exit")
- }
-
-
-
- /**
- * return sync response
- */
- def sendSyncResponse = { DelegateExecution execution ->
- logger.debug(Prefix + "sendSyncResponse Start")
- try {
- String jobId = execution.getVariable("jobId")
- String activateSyncResponse = """{"jobId": "${jobId}","status": "processing"}"""
- .trim().replaceAll(" ", "")
-
- logger.debug("sendSyncResponse to APIH:" + "\n" + activateSyncResponse)
- sendWorkflowResponse(execution, 202, activateSyncResponse)
-
- execution.setVariable("sentSyncResponse", true)
- } catch (Exception ex) {
- String msg = "Exception in sendSyncResponse:" + ex.getMessage()
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- logger.debug(Prefix + "sendSyncResponse Exit")
- }
-
+ String Prefix="ActivateSliceSubnet_"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ RequestDBUtil requestDBUtil = new RequestDBUtil()
+
+ private static final Logger logger = LoggerFactory.getLogger(ActivateSliceSubnet.class)
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ logger.debug(Prefix + "preProcessRequest Start")
+ execution.setVariable("prefix", Prefix)
+ execution.setVariable("startTime", System.currentTimeMillis())
+ def msg
+ try {
+ // get request input
+ String subnetInstanceReq = execution.getVariable("bpmnRequest")
+ logger.debug(subnetInstanceReq)
+
+ String requestId = execution.getVariable("mso-request-id")
+ execution.setVariable("msoRequestId", requestId)
+ logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId)
+
+ //subscriberInfo
+ String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId")
+ if (isBlank(globalSubscriberId)) {
+ msg = "Input globalSubscriberId' is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("globalSubscriberId", globalSubscriberId)
+ }
+
+ //NSSI ID
+ String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID")
+ if (isBlank(serviceInstanceID)) {
+ msg = "Input serviceInstanceID is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("serviceInstanceID", serviceInstanceID)
+ }
+ String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId")
+ if (isBlank(nsiId)) {
+ msg = "Input nsiId is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("nsiId", nsiId)
+ }
+ String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType")
+ if (isBlank(networkType)) {
+ msg = "Input networkType is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("networkType", networkType.toUpperCase())
+ }
+ //requestParameters, subscriptionServiceType is 5G
+ String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType")
+ if (isBlank(subscriptionServiceType)) {
+ msg = "Input subscriptionServiceType is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("subscriptionServiceType", subscriptionServiceType)
+ }
+
+ //operationType = deactivateInstance/activateInstance
+ String operationType = execution.getVariable("requestAction")
+ if (isBlank(operationType)) {
+ msg = "Input operationType is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("operationType", operationType)
+ }
+
+ String jobId = UUID.randomUUID().toString()
+ execution.setVariable("jobId", jobId)
+
+ String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties")
+ execution.setVariable("sliceParams", sliceParams)
+
+ } catch(BpmnError e) {
+ throw e
+ } catch(Exception ex) {
+ msg = "Exception in ActivateSliceSubnet.preProcessRequest " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "preProcessRequest Exit")
+ }
+
+
+ /**
+ * create operation status in request db
+ *
+ * Init the Operation Status
+ */
+ def prepareInitOperationStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareInitOperationStatus Start")
+
+ String serviceId = execution.getVariable("serviceInstanceID")
+ String jobId = execution.getVariable("jobId")
+ String nsiId = execution.getVariable("nsiId")
+ String operationType = execution.getVariable("operationType")
+ logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId)
+
+ ResourceOperationStatus initStatus = new ResourceOperationStatus()
+ initStatus.setServiceId(serviceId)
+ initStatus.setOperationId(jobId)
+ initStatus.setResourceTemplateUUID(nsiId)
+ initStatus.setOperType(operationType)
+ requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
+
+ logger.debug(Prefix + "prepareInitOperationStatus Exit")
+ }
+
+
+
+ /**
+ * return sync response
+ */
+ def sendSyncResponse = { DelegateExecution execution ->
+ logger.debug(Prefix + "sendSyncResponse Start")
+ try {
+ String jobId = execution.getVariable("jobId")
+ String activateSyncResponse = """{"jobId": "${jobId}","status": "processing"}"""
+ .trim().replaceAll(" ", "")
+
+ logger.debug("sendSyncResponse to APIH:" + "\n" + activateSyncResponse)
+ sendWorkflowResponse(execution, 202, activateSyncResponse)
+
+ execution.setVariable("sentSyncResponse", true)
+ } catch (Exception ex) {
+ String msg = "Exception in sendSyncResponse:" + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "sendSyncResponse Exit")
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy
index 5a7722d679..9100f2773b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy
@@ -33,158 +33,158 @@ import static org.apache.commons.lang3.StringUtils.isBlank
class AllocateSliceSubnet extends AbstractServiceTaskProcessor {
- String Prefix="ASS_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- RequestDBUtil requestDBUtil = new RequestDBUtil()
- JsonUtils jsonUtil = new JsonUtils()
- private static final Logger logger = LoggerFactory.getLogger(AllocateSliceSubnet.class)
-
- @Override
- void preProcessRequest(DelegateExecution execution) {
- logger.debug(Prefix + "preProcessRequest Start")
- execution.setVariable("prefix", Prefix)
- execution.setVariable("startTime", System.currentTimeMillis())
- def msg
- try {
- // get request input
- String subnetInstanceReq = execution.getVariable("bpmnRequest")
- logger.debug(subnetInstanceReq)
-
- String requestId = execution.getVariable("mso-request-id")
- execution.setVariable("msoRequestId", requestId)
- logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId)
-
- //modelInfo
- String modelInvariantUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelInvariantUuid")
- if (isBlank(modelInvariantUuid)) {
- msg = "Input modelInvariantUuid is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("modelInvariantUuid", modelInvariantUuid)
- }
-
- logger.debug("modelInvariantUuid: " + modelInvariantUuid)
-
- String modelUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelUuid")
- if (isBlank(modelUuid)) {
- msg = "Input modelUuid is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("modelUuid", modelUuid)
- }
-
- logger.debug("modelUuid: " + modelUuid)
-
-
- //subscriberInfo
- String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId")
- if (isBlank(globalSubscriberId)) {
- msg = "Input globalSubscriberId' is null"
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
- execution.setVariable("globalSubscriberId", globalSubscriberId)
- }
- String dummyServiceId = new UUID(0,0).toString();
- execution.setVariable("dummyServiceId", dummyServiceId)
- logger.debug("dummyServiceId: " + dummyServiceId)
- String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name")
- execution.setVariable("servicename", servicename)
-
- String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId")
- if (isBlank(nsiId)) {
- msg = "Input nsiId is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("nsiId", nsiId)
- }
-
- String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType")
- if (isBlank(networkType)) {
- msg = "Input networkType is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("networkType", networkType.toUpperCase())
- }
-
- //requestParameters, subscriptionServiceType is 5G
- String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType")
- if (isBlank(subscriptionServiceType)) {
- msg = "Input subscriptionServiceType is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
- execution.setVariable("subscriptionServiceType", subscriptionServiceType)
- }
-
- String jobId = UUID.randomUUID().toString()
- execution.setVariable("jobId", jobId)
-
- String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties")
- execution.setVariable("sliceParams", sliceParams)
-
- } catch(BpmnError e) {
- throw e
- } catch(Exception ex) {
- msg = "Exception in AllocateSliceSubnet.preProcessRequest " + ex.getMessage()
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- logger.debug(Prefix + "preProcessRequest Exit")
- }
-
-
- /**
- * create operation status in request db
- *
- * Init the Operation Status
- */
- def prepareInitOperationStatus = { DelegateExecution execution ->
- logger.debug(Prefix + "prepareInitOperationStatus Start")
-
- String serviceId = execution.getVariable("dummyServiceId")
- String jobId = execution.getVariable("jobId")
- String nsiId = execution.getVariable("nsiId")
- logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId)
-
- ResourceOperationStatus initStatus = new ResourceOperationStatus()
- initStatus.setServiceId(serviceId)
- initStatus.setOperationId(jobId)
- initStatus.setResourceTemplateUUID(nsiId)
- initStatus.setOperType("Allocate")
- requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
-
- logger.debug(Prefix + "prepareInitOperationStatus Exit")
- }
-
-
- /**
- * return sync response
- */
- def sendSyncResponse = { DelegateExecution execution ->
- logger.debug(Prefix + "sendSyncResponse Start")
- try {
- String jobId = execution.getVariable("jobId")
- String allocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}"""
- .trim().replaceAll(" ", "").trim().replaceAll(" ", "")
-
- logger.debug("sendSyncResponse to APIH:" + "\n" + allocateSyncResponse)
- sendWorkflowResponse(execution, 202, allocateSyncResponse)
-
- execution.setVariable("sentSyncResponse", true)
- } catch (Exception ex) {
- String msg = "Exception in sendSyncResponse:" + ex.getMessage()
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- logger.debug(Prefix + "sendSyncResponse Exit")
- }
-
+ String Prefix="AllocateSliceSubnet_"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ RequestDBUtil requestDBUtil = new RequestDBUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ private static final Logger logger = LoggerFactory.getLogger(AllocateSliceSubnet.class)
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ logger.debug(Prefix + "preProcessRequest Start")
+ execution.setVariable("prefix", Prefix)
+ execution.setVariable("startTime", System.currentTimeMillis())
+ def msg
+ try {
+ // get request input
+ String subnetInstanceReq = execution.getVariable("bpmnRequest")
+ logger.debug(subnetInstanceReq)
+
+ String requestId = execution.getVariable("mso-request-id")
+ execution.setVariable("msoRequestId", requestId)
+ logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId)
+
+ //modelInfo
+ String modelInvariantUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelInvariantUuid")
+ if (isBlank(modelInvariantUuid)) {
+ msg = "Input modelInvariantUuid is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("modelInvariantUuid", modelInvariantUuid)
+ }
+
+ logger.debug("modelInvariantUuid: " + modelInvariantUuid)
+
+ String modelUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelUuid")
+ if (isBlank(modelUuid)) {
+ msg = "Input modelUuid is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("modelUuid", modelUuid)
+ }
+
+ logger.debug("modelUuid: " + modelUuid)
+
+
+ //subscriberInfo
+ String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId")
+ if (isBlank(globalSubscriberId)) {
+ msg = "Input globalSubscriberId' is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("globalSubscriberId", globalSubscriberId)
+ }
+ String dummyServiceId = new UUID(0,0).toString();
+ execution.setVariable("dummyServiceId", dummyServiceId)
+ logger.debug("dummyServiceId: " + dummyServiceId)
+ String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name")
+ execution.setVariable("servicename", servicename)
+
+ String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId")
+ if (isBlank(nsiId)) {
+ msg = "Input nsiId is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("nsiId", nsiId)
+ }
+
+ String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType")
+ if (isBlank(networkType)) {
+ msg = "Input networkType is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("networkType", networkType.toUpperCase())
+ }
+
+ //requestParameters, subscriptionServiceType is 5G
+ String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType")
+ if (isBlank(subscriptionServiceType)) {
+ msg = "Input subscriptionServiceType is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("subscriptionServiceType", subscriptionServiceType)
+ }
+
+ String jobId = UUID.randomUUID().toString()
+ execution.setVariable("jobId", jobId)
+
+ String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties")
+ execution.setVariable("sliceParams", sliceParams)
+
+ } catch(BpmnError e) {
+ throw e
+ } catch(Exception ex) {
+ msg = "Exception in AllocateSliceSubnet.preProcessRequest " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "preProcessRequest Exit")
+ }
+
+
+ /**
+ * create operation status in request db
+ *
+ * Init the Operation Status
+ */
+ def prepareInitOperationStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareInitOperationStatus Start")
+
+ String serviceId = execution.getVariable("dummyServiceId")
+ String jobId = execution.getVariable("jobId")
+ String nsiId = execution.getVariable("nsiId")
+ logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId)
+
+ ResourceOperationStatus initStatus = new ResourceOperationStatus()
+ initStatus.setServiceId(serviceId)
+ initStatus.setOperationId(jobId)
+ initStatus.setResourceTemplateUUID(nsiId)
+ initStatus.setOperType("Allocate")
+ requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
+
+ logger.debug(Prefix + "prepareInitOperationStatus Exit")
+ }
+
+
+ /**
+ * return sync response
+ */
+ def sendSyncResponse = { DelegateExecution execution ->
+ logger.debug(Prefix + "sendSyncResponse Start")
+ try {
+ String jobId = execution.getVariable("jobId")
+ String allocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}"""
+ .trim().replaceAll(" ", "").trim().replaceAll(" ", "")
+
+ logger.debug("sendSyncResponse to APIH:" + "\n" + allocateSyncResponse)
+ sendWorkflowResponse(execution, 202, allocateSyncResponse)
+
+ execution.setVariable("sentSyncResponse", true)
+ } catch (Exception ex) {
+ String msg = "Exception in sendSyncResponse:" + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "sendSyncResponse Exit")
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy
index 964baa7a9d..65885f3516 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy
@@ -32,14 +32,13 @@ import org.slf4j.LoggerFactory
import static org.apache.commons.lang3.StringUtils.isBlank
class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor {
- String Prefix="DeASS_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- RequestDBUtil requestDBUtil = new RequestDBUtil()
-
- private static final Logger logger = LoggerFactory.getLogger(DeAllocateSliceSubnet.class)
-
- @Override
+ String Prefix="DeAllocateSliceSubnet_"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ RequestDBUtil requestDBUtil = new RequestDBUtil()
+ private static final Logger logger = LoggerFactory.getLogger(DeAllocateSliceSubnet.class)
+
+ @Override
void preProcessRequest(DelegateExecution execution) {
logger.debug(Prefix + "preProcessRequest Start")
execution.setVariable("prefix", Prefix)
@@ -62,8 +61,8 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor {
} else {
execution.setVariable("globalSubscriberId", globalSubscriberId)
}
-
- //NSSI ID
+
+ //NSSI ID
String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID")
if (isBlank(serviceInstanceID)) {
msg = "Input serviceInstanceID is null"
@@ -73,27 +72,27 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor {
{
execution.setVariable("serviceInstanceID", serviceInstanceID)
}
-
- String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId")
- if (isBlank(nsiId)) {
- msg = "Input nsiId is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("nsiId", nsiId)
- }
-
- String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType")
- if (isBlank(networkType)) {
- msg = "Input networkType is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("networkType", networkType.toUpperCase())
- }
-
+
+ String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId")
+ if (isBlank(nsiId)) {
+ msg = "Input nsiId is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("nsiId", nsiId)
+ }
+
+ String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType")
+ if (isBlank(networkType)) {
+ msg = "Input networkType is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("networkType", networkType.toUpperCase())
+ }
+
//requestParameters, subscriptionServiceType is 5G
String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType")
if (isBlank(subscriptionServiceType)) {
@@ -106,9 +105,9 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor {
String jobId = UUID.randomUUID().toString()
execution.setVariable("jobId", jobId)
-
- String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties")
- execution.setVariable("sliceParams", sliceParams)
+
+ String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties")
+ execution.setVariable("sliceParams", sliceParams)
} catch(BpmnError e) {
throw e
@@ -131,13 +130,13 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor {
String serviceId = execution.getVariable("serviceInstanceID")
String jobId = execution.getVariable("jobId")
- String nsiId = execution.getVariable("nsiId")
+ String nsiId = execution.getVariable("nsiId")
logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId)
ResourceOperationStatus initStatus = new ResourceOperationStatus()
initStatus.setServiceId(serviceId)
initStatus.setOperationId(jobId)
- initStatus.setResourceTemplateUUID(nsiId)
+ initStatus.setResourceTemplateUUID(nsiId)
initStatus.setOperType("Deallocate")
requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
@@ -145,26 +144,26 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor {
}
-
- /**
- * return sync response
- */
- def sendSyncResponse = { DelegateExecution execution ->
- logger.debug(Prefix + "sendSyncResponse Start")
- try {
- String jobId = execution.getVariable("jobId")
- String deAllocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""".trim().replaceAll(" ", "")
-
- logger.debug("sendSyncResponse to APIH:" + "\n" + deAllocateSyncResponse)
- sendWorkflowResponse(execution, 202, deAllocateSyncResponse)
-
- execution.setVariable("sentSyncResponse", true)
- } catch (Exception ex) {
- String msg = "Exception in sendSyncResponse:" + ex.getMessage()
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- logger.debug(Prefix + "sendSyncResponse Exit")
- }
+
+ /**
+ * return sync response
+ */
+ def sendSyncResponse = { DelegateExecution execution ->
+ logger.debug(Prefix + "sendSyncResponse Start")
+ try {
+ String jobId = execution.getVariable("jobId")
+ String deAllocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""".trim().replaceAll(" ", "")
+
+ logger.debug("sendSyncResponse to APIH:" + "\n" + deAllocateSyncResponse)
+ sendWorkflowResponse(execution, 202, deAllocateSyncResponse)
+
+ execution.setVariable("sentSyncResponse", true)
+ } catch (Exception ex) {
+ String msg = "Exception in sendSyncResponse:" + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "sendSyncResponse Exit")
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
index 567725246e..646861a6a0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
@@ -246,11 +246,61 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
void getNSSIAssociatedProfiles(DelegateExecution execution) {
LOGGER.trace("${getPrefix()} Start getNSSIAssociatedProfiles")
+ List<SliceProfile> associatedProfiles = new ArrayList<>()
+
+ AAIResourcesClient client = getAAIClient()
+
def currentNSSI = execution.getVariable("currentNSSI")
ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
+ String nssiId = currentNSSI['nssiId']
+
+ // NSSI
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ AAIResultWrapper nssiWrapper = client.get(nssiUri)
+ Optional<Relationships> nssiRelationships = nssiWrapper.getRelationships()
+
+ if (nssiRelationships.isPresent()) {
+ // Allotted Resource
+ for (AAIResourceUri allottedResourceUri : nssiRelationships.get().getRelatedUris(Types.ALLOTTED_RESOURCE)) {
+ AAIResultWrapper arWrapper = client.get(allottedResourceUri)
+ Optional<Relationships> arRelationships = arWrapper.getRelationships()
+
+ boolean isFound = false
+ if(arRelationships.isPresent()) {
+ // Slice Profile Instance
+ for (AAIResourceUri sliceProfileInstanceUri : arRelationships.get().getRelatedUris(Types.SERVICE_INSTANCE)) {
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+ if(sliceProfileInstance.getServiceRole().equals("slice-profile-instance")) { // Service instance as a Slice Profile Instance
+ associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile()
+
+ currentNSSI['sliceProfileInstanceUri'] = sliceProfileInstanceUri
+
+ isFound = true
+ break // Should be only one
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No Slice Profile Instance found")
+ }
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for Allotted Resource")
+ }
+
+ if(isFound) {
+ break
+ }
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for nssi id = " + nssiId)
+ }
if(associatedProfiles.isEmpty()) {
String msg = String.format("No associated profiles found for NSSI %s in AAI", nssi.getServiceInstanceId())
@@ -587,13 +637,13 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param constituteVnf
* @return List<VfModules>
*/
- List<VfModules> prepareVfModules(DelegateExecution execution, GenericVnf constituteVnf) {
+ List<org.onap.so.serviceinstancebeans.VfModules> prepareVfModules(DelegateExecution execution, GenericVnf constituteVnf) {
AAIResourcesClient client = getAAIClient()
- List<VfModules> vfModuless = new ArrayList<>()
+ List<org.onap.so.serviceinstancebeans.VfModules> vfModuless = new ArrayList<>()
for (VfModule vfModule : constituteVnf.getVfModules().getVfModule()) {
- VfModules vfmodules = new VfModules()
+ org.onap.so.serviceinstancebeans.VfModules vfmodules = new org.onap.so.serviceinstancebeans.VfModules()
ModelInfo vfModuleModelInfo = new ModelInfo()
vfModuleModelInfo.setModelInvariantUuid(vfModule.getModelInvariantId())
@@ -703,7 +753,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
Vnfs vnf = new Vnfs()
// Line of Business
- LineOfBusiness lob = new LineOfBusiness()
+ org.onap.so.serviceinstancebeans.LineOfBusiness lob = new org.onap.so.serviceinstancebeans.LineOfBusiness()
lob.setLineOfBusinessName("VNF")
vnf.setLineOfBusiness(lob)
@@ -739,8 +789,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* Prepare Service
* @return Service
*/
- Service prepareService(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) {
- Service service = new Service()
+ org.onap.so.serviceinstancebeans.Service prepareService(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) {
+ org.onap.so.serviceinstancebeans.Service service = new org.onap.so.serviceinstancebeans.Service()
// Model Info
service.setModelInfo(prepareServiceModelInfo(networkServiceInstance, modelInfo))
@@ -793,21 +843,21 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
* @return OwningEntity
*/
- OwningEntity prepareOwningEntity(DelegateExecution execution) {
+ org.onap.so.serviceinstancebeans.OwningEntity prepareOwningEntity(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
AAIResourcesClient client = getAAIClient()
AAIResourceUri networkServiceInstanceUri = (AAIResourceUri)currentNSSI['networkServiceInstanceUri']
- OwningEntity owningEntity = new OwningEntity()
+ org.onap.so.serviceinstancebeans.OwningEntity owningEntity = new org.onap.so.serviceinstancebeans.OwningEntity()
AAIResultWrapper wrapper = client.get(networkServiceInstanceUri)
Optional<Relationships> owningEntityRelationshipsOps = wrapper.getRelationships()
if (owningEntityRelationshipsOps.isPresent()) {
List<AAIResourceUri> owningEntityRelatedAAIUris = owningEntityRelationshipsOps.get().getRelatedUris(Types.OWNING_ENTITY)
if (!(owningEntityRelatedAAIUris == null || owningEntityRelatedAAIUris.isEmpty())) {
- Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation
+ Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.v19.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation
if (owningEntityOpt.isPresent()) {
owningEntity.setOwningEntityId(owningEntityOpt.get().getOwningEntityId())
owningEntity.setOwningEntityName(owningEntityOpt.get().getOwningEntityName())
@@ -825,12 +875,12 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
* @return Project
*/
- Project prepareProject(DelegateExecution execution) {
+ org.onap.so.serviceinstancebeans.Project prepareProject(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
AAIResourcesClient client = getAAIClient()
- Project project = new Project()
+ org.onap.so.serviceinstancebeans.Project project = new org.onap.so.serviceinstancebeans.Project()
AAIResourceUri cloudRegionRelatedAAIUri = (AAIResourceUri)currentNSSI['cloudRegionRelatedAAIUri']
@@ -840,7 +890,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
if (cloudRegionOps.isPresent()) {
List<AAIResourceUri> projectAAIUris = cloudRegionOps.get().getRelatedUris(Types.PROJECT)
if (!(projectAAIUris == null || projectAAIUris.isEmpty())) {
- Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.Project.class, projectAAIUris.get(0))
+ Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.v19.Project.class, projectAAIUris.get(0))
if (projectOpt.isPresent()) {
project.setProjectName(projectOpt.get().getProjectName())
}
@@ -950,23 +1000,49 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
def currentNSSI = execution.getVariable("currentNSSI")
- ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
-
String nssiId = currentNSSI['nssiId']
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
+ AAIResourceUri sliceProfileInstanceUri = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri']
- String currentSNSSAI = currentNSSI['S-NSSAI']
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+
+ List<SliceProfile> associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile()
+
+ String currentSNSSAI = currentNSSI['S-NSSAI']
+
+ if(!(associatedProfiles == null || associatedProfiles.isEmpty())) {
+ // Removes slice profile which contains given S-NSSAI and updates Slice Profile Instance
+ associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) })
+
+ try {
+ client.update(sliceProfileInstanceUri, sliceProfileInstance)
+
+ currentNSSI['sliceProfileInstance'] = sliceProfileInstance
+ } catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage())
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profiles found")
+ }
- associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) })
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profile instance found")
+ }
+ // Removes SLice Profile Instance association with NSSI
try {
- getAAIClient().update(nssiUri, nssi)
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage())
+ client.disconnect(nssiUri, sliceProfileInstanceUri)
+ }
+ catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance association with NSSI dosconnect call: " + e.getMessage())
}
+
LOGGER.trace("${getPrefix()} Exit removeSPAssociationWithNSSI")
}
@@ -982,17 +1058,10 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
def currentNSSI = execution.getVariable("currentNSSI")
- SliceProfile sliceProfileContainsSNSSAI = (SliceProfile)currentNSSI['sliceProfileS-NSSAI']
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- String nssiId = currentNSSI['nssiId']
-
- // global-customer-id, service-type, service-instance-id, profile-id
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileContainsSNSSAI.getProfileId()))
+ AAIResourceUri sliceProfileInstanceURI = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri']
try {
- client.delete(sliceProfileUri)
+ client.delete(sliceProfileInstanceURI)
}catch(Exception e){
exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
index 055cbfc9cc..fe881eb888 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
@@ -22,10 +22,14 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.v19.AllottedResource
import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aaiclient.client.aai.AAIResourcesClient
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
+import org.onap.aaiclient.client.aai.entities.Relationships
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -299,12 +303,38 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
String nssiId = currentNSSI['nssiId']
String nsiId = currentNSSI['nsiId']
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ // NSSI
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ ServiceInstance nssi = currentNSSI['nssi']
+
+ String allottedResourceId = null
+
+ // Removes Allotted resource
+ List<AllottedResource> allottedResources = nssi.getAllottedResources()?.getAllottedResource()
+ if(allottedResources != null && allottedResources.size() == 1) { // Shouldn contain one allotted resource
+ allottedResourceId = allottedResources.get(0).getId()
+ allottedResources.remove(0)
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No allotted resource found for NSSI id = " + nssiId)
+ }
+
+ try {
+ client.update(nssiUri, nssi)
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI association with NSI disconnect call: " + e.getMessage())
+ }
+
+
+ // Remove association between NSI and Allotted Resource
AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId))
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).allottedResource(allottedResourceId))
try {
- client.disconnect(nssiUri, nsiUri)
+ client.disconnect(nsiUri, allottedResourceUri)
}catch(Exception e){
exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI association with NSI disconnect call: " + e.getMessage())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
index 4ccea61ed4..ff16184f02 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
@@ -22,8 +22,11 @@ package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.v19.AllottedResource
+import org.onap.aai.domain.yang.v19.AllottedResources
import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aai.domain.yang.v19.SliceProfile
+import org.onap.aai.domain.yang.v19.SliceProfiles
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
@@ -37,6 +40,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import static org.apache.commons.lang3.StringUtils.isAllLowerCase
import static org.apache.commons.lang3.StringUtils.isBlank
class DoModifyCoreNSSI extends DoCommonCoreNSSI {
@@ -51,22 +55,18 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class)
+
/**
- * Creates Slice Profile Instance
+ * Prepares Slice Profile
* @param execution
+ * @return SLice Profile
*/
- void createSliceProfileInstance(DelegateExecution execution) {
- LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
-
+ SliceProfile prepareSliceProfile(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
String sliceProfileID = currentNSSI['sliceProfileId']
Map<String,Object> sliceProfileMap = new ObjectMapper().readValue(currentNSSI['sliceProfile'], Map.class)
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- String nssiId = currentNSSI['nssiId']
-
SliceProfile sliceProfile = new SliceProfile()
sliceProfile.setServiceAreaDimension("")
sliceProfile.setPayloadSize(0)
@@ -112,14 +112,80 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
sliceProfile.setProfileId(sliceProfileID)
sliceProfile.setE2ELatency(0)
+ return sliceProfile
+ }
+
+
+ /**
+ * Prepares Slice Profile Instance
+ * @param execution
+ * @return Slice Profile Instance
+ */
+ ServiceInstance prepareSliceProfileInstance(DelegateExecution execution) {
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ String sliceProfileInstanceId = UUID.randomUUID().toString()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+
+
+ String sliceInstanceName = "sliceprofile_" + sliceProfileInstanceId
+ sliceProfileInstance.setServiceInstanceName(sliceInstanceName)
+
+ String serviceType = jsonUtil.getJsonValue(currentNSSI['sliceProfile'], "sST")
+ sliceProfileInstance.setServiceType(serviceType)
+
+ String serviceStatus = "deactivated"
+ sliceProfileInstance.setOrchestrationStatus(serviceStatus)
+
+ String serviceInstanceLocationid = jsonUtil.getJsonValue(currentNSSI['sliceProfile'], "plmnIdList")
+ sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
+
+ String serviceRole = "slice-profile-instance"
+ sliceProfileInstance.setServiceRole(serviceRole)
+ List<String> snssaiList = (List<String>)currentNSSI['S-NSSAIs']
+ String snssai = snssaiList.get(0)
+
+ sliceProfileInstance.setEnvironmentContext(snssai)
+ sliceProfileInstance.setWorkloadContext("CN-NF")
+
+ // TO DO: Model info
+
+ return sliceProfileInstance
+ }
+
+
+
+ /**
+ * Creates Slice Profile Instance
+ * @param execution
+ */
+ void createSliceProfileInstance(DelegateExecution execution) {
+ LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ SliceProfile sliceProfile = prepareSliceProfile(execution)
+
+ ServiceInstance sliceProfileInstance = prepareSliceProfileInstance(execution)
+
+ SliceProfiles sliceProfiles = new SliceProfiles()
+ sliceProfiles.getSliceProfile().add(sliceProfile)
+ sliceProfileInstance.setSliceProfiles(sliceProfiles)
+
try {
AAIResourcesClient client = getAAIClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
- client.create(uri, sliceProfile)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).
+ serviceInstance(sliceProfileInstance.getServiceInstanceId()))
+ client.create(uri, sliceProfileInstance)
- currentNSSI['createdSliceProfile'] = sliceProfile
+ currentNSSI['createdSliceProfileInstanceId'] = sliceProfileInstance.getServiceInstanceId()
} catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile create call:" + ex.getMessage())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while Slice Profile create call:" + ex.getMessage())
}
LOGGER.trace("${PREFIX} Exit createSliceProfileInstance")
@@ -127,6 +193,42 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
/**
+ * Creates Allotted Resource
+ * @param execution
+ * @return AllottedResource
+ */
+ AllottedResource createAllottedResource(DelegateExecution execution) {
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String sliceProfileInstanceId = currentNSSI['createdSliceProfileInstanceId']
+
+ AllottedResource allottedResource = new AllottedResource()
+
+ String allottedResourceId = UUID.randomUUID().toString()
+
+ allottedResource.setId(allottedResourceId)
+
+ // TO DO: No other info
+
+ try {
+ AAIResourcesClient client = getAAIClient()
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceProfileInstanceId).allottedResource(allottedResourceId))
+
+ client.create(allottedResourceUri, allottedResource)
+
+ currentNSSI['allottedResourceUri'] = allottedResourceUri
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while Allotted Resource create call:" + ex.getMessage())
+ }
+
+ return allottedResource
+ }
+
+
+
+ /**
* Creates Slice Profile association with NSSI
* @param execution
*/
@@ -135,26 +237,48 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
def currentNSSI = execution.getVariable("currentNSSI")
- String sliceProfileID = currentNSSI['sliceProfileId']
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
String nssiId = currentNSSI['nssiId']
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
+ String sliceProfileInstanceId = currentNSSI['createdSliceProfileInstanceId']
+ AAIResourcesClient client = getAAIClient()
+
+ // Creates Allotted Resource
+ AllottedResource allottedResource = createAllottedResource(execution)
+ AAIResourceUri allottedResourceUri = (AAIResourceUri)currentNSSI['allottedResourceUri']
+
+ // Updates Slice Profile Instance with Allotted Resource
try {
- SliceProfile createdSliceProfile = (SliceProfile)currentNSSI['createdSliceProfile']
- ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
- associatedProfiles.add(createdSliceProfile)
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstanceId))
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+
+ AllottedResources allottedResources = sliceProfileInstance.getAllottedResources()
+ if(allottedResources == null) {
+ allottedResources = new AllottedResources()
+ }
+
+ allottedResources.getAllottedResource().add(allottedResource)
+ sliceProfileInstance.setAllottedResources(allottedResources)
+
+ client.update(sliceProfileInstanceUri, sliceProfileInstance)
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profile instance found with id = " + sliceProfileInstanceId)
+ }
+
+ } catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance update call: " + e.getMessage())
+ }
- getAAIClient().update(nssiUri, nssi)
- getAAIClient().connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO)
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI disconnect call: " + e.getMessage())
+ // Associates NSSI with Allotted Resource
+ try {
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ client.connect(nssiUri, allottedResourceUri, AAIEdgeLabel.USES)
+ } catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI with Allotted Resource connect call: " + e.getMessage())
}
LOGGER.trace("${PREFIX} Exit associateSliceProfileInstanceWithNSSI")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy
index 47489b7b84..0465a433eb 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy
@@ -32,142 +32,142 @@ import org.slf4j.LoggerFactory
import static org.apache.commons.lang3.StringUtils.isBlank
class ModifySliceSubnet extends AbstractServiceTaskProcessor {
- String Prefix="MSS_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- RequestDBUtil requestDBUtil = new RequestDBUtil()
-
- private static final Logger logger = LoggerFactory.getLogger(ModifySliceSubnet.class)
-
- @Override
- void preProcessRequest(DelegateExecution execution) {
- logger.debug(Prefix + "preProcessRequest Start")
- execution.setVariable("prefix", Prefix)
- execution.setVariable("startTime", System.currentTimeMillis())
- def msg
- try {
- // get request input
- String subnetInstanceReq = execution.getVariable("bpmnRequest")
- logger.debug(subnetInstanceReq)
-
- String requestId = execution.getVariable("mso-request-id")
- execution.setVariable("msoRequestId", requestId)
- logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId)
-
- //subscriberInfo
- String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId")
- if (isBlank(globalSubscriberId)) {
- msg = "Input globalSubscriberId' is null"
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
- execution.setVariable("globalSubscriberId", globalSubscriberId)
- }
-
- //NSSI Info
- String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID")
- if (isBlank(serviceInstanceID)) {
- msg = "Input serviceInstanceID is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("serviceInstanceID", serviceInstanceID)
- }
-
- String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name")
- execution.setVariable("servicename", servicename)
-
- String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId")
- if (isBlank(nsiId)) {
- msg = "Input nsiId is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("nsiId", nsiId)
- }
-
- String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType")
- if (isBlank(networkType)) {
- msg = "Input networkType is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("networkType", networkType.toUpperCase())
- }
-
- //requestParameters, subscriptionServiceType is 5G
- String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType")
- if (isBlank(subscriptionServiceType)) {
- msg = "Input subscriptionServiceType is null"
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
- execution.setVariable("subscriptionServiceType", subscriptionServiceType)
- }
-
- String jobId = UUID.randomUUID().toString()
- execution.setVariable("jobId", jobId)
-
- String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties")
- execution.setVariable("sliceParams", sliceParams)
-
- } catch(BpmnError e) {
- throw e
- } catch(Exception ex) {
- msg = "Exception in ModifySliceSubnet.preProcessRequest " + ex.getMessage()
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- logger.debug(Prefix + "preProcessRequest Exit")
- }
-
-
- /**
- * create operation status in request db
- *
- * Init the Operation Status
- */
- def prepareInitOperationStatus = { DelegateExecution execution ->
- logger.debug(Prefix + "prepareInitOperationStatus Start")
-
- String serviceId = execution.getVariable("serviceInstanceID")
- String jobId = execution.getVariable("jobId")
- String nsiId = execution.getVariable("nsiId")
- logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId)
-
- ResourceOperationStatus initStatus = new ResourceOperationStatus()
- initStatus.setServiceId(serviceId)
- initStatus.setOperationId(jobId)
- initStatus.setResourceTemplateUUID(nsiId)
- initStatus.setOperType("Modify")
- requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
-
- logger.debug(Prefix + "prepareInitOperationStatus Exit")
- }
-
-
-
- /**
- * return sync response
- */
- def sendSyncResponse = { DelegateExecution execution ->
- logger.debug(Prefix + "sendSyncResponse Start")
- try {
- String jobId = execution.getVariable("jobId")
- String modifySyncResponse = """{"jobId": "${jobId}","status": "processing"}"""
- .trim().replaceAll(" ", "")
- logger.debug("sendSyncResponse to APIH:" + "\n" + modifySyncResponse)
- sendWorkflowResponse(execution, 202, modifySyncResponse)
-
- execution.setVariable("sentSyncResponse", true)
- } catch (Exception ex) {
- String msg = "Exception in sendSyncResponse:" + ex.getMessage()
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- logger.debug(Prefix + "sendSyncResponse Exit")
- }
+ String Prefix="ModifySliceSubnet_"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ RequestDBUtil requestDBUtil = new RequestDBUtil()
+
+ private static final Logger logger = LoggerFactory.getLogger(ModifySliceSubnet.class)
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ logger.debug(Prefix + "preProcessRequest Start")
+ execution.setVariable("prefix", Prefix)
+ execution.setVariable("startTime", System.currentTimeMillis())
+ def msg
+ try {
+ // get request input
+ String subnetInstanceReq = execution.getVariable("bpmnRequest")
+ logger.debug(subnetInstanceReq)
+
+ String requestId = execution.getVariable("mso-request-id")
+ execution.setVariable("msoRequestId", requestId)
+ logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId)
+
+ //subscriberInfo
+ String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId")
+ if (isBlank(globalSubscriberId)) {
+ msg = "Input globalSubscriberId' is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("globalSubscriberId", globalSubscriberId)
+ }
+
+ //NSSI Info
+ String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID")
+ if (isBlank(serviceInstanceID)) {
+ msg = "Input serviceInstanceID is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("serviceInstanceID", serviceInstanceID)
+ }
+
+ String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name")
+ execution.setVariable("servicename", servicename)
+
+ String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId")
+ if (isBlank(nsiId)) {
+ msg = "Input nsiId is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("nsiId", nsiId)
+ }
+
+ String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType")
+ if (isBlank(networkType)) {
+ msg = "Input networkType is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("networkType", networkType.toUpperCase())
+ }
+
+ //requestParameters, subscriptionServiceType is 5G
+ String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType")
+ if (isBlank(subscriptionServiceType)) {
+ msg = "Input subscriptionServiceType is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("subscriptionServiceType", subscriptionServiceType)
+ }
+
+ String jobId = UUID.randomUUID().toString()
+ execution.setVariable("jobId", jobId)
+
+ String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties")
+ execution.setVariable("sliceParams", sliceParams)
+
+ } catch(BpmnError e) {
+ throw e
+ } catch(Exception ex) {
+ msg = "Exception in ModifySliceSubnet.preProcessRequest " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "preProcessRequest Exit")
+ }
+
+
+ /**
+ * create operation status in request db
+ *
+ * Init the Operation Status
+ */
+ def prepareInitOperationStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareInitOperationStatus Start")
+
+ String serviceId = execution.getVariable("serviceInstanceID")
+ String jobId = execution.getVariable("jobId")
+ String nsiId = execution.getVariable("nsiId")
+ logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId)
+
+ ResourceOperationStatus initStatus = new ResourceOperationStatus()
+ initStatus.setServiceId(serviceId)
+ initStatus.setOperationId(jobId)
+ initStatus.setResourceTemplateUUID(nsiId)
+ initStatus.setOperType("Modify")
+ requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
+
+ logger.debug(Prefix + "prepareInitOperationStatus Exit")
+ }
+
+
+
+ /**
+ * return sync response
+ */
+ def sendSyncResponse = { DelegateExecution execution ->
+ logger.debug(Prefix + "sendSyncResponse Start")
+ try {
+ String jobId = execution.getVariable("jobId")
+ String modifySyncResponse = """{"jobId": "${jobId}","status": "processing"}"""
+ .trim().replaceAll(" ", "")
+ logger.debug("sendSyncResponse to APIH:" + "\n" + modifySyncResponse)
+ sendWorkflowResponse(execution, 202, modifySyncResponse)
+
+ execution.setVariable("sentSyncResponse", true)
+ } catch (Exception ex) {
+ String msg = "Exception in sendSyncResponse:" + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "sendSyncResponse Exit")
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
index 6ca3937d68..9707dd2242 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
@@ -36,6 +36,7 @@ import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.T
import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.serviceinstancebeans.RequestDetails
import javax.ws.rs.core.Response
@@ -185,8 +186,10 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
def currentNSSI = [:]
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+ String nssiId = "5G-999"
ServiceInstance nssi = new ServiceInstance()
- nssi.setServiceInstanceId("5G-999")
+ nssi.setServiceInstanceId(nssiId)
+ currentNSSI.put("nssiId", nssiId)
SliceProfiles sliceProfiles = new SliceProfiles()
@@ -194,13 +197,49 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
slProfiles.add(new SliceProfile())
slProfiles.add(new SliceProfile())
- nssi.setSliceProfiles(sliceProfiles)
+ //nssi.setSliceProfiles(sliceProfiles)
currentNSSI.put("nssi", nssi)
- DoCommonCoreNSSI obj = new DoCommonCoreNSSI()
- obj.getNSSIAssociatedProfiles(mockExecution)
+ DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
+ when(spy.getAAIClient()).thenReturn(client)
+
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class) //new AAIResultWrapper(json)
+ Relationships rsMock = mock(Relationships.class)
+ Optional<Relationships> orsMock = Optional.of(rsMock)
+ List<AAIResourceUri> allottedUris = new ArrayList<>()
+ AAIResourceUri allottedUri = AAIUriFactory.createResourceUri(Types.ALLOTTED_RESOURCE.getFragment("allotted-id"))
+ allottedUris.add(allottedUri)
+
+ when(client.get(nssiUri)).thenReturn(wrapperMock)
+ when(wrapperMock.getRelationships()).thenReturn(orsMock)
+ when(rsMock.getRelatedUris(Types.ALLOTTED_RESOURCE)).thenReturn(allottedUris)
+
+ String sliceProfileInstanceId = "slice-profile-instance-id"
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+ sliceProfileInstance.setServiceRole("slice-profile-instance")
+
+ List<AAIResourceUri> sliceProfileInstanceUris = new ArrayList<>()
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstance.getServiceInstanceId()))
+ sliceProfileInstanceUris.add(sliceProfileInstanceUri)
+
+ Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance)
+
+ when(client.get(allottedUri)).thenReturn(wrapperMock)
+ when(rsMock.getRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(sliceProfileInstanceUris)
+ when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt)
+
+
+ SliceProfiles sps = new SliceProfiles()
+ sps.getSliceProfile().addAll(slProfiles)
+ sliceProfileInstance.setSliceProfiles(sps)
+
+ spy.getNSSIAssociatedProfiles(mockExecution)
List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
+ assertTrue("sliceProfileInstanceUri not found in contect Map", currentNSSI.get("sliceProfileInstanceUri") != null)
assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
}
@@ -262,6 +301,20 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-subscriber-id").serviceSubscription("subscription-service-type").
+ serviceInstance("slice-profile-instance-id"))
+
+ String sliceProfileInstanceId = "slice-profile-instance-id"
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+ sliceProfileInstance.setServiceRole("slice-profile-instance")
+
+ Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance)
+
+ when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt)
+
+ currentNSSI.put("sliceProfileInstanceUri", sliceProfileInstanceUri)
+
DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
@@ -284,13 +337,19 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
associatedProfiles.add(sliceProfile2)
associatedProfiles.add(sliceProfile3)
+ SliceProfiles sps = new SliceProfiles()
+ sps.getSliceProfile().addAll(associatedProfiles)
+ sliceProfileInstance.setSliceProfiles(sps)
+
int sizeBefore = associatedProfiles.size()
- doNothing().when(client).update(nssiUri, nssi)
+ doNothing().when(client).update(sliceProfileInstanceUri, sliceProfileInstance)
+
+ doNothing().when(client). disconnect(nssiUri, sliceProfileInstanceUri)
spy.removeSPAssociationWithNSSI(mockExecution)
- assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1))
+ assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("sliceProfileInstance")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1))
}
@@ -300,30 +359,16 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
- String globalSubscriberId = "global-id"
- String subscriptionServiceType = "subscription-service-type"
- String nssiId = "5G-999"
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-subscriber-id").serviceSubscription("subscription-service-type").
+ serviceInstance("slice-profile-instance-id"))
- when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
- when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
-
- currentNSSI.put("nssiId", nssiId)
-
- String theSNSSAI = "theS-NSSAI"
-
- SliceProfile sliceProfile = new SliceProfile()
- sliceProfile.setSNssai(theSNSSAI)
- sliceProfile.setProfileId("prof-id")
-
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
-
- currentNSSI.put("sliceProfileS-NSSAI", sliceProfile)
+ currentNSSI.put("sliceProfileInstanceUri", uri)
DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
- doNothing().when(client).delete(nssiUri)
+ doNothing().when(client).delete(uri)
spy.deleteSliceProfileInstance(mockExecution)
@@ -426,8 +471,13 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
prepareProject(cloudRegionAAIUri)
- String requestDetails = spy.prepareRequestDetails(mockExecution)
+ String prepareRequestDetailsResponse = spy.prepareRequestDetails(mockExecution)
+
+ JsonUtils jsonUtil = new JsonUtils()
+ String errorCode = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorCode")
+ String errMsg = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorMessage")
+ assertTrue(errMsg, errorCode == null || errorCode.isEmpty())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
index c6e874591f..26b96a0a4a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
@@ -26,6 +26,7 @@ import org.mockito.Mockito
import org.onap.aai.domain.yang.v19.*
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
@@ -153,31 +154,6 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
@Test
- void testGetNSSIAssociatedProfiles() {
- def currentNSSI = [:]
- when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
-
- ServiceInstance nssi = new ServiceInstance()
- nssi.setServiceInstanceId("5G-999")
-
- SliceProfiles sliceProfiles = new SliceProfiles()
-
- List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile()
- slProfiles.add(new SliceProfile())
- slProfiles.add(new SliceProfile())
-
- nssi.setSliceProfiles(sliceProfiles)
- currentNSSI.put("nssi", nssi)
-
- DoDeallocateCoreNSSI obj = new DoDeallocateCoreNSSI()
- obj.getNSSIAssociatedProfiles(mockExecution)
-
- List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
- assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
- }
-
-
- @Test
void testCalculateSNSSAI() {
def currentNSSI = [:]
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
@@ -232,9 +208,30 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
currentNSSI.put("nsiId", nsiId)
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ ServiceInstance nssi = new ServiceInstance()
+ nssi.setServiceInstanceId(nssiId)
+
+ AllottedResources allottedResources = new AllottedResources()
+ AllottedResource allottedResource = new AllottedResource()
+ allottedResource.setId(UUID.randomUUID().toString())
+ allottedResources.getAllottedResource().add(allottedResource)
+ nssi.setAllottedResources(allottedResources)
+
+ currentNSSI.put("nssi", nssi)
+
AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId))
- doNothing().when(client).disconnect(nssiUri, nsiUri)
+ doNothing().when(client).update(nssiUri, nssi)
+
+ String globalSubscriberId = "globalSubscriberId"
+ String subscriptionServiceType = "subscription-service-type"
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
+ when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
+
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).allottedResource(allottedResource.getId()))
+
+ doNothing().when(client).disconnect(nsiUri, allottedResourceUri)
spy.removeNSSIAssociationWithNSI(mockExecution)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
index 32c4c1aa57..ac6f897dfa 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
@@ -23,6 +23,8 @@ package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.Before
import org.junit.Test
+import org.mockito.Mockito
+import org.onap.aai.domain.yang.v19.AllottedResource
import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aai.domain.yang.v19.SliceProfile
import org.onap.aai.domain.yang.v19.SliceProfiles
@@ -46,31 +48,6 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
@Test
- void testGetNSSIAssociatedProfiles() {
- def currentNSSI = [:]
- when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
-
- ServiceInstance nssi = new ServiceInstance()
- nssi.setServiceInstanceId("5G-999")
-
- SliceProfiles sliceProfiles = new SliceProfiles()
-
- List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile()
- slProfiles.add(new SliceProfile())
- slProfiles.add(new SliceProfile())
-
- nssi.setSliceProfiles(sliceProfiles)
- currentNSSI.put("nssi", nssi)
-
- DoModifyCoreNSSI obj = new DoModifyCoreNSSI()
- obj.getNSSIAssociatedProfiles(mockExecution)
-
- List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
- assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
- }
-
-
- @Test
void testCalculateSNSSAISliceProfileInstanceHasToBeDeleted() {
def currentNSSI = [:]
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
@@ -154,9 +131,15 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
String sliceProfileId = "sliceProfileId"
- currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"],\"expDataRateUL\":\"12\"}")
+ currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"],\"expDataRateUL\":\"12\",\"expDataRateDL\":\"5\"," +
+ "\"activityFactor\":\"2\",\"resourceSharingLevel\":\"resource-sharing-level\",\"uEMobilityLevel\":\"ue-mobility-level\",\"coverageAreaTAList\":\"coverage-area-ta-list\"," +
+ "\"maxNumberofUEs\":\"10000\",\"latency\":\"7\"}")
currentNSSI.put("sliceProfileId", sliceProfileId)
+ List<String> snssais = new ArrayList<>()
+ snssais.add("s-nssai")
+ currentNSSI.put("S-NSSAIs", snssais)
+
DoModifyCoreNSSI spy = spy(DoModifyCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
@@ -169,17 +152,21 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
currentNSSI.put("nssiId", nssiId)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileId))
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(UUID.randomUUID().toString())
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).
+ serviceInstance(sliceProfileInstance.getServiceInstanceId()))
SliceProfile sliceProfile = new SliceProfile()
sliceProfile.setProfileId(sliceProfileId)
- doNothing().when(client).create(uri, sliceProfile)
+ doNothing().when(client).create(uri, sliceProfileInstance)
spy.createSliceProfileInstance(mockExecution)
- assertNotNull("Slice Profile doesn't exist", currentNSSI.get("createdSliceProfile"))
- assertTrue("Unexpected Slice Profile Id", ((SliceProfile)currentNSSI.get("createdSliceProfile")).getProfileId().equals(sliceProfile.getProfileId()))
+ assertTrue("Slice Profile Instance Id doesn't exist", (currentNSSI.get("createdSliceProfileInstanceId")) != null)
+
}
@@ -202,8 +189,19 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
String globalSubscriberId = "globalSubscriberId"
String subscriptionServiceType = "subscriptionServiceType"
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileId))
+ String sliceProfileInstanceId = "slice-rpofile-instance-id"
+ currentNSSI.put("createdSliceProfileInstanceId", sliceProfileInstanceId)
+
+ AllottedResource allottedResource = new AllottedResource()
+
+ String allottedResourceId = UUID.randomUUID().toString()
+
+ allottedResource.setId(allottedResourceId)
+
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceProfileInstanceId).allottedResource(allottedResourceId))
+ doNothing().when(client).create(allottedResourceUri, allottedResource)
+
+ currentNSSI.put("allottedResourceUri", allottedResourceUri)
when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
@@ -213,19 +211,26 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
SliceProfile sliceProfile = new SliceProfile()
currentNSSI.put("createdSliceProfile", sliceProfile)
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstanceId))
+
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+ Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance)
+
+ when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt)
+ doNothing().when(client).update(sliceProfileInstanceUri, sliceProfileInstance)
+
ServiceInstance nssi = new ServiceInstance()
nssi.setServiceInstanceId(nssiId)
nssi.setSliceProfiles(new SliceProfiles())
currentNSSI.put("nssi", nssi)
- int sizeBelore = nssi.getSliceProfiles().getSliceProfile().size()
-
- doNothing().when(client).update(nssiUri, nssi)
- doNothing().when(client).connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO)
+ doNothing().when(client).connect(nssiUri, sliceProfileInstanceUri, AAIEdgeLabel.USES)
spy.associateSliceProfileInstanceWithNSSI(mockExecution)
- assertTrue("Wrong number of associated slice profiles", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBelore + 1))
}
}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn
index 450faaebca..29f024991d 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn
@@ -91,13 +91,6 @@ nss.prepareInitOperationStatus(execution)</bpmn:script>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="Flow_0ou7wr9" sourceRef="Activity_1hyt0pb" targetRef="Activity_1ydx2rx" />
<bpmn:sequenceFlow id="Flow_18cgkru" sourceRef="Activity_1ydx2rx" targetRef="Activity_0qlstj2" />
- <bpmn:callActivity id="CallDoAllocateTransportNSSI" name="Call TNAllocateNSSI" calledElement="DoAllocateTransportNSSI">
- <bpmn:extensionElements>
- <camunda:in source="servicename" target="servicename" />
- </bpmn:extensionElements>
- <bpmn:incoming>Flow_0g7721r</bpmn:incoming>
- <bpmn:outgoing>Flow_189zwjw</bpmn:outgoing>
- </bpmn:callActivity>
<bpmn:sequenceFlow id="Flow_189zwjw" sourceRef="CallDoAllocateTransportNSSI" targetRef="Event_18u424w" />
<bpmn:callActivity id="CallDoAllocateCoreNSSI" name="Call CNAllocateNSSI" calledElement="DoAllocateCoreNSSI">
<bpmn:extensionElements>
@@ -118,6 +111,24 @@ nss.prepareInitOperationStatus(execution)</bpmn:script>
<bpmn:outgoing>Flow_1coedjo</bpmn:outgoing>
</bpmn:callActivity>
<bpmn:sequenceFlow id="Flow_1coedjo" sourceRef="CallDoAllocateCoreNSSI" targetRef="Event_18u424w" />
+ <bpmn:callActivity id="CallDoAllocateTransportNSSI" name="Call TNAllocateNSSI" calledElement="DoAllocateTransportNSSI">
+ <bpmn:extensionElements>
+ <camunda:in source="msoRequestId" target="msoRequestId" />
+ <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" />
+ <camunda:in source="modelUuid" target="modelUuid" />
+ <camunda:in source="globalSubscriberId" target="globalSubscriberId" />
+ <camunda:in source="dummyServiceId" target="dummyServiceId" />
+ <camunda:in source="nsiId" target="nsiId" />
+ <camunda:in source="networkType" target="networkType" />
+ <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" />
+ <camunda:in source="jobId" target="jobId" />
+ <camunda:in source="sliceParams" target="sliceParams" />
+ <camunda:out source="WorkflowException" target="WorkflowException" />
+ <camunda:in source="servicename" target="servicename" />
+ </bpmn:extensionElements>
+ <bpmn:incoming>Flow_0g7721r</bpmn:incoming>
+ <bpmn:outgoing>Flow_189zwjw</bpmn:outgoing>
+ </bpmn:callActivity>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="AllocateSliceSubnet">
@@ -126,8 +137,8 @@ nss.prepareInitOperationStatus(execution)</bpmn:script>
<di:waypoint x="1152" y="190" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_189zwjw_di" bpmnElement="Flow_189zwjw">
- <di:waypoint x="1080" y="300" />
- <di:waypoint x="1170" y="300" />
+ <di:waypoint x="1080" y="290" />
+ <di:waypoint x="1170" y="290" />
<di:waypoint x="1170" y="208" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_18cgkru_di" bpmnElement="Flow_18cgkru">
@@ -153,10 +164,10 @@ nss.prepareInitOperationStatus(execution)</bpmn:script>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0g7721r_di" bpmnElement="Flow_0g7721r">
<di:waypoint x="890" y="215" />
- <di:waypoint x="890" y="300" />
- <di:waypoint x="980" y="300" />
+ <di:waypoint x="890" y="290" />
+ <di:waypoint x="980" y="290" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="912" y="273" width="36" height="14" />
+ <dc:Bounds x="912" y="263" width="36" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1fij4ds_di" bpmnElement="Flow_1fij4ds">
@@ -208,12 +219,13 @@ nss.prepareInitOperationStatus(execution)</bpmn:script>
<bpmndi:BPMNShape id="Activity_1ydx2rx_di" bpmnElement="Activity_1ydx2rx">
<dc:Bounds x="380" y="150" width="100" height="80" />
</bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Activity_008nbm9_di" bpmnElement="CallDoAllocateTransportNSSI">
- <dc:Bounds x="980" y="260" width="100" height="80" />
- </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_01669p4_di" bpmnElement="CallDoAllocateCoreNSSI">
<dc:Bounds x="980" y="150" width="100" height="80" />
</bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_00awuik_di" bpmnElement="CallDoAllocateTransportNSSI">
+ <dc:Bounds x="980" y="250" width="100" height="80" />
+ </bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
+
diff --git a/graph-inventory/fluent-builder-maven-plugin/pom.xml b/graph-inventory/fluent-builder-maven-plugin/pom.xml
index 87f5138b4b..6e59d0d893 100644
--- a/graph-inventory/fluent-builder-maven-plugin/pom.xml
+++ b/graph-inventory/fluent-builder-maven-plugin/pom.xml
@@ -9,6 +9,36 @@
<artifactId>fluent-builder-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ <versionRange>[3.6.0,)</versionRange>
+ </pluginExecutionFilter>
+ <action>
+ <execute>
+ <runOnIncremental>false</runOnIncremental>
+ </execute>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
index 17b22ec216..9b42eacfc2 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
@@ -29,6 +29,7 @@ import javax.annotation.PostConstruct;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
import org.apache.http.HttpStatus;
+import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.db.request.beans.ArchivedInfraRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.OperationStatus;
@@ -42,6 +43,7 @@ import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.beans.WatchdogDistributionStatus;
import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest;
+import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
@@ -297,17 +299,55 @@ public class RequestsDbClient {
restTemplate.exchange(uri, HttpMethod.PATCH, entity, String.class);
}
+ /**
+ * Required for groovy usage. Cannot use Spring Autowired variables
+ *
+ * @param requestId
+ * @param basicAuth
+ * @param host
+ * @return
+ */
public InfraActiveRequests getInfraActiveRequests(String requestId, String basicAuth, String host) {
+ RestTemplate template = new RestTemplate();
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(HttpHeaders.AUTHORIZATION, basicAuth);
+ headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
URI uri = getUri(host + "/infraActiveRequests/" + requestId);
-
- return getSingleResponse(uri, InfraActiveRequests.class);
+ try {
+ InfraActiveRequests infraActiveRequests = template
+ .exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), InfraActiveRequests.class).getBody();
+ if (infraActiveRequests != null) {
+ infraActiveRequests.setRequestId(requestId);
+ }
+ return infraActiveRequests;
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ return null;
+ }
+ throw e;
+ }
}
+ /**
+ * Required for groovy usage. Cannot use Spring Autowired variables
+ *
+ * @param request
+ * @param basicAuth
+ * @param host
+ */
public void updateInfraActiveRequests(InfraActiveRequests request, String basicAuth, String host) {
+ RestTemplate template = new RestTemplate();
+ template.getInterceptors().add(new SOSpringClientFilter());
+ template.getInterceptors().add(new SpringClientPayloadFilter());
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(HttpHeaders.AUTHORIZATION, basicAuth);
+ headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
URI uri = getUri(host + "/infraActiveRequests/" + request.getRequestId());
- HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, getHttpHeaders());
- restTemplate.put(uri, entity);
+ HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers);
+ template.put(uri, entity);
}
protected URI getUri(String uri) {
diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image
index db57688dc1..a1f4fc15ae 100644
--- a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image
+++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image
@@ -8,7 +8,12 @@ ENV http_proxy=$HTTP_PROXY
ENV https_proxy=$HTTPS_PROXY
# Install commonly needed tools
-RUN apk --no-cache add curl netcat-openbsd nss apache2-utils
+RUN apk --no-cache add curl netcat-openbsd nss apache2-utils java-cacerts
+
+# Create symlink for default Java truststore
+RUN set -eux; \
+ rm -rf "$JAVA_HOME/lib/security/cacerts"; \
+ ln -sT /etc/ssl/certs/java/cacerts "$JAVA_HOME/lib/security/cacerts"
# Create 'so' user
RUN addgroup -g 1000 so && adduser -S -u 1000 -G so -s /bin/sh so
diff --git a/so-etsi-nfvo/pom.xml b/so-etsi-nfvo/pom.xml
index fa85460086..6845896fc0 100644
--- a/so-etsi-nfvo/pom.xml
+++ b/so-etsi-nfvo/pom.xml
@@ -28,6 +28,7 @@
<jaxb-api>2.3.0</jaxb-api>
<snakeyaml-version>0.11</snakeyaml-version>
<hamcrest-version>2.2</hamcrest-version>
+ <equalsverifier-version>3.4.1</equalsverifier-version>
</properties>
<build>
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaVariableNameConstants.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaVariableNameConstants.java
index fd51b1a873..a7acc3ec25 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaVariableNameConstants.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaVariableNameConstants.java
@@ -32,8 +32,7 @@ public class CamundaVariableNameConstants {
public static final String SERVICE_TYPE_PARAM_NAME = "serviceType";
public static final String NS_PACKAGE_MODEL_PARAM_NAME = "NSPackageModel";
- public static final String CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME =
- "CreateNsWorkflowProcessingException";
+ public static final String NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME = "NsWorkflowProcessingException";
public static final String CREATE_NS_RESPONSE_PARAM_NAME = "createNsResponse";
public static final String INSTANTIATE_NS_REQUEST_PARAM_NAME = "instantiateNsRequest";
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/Constants.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/Constants.java
index 14a4f4340b..c6c56c9eb3 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/Constants.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/Constants.java
@@ -30,6 +30,7 @@ public class Constants {
public static final String CREATE_NS_WORKFLOW_NAME = "CreateNs";
public static final String INSTANTIATE_NS_WORKFLOW_NAME = "InstantiateNs";
public static final String TERMINATE_NS_WORKFLOW_NAME = "TerminateNs";
+ public static final String DELETE_NS_WORKFLOW_NAME = "DeleteNs";
public static final String GET_NS_OCCURRENCE_OPERATION_STATUS_NAME = "GetNsOccurrenceOperationStatus";
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProvider.java
index 29ed85cbd8..a54a6f41f9 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProvider.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProvider.java
@@ -43,4 +43,5 @@ public interface AaiServiceProvider {
void deleteGenericVnf(final String vnfId);
+ void deleteServiceInstance(final String globalCustomerId, final String serviceType, final String serviceInstanceId);
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java
index 0da53a09c2..a3b3fa9d66 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java
@@ -22,7 +22,6 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai;
import java.util.Optional;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aaiclient.client.aai.AAIObjectType;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
@@ -93,4 +92,15 @@ public class AaiServiceProviderImpl implements AaiServiceProvider {
AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId));
aaiClientProvider.getAaiClient().delete(aaiResourceUri);
}
+
+ @Override
+ public void deleteServiceInstance(final String globalCustomerId, final String serviceType,
+ final String serviceInstanceId) {
+ logger.info(
+ "Deleting Service Instance with \nGlobal Customer Id: {}, \nService Type: {}, and \nService Instance Id: {} \nfrom AAI.",
+ globalCustomerId, serviceType, serviceInstanceId);
+ final AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(globalCustomerId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId));
+ aaiClientProvider.getAaiClient().delete(serviceInstanceUri);
+ }
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java
index 31e3011c0e..5e5e51cee0 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java
@@ -28,8 +28,10 @@ import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstan
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.SERVICE_TYPE_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.TERMINATE_NS_REQUEST_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.CREATE_NS_WORKFLOW_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.DELETE_NS_WORKFLOW_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.INSTANTIATE_NS_WORKFLOW_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.TERMINATE_NS_WORKFLOW_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction.DELETE;
import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction.INSTANTIATE;
import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction.TERMINATE;
import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.ERROR;
@@ -240,6 +242,46 @@ public class JobExecutorService {
throw new NsRequestProcessingException(message);
}
+ public void runDeleteNsJob(final String nsInstanceId) {
+ final NfvoJob nfvoJob = new NfvoJob().startTime(LocalDateTime.now()).jobType("NS").jobAction(DELETE)
+ .resourceId(nsInstanceId).status(STARTING).progress(0);
+ databaseServiceProvider.addJob(nfvoJob);
+ logger.info("New job created in database :\n{}", nfvoJob);
+
+ workflowExecutorService.executeWorkflow(nfvoJob.getJobId(), DELETE_NS_WORKFLOW_NAME,
+ getVariables(nsInstanceId, nfvoJob.getJobId()));
+
+ final ImmutablePair<String, JobStatusEnum> immutablePair =
+ waitForJobToFinish(nfvoJob.getJobId(), JOB_FINISHED_STATES);
+
+ if (immutablePair.getRight() == null) {
+ final String message = "Failed to Delete NS with id: " + nsInstanceId;
+ logger.error(message);
+ throw new NsRequestProcessingException(message);
+ }
+
+ final JobStatusEnum finalJobStatus = immutablePair.getRight();
+ final String processInstanceId = immutablePair.getLeft();
+
+ if (FINISHED.equals(finalJobStatus)) {
+ logger.info("Delete Job status: {}", finalJobStatus);
+ return;
+ }
+
+ final Optional<InlineResponse400> optional = workflowQueryService.getProblemDetails(processInstanceId);
+ if (optional.isPresent()) {
+ final InlineResponse400 problemDetails = optional.get();
+ final String message = "Failed to Delete NS with id: " + nsInstanceId + " due to:\n" + problemDetails;
+ logger.error(message);
+ throw new NsRequestProcessingException(message, problemDetails);
+ }
+
+ final String message =
+ "Received unexpected Job Status: " + finalJobStatus + " Failed to Delete NS with id: " + nsInstanceId;
+ logger.error(message);
+ throw new NsRequestProcessingException(message);
+ }
+
private void doInitialTerminateChecks(final String nsInstanceId, final TerminateNsRequest terminateNsRequest) {
if (isNotImmediateTerminateRequest(terminateNsRequest)) {
final String message = "TerminateNsRequest received with terminateTime: "
@@ -347,4 +389,11 @@ public class JobExecutorService {
variables.put(TERMINATE_NS_REQUEST_PARAM_NAME, terminateNsRequest);
return variables;
}
+
+ private Map<String, Object> getVariables(final String nsInstanceId, final String jobId) {
+ final Map<String, Object> variables = new HashMap<>();
+ variables.put(NS_INSTANCE_ID_PARAM_NAME, nsInstanceId);
+ variables.put(JOB_ID_PARAM_NAME, jobId);
+ return variables;
+ }
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/WorkflowQueryService.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/WorkflowQueryService.java
index 297e9c34af..a6180b0e52 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/WorkflowQueryService.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/WorkflowQueryService.java
@@ -20,7 +20,7 @@
package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_RESPONSE_PARAM_NAME;
-import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.TENANT_ID;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Optional;
@@ -83,7 +83,7 @@ public class WorkflowQueryService {
public Optional<InlineResponse400> getProblemDetails(final String processInstanceId) {
try {
final HistoricVariableInstance historicVariableInstance =
- getVariable(processInstanceId, CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
+ getVariable(processInstanceId, NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
logger.info("Found HistoricVariableInstance : {}", historicVariableInstance);
final Object variableValue = historicVariableInstance.getValue();
@@ -94,7 +94,7 @@ public class WorkflowQueryService {
historicVariableInstance.getValue() != null ? variableValue.getClass() : null, variableValue);
} catch (final ProcessEngineException processEngineException) {
logger.error("Unable to find {} variable using processInstanceId: {}",
- CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, processInstanceId, processEngineException);
+ NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, processInstanceId, processEngineException);
}
return Optional.empty();
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java
index e6905b86fc..d23e81201c 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java
@@ -19,7 +19,7 @@
*/
package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
-import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.JOB_ID_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_INSTANCE_ID_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.OCC_ID_PARAM_NAME;
@@ -33,6 +33,7 @@ import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400;
import org.slf4j.Logger;
@@ -77,7 +78,7 @@ public abstract class AbstractNetworkServiceTask {
final Optional<NfvoJob> optional = databaseServiceProvider.getJob(jobId);
if (optional.isPresent()) {
final InlineResponse400 problemDetails =
- (InlineResponse400) execution.getVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
+ (InlineResponse400) execution.getVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
final NfvoJob nfvoJob = optional.get();
nfvoJob.status(JobStatusEnum.ERROR).endTime(LocalDateTime.now());
@@ -146,7 +147,7 @@ public abstract class AbstractNetworkServiceTask {
protected void abortOperation(final DelegateExecution execution, final String message,
final InlineResponse400 problemDetails) {
logger.error(message);
- execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, problemDetails);
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, problemDetails);
throw new BpmnError("WORKFLOW_FAILED");
}
@@ -156,14 +157,20 @@ public abstract class AbstractNetworkServiceTask {
if (optional.isEmpty()) {
final String message = "Unable to find job using job id: " + jobId;
logger.error(message);
- execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME,
- new InlineResponse400().detail(message));
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, new InlineResponse400().detail(message));
throw new BpmnError("WORKFLOW_FAILED");
}
return optional.get();
}
+ protected void updateNsInstanceStatus(final DelegateExecution execution, final State nsStatus) {
+ final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution);
+ logger.info("Updating NfvoNsInst Status to {} and saving to DB", nsStatus);
+ nfvoNsInst.setStatus(nsStatus);
+ databaseServiceProvider.saveNfvoNsInst(nfvoNsInst);
+ }
+
protected NfvoNsInst getNfvoNsInst(final DelegateExecution execution) {
final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
return getNfvoNsInst(execution, nsInstId);
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateNsTask.java
index fa7187b388..2cf68bee14 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateNsTask.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateNsTask.java
@@ -21,7 +21,7 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_REQUEST_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_RESPONSE_PARAM_NAME;
-import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.GLOBAL_CUSTOMER_ID_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_INSTANCE_ID_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_PACKAGE_MODEL_PARAM_NAME;
@@ -102,7 +102,7 @@ public class CreateNsTask extends AbstractNetworkServiceTask {
final String message = "Unable to find NS package using NsdId: " + createNsRequest.getNsdId();
logger.error(message);
execution.setVariable(DOES_NS_PACKAGE_EXISTS_PARAM_NAME, false);
- execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME,
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME,
new InlineResponse400().detail(message));
}
@@ -113,7 +113,7 @@ public class CreateNsTask extends AbstractNetworkServiceTask {
execution.setVariable(DOES_NS_PACKAGE_EXISTS_PARAM_NAME, false);
- execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME,
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME,
new InlineResponse400().title(message).detail(message));
}
@@ -135,7 +135,7 @@ public class CreateNsTask extends AbstractNetworkServiceTask {
final Optional<NfvoNsInst> optional =
databaseServiceProvider.getNfvoNsInstByName(createNsRequest.getNsName());
final NfvoNsInst nfvoNsInst = optional.get();
- execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, new InlineResponse400()
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, new InlineResponse400()
.detail("Ns Instance already exists in database : " + nfvoNsInst.toString()));
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/DeleteNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/DeleteNsTask.java
new file mode 100644
index 0000000000..cd711fb3e8
--- /dev/null
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/DeleteNsTask.java
@@ -0,0 +1,140 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 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.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
+import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
+import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.Optional;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_INSTANCE_ID_PARAM_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.FINISHED;
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.IN_PROGRESS;
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.STARTED;
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.State.NOT_INSTANTIATED;
+
+/**
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ *
+ */
+@Component
+public class DeleteNsTask extends AbstractNetworkServiceTask {
+
+ private static final String NS_INSTANCE_EXISTS_PARAM_NAME = "nsInstanceExists";
+ private static final String NS_INSTANCE_IS_IN_NOT_INSTANTIATED_STATE_PARAM_NAME = "isInNotInstantiatedState";
+ private static final Logger logger = LoggerFactory.getLogger(DeleteNsTask.class);
+ private final AaiServiceProvider aaiServiceProvider;
+
+ @Autowired
+ public DeleteNsTask(final DatabaseServiceProvider databaseServiceProvider,
+ final AaiServiceProvider aaiServiceProvider) {
+ super(databaseServiceProvider);
+ this.aaiServiceProvider = aaiServiceProvider;
+ }
+
+ public void setJobStatusToStarted(final DelegateExecution execution) {
+ setJobStatus(execution, STARTED, "Delete NS workflow process started");
+ }
+
+ public void setJobStatusToFinished(final DelegateExecution execution) {
+ setJobStatus(execution, FINISHED, "Delete NS workflow process finished");
+ }
+
+ public void setJobStatusInProgress(final DelegateExecution execution, final String message) {
+ setJobStatus(execution, IN_PROGRESS, message);
+ }
+
+ public void setJobStatusToError(final DelegateExecution execution) {
+ setJobStatusToError(execution, "Delete NS workflow process failed");
+ }
+
+ public void checkIfNsInstanceExistsInDb(final DelegateExecution execution) {
+ logger.info("Executing checkIfNsInstanceExistsInDb ...");
+ setJobStatusInProgress(execution, "Checking that NS Instance Exists in DB");
+
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstId);
+ final boolean nsInstanceExists = optionalNfvoNsInst.isPresent();
+ logger.info("NS Instance entry with id: {} {} exist in database", nsInstId,
+ nsInstanceExists ? "does" : "doesn't");
+ execution.setVariable(NS_INSTANCE_EXISTS_PARAM_NAME, nsInstanceExists);
+
+ if (!nsInstanceExists) {
+ final String message =
+ "NS Instance with id: " + nsInstId + " does not exist in database, so will not be deleted.";
+ logger.info(message);
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, new InlineResponse400().detail(message));
+ }
+
+ logger.info("Finished executing checkIfNsInstanceExistsInDb ...");
+ }
+
+ public void checkthatNsInstanceInDbIsInNotInstantiatedState(final DelegateExecution execution) {
+ logger.info("Executing checkthatNsInstanceInDbIsInNotInstantiatedState ...");
+ setJobStatusInProgress(execution, "Checking that NS Instance is in NOT_INSTANTIATED state in Db");
+
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution, nsInstId);
+ final State nfvoNsInstState = nfvoNsInst.getStatus();
+ final boolean nsInstanceIsNotInstantiated = NOT_INSTANTIATED.equals(nfvoNsInstState);
+ logger.info("Ns Instance entry with nsInstId: {} is in state: {}", nsInstId, nfvoNsInstState);
+ execution.setVariable(NS_INSTANCE_IS_IN_NOT_INSTANTIATED_STATE_PARAM_NAME, nsInstanceIsNotInstantiated);
+
+ if (!nsInstanceIsNotInstantiated) {
+ final String message =
+ "Cannot Delete NS Instance with id: " + nsInstId + " in the state: " + nfvoNsInstState;
+ logger.info(message);
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, new InlineResponse400().detail(message));
+ }
+
+ logger.info("Finished executing checkthatNsInstanceInDbIsInNotInstantiatedState ...");
+ }
+
+ public void deleteNsInstanceFromAai(final DelegateExecution execution) {
+ logger.info("Executing deleteNsInstanceFromAAI ...");
+ setJobStatusInProgress(execution, "Deleting NS Instance from AAI");
+
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution, nsInstId);
+ final String globalCustomerId = nfvoNsInst.getGlobalCustomerId();
+ final String serviceType = nfvoNsInst.getServiceType();
+
+ aaiServiceProvider.deleteServiceInstance(globalCustomerId, serviceType, nsInstId);
+
+ logger.info("Finished executing deleteNsInstanceFromAAI ...");
+ }
+
+ public void deleteNsInstanceFromDb(final DelegateExecution execution) {
+ logger.info("Executing deleteNsInstanceFromDb ...");
+ setJobStatusInProgress(execution, "Deleting NS Instance from Db");
+
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ databaseServiceProvider.deleteNfvoNsInst(nsInstId);
+
+ logger.info("Finished executing deleteNsInstanceFromDb ...");
+ }
+}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java
index 2157051e8b..1d9e09e74b 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java
@@ -316,13 +316,6 @@ public class InstantiateNsTask extends AbstractNetworkServiceTask {
}
- private void updateNsInstanceStatus(final DelegateExecution execution, final State nsStatus) {
- final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution);
- logger.info("Updating NfvoNsInst Status to {} and saving to DB", nsStatus);
- nfvoNsInst.setStatus(nsStatus);
- databaseServiceProvider.saveNfvoNsInst(nfvoNsInst);
- }
-
private Optional<Tenant> getTenant(final Map<String, String> additionalParams) {
final String vimId = (String) additionalParams.get("vim_id");
if (vimId != null) {
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java
index 972e4d6de8..2baa2845a5 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java
@@ -22,7 +22,6 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
-import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
import org.slf4j.Logger;
@@ -116,13 +115,6 @@ public class TerminateNsTask extends AbstractNetworkServiceTask {
}
}
- private void updateNsInstanceStatus(final DelegateExecution execution, final State nsStatus) {
- final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution);
- logger.info("Updating NfvoNsInst Status to {} and saving to DB", nsStatus);
- nfvoNsInst.setStatus(nsStatus);
- databaseServiceProvider.saveNfvoNsInst(nfvoNsInst);
- }
-
private List<String> getNfvoNfInstIds(final DelegateExecution execution) {
final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
logger.info("Getting NfvoNfInstList using nsInstId: {}", nsInstId);
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/CreateNs.bpmn b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/CreateNs.bpmn
index 815b76c907..4c24f91cf9 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/CreateNs.bpmn
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/CreateNs.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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1l4zor5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0">
+<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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1l4zor5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
<bpmn:process id="CreateNs" name="&#10;CreateNs" isExecutable="true">
<bpmn:startEvent id="StartEvent_1" name="Start Process">
<bpmn:outgoing>Flow_1tqn5q5</bpmn:outgoing>
@@ -102,7 +102,7 @@
<bpmn:sequenceFlow id="Flow_1rtsvpm" sourceRef="Activity_03ht66t" targetRef="Activity_1r4l8w8" />
</bpmn:process>
<bpmn:error id="Error_0s855yd" name="java.lang.Exception" errorCode="java.lang.Exception" />
- <bpmn:error id="Error_0rqvnym" name="CreateNsProcessingException" errorCode="CREATE_NS_PROCESSING_EXCEPTION" />
+ <bpmn:error id="Error_0rqvnym" name="NsWorkflowProcessingException" errorCode="CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateNs">
<bpmndi:BPMNEdge id="Flow_1rtsvpm_di" bpmnElement="Flow_1rtsvpm">
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/DeleteNs.bpmn b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/DeleteNs.bpmn
new file mode 100644
index 0000000000..a6bb214440
--- /dev/null
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/DeleteNs.bpmn
@@ -0,0 +1,260 @@
+<?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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1l4zor5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
+ <bpmn:process id="DeleteNs" name="DeleteNs" isExecutable="true">
+ <bpmn:startEvent id="StartEvent_1" name="Start Process">
+ <bpmn:outgoing>Flow_1tqn5q5</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:endEvent id="EndEvent_1" name="End Process">
+ <bpmn:incoming>Flow_0t87ov3</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_1tqn5q5" sourceRef="StartEvent_1" targetRef="Activity_15ksfz6" />
+ <bpmn:serviceTask id="Activity_15ksfz6" name="Set Job Status to STARTED" camunda:asyncBefore="true" camunda:expression="${DeleteNsTask.setJobStatusToStarted(execution)}">
+ <bpmn:incoming>Flow_1tqn5q5</bpmn:incoming>
+ <bpmn:outgoing>Flow_0fhodlp</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_1r4l8w8" name="Set Job Status to FINISHED" camunda:expression="${DeleteNsTask.setJobStatusToFinished(execution)}">
+ <bpmn:incoming>Flow_1rtsvpm</bpmn:incoming>
+ <bpmn:outgoing>Flow_0t87ov3</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_0t87ov3" sourceRef="Activity_1r4l8w8" targetRef="EndEvent_1" />
+ <bpmn:subProcess id="Activity_06ko4e2" name="Error Handling" triggeredByEvent="true">
+ <bpmn:startEvent id="Event_1ibvrn2" name="error">
+ <bpmn:outgoing>Flow_0554tjv</bpmn:outgoing>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_0lc46mh" />
+ </bpmn:startEvent>
+ <bpmn:endEvent id="Event_02f7sr1" name="end">
+ <bpmn:incoming>Flow_04xvpee</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_0554tjv" sourceRef="Event_1ibvrn2" targetRef="Activity_1sj0nvr" />
+ <bpmn:serviceTask id="Activity_1sj0nvr" name="Set Job Status to ERROR" camunda:asyncBefore="true" camunda:expression="${DeleteNsTask.setJobStatusToError(execution)}">
+ <bpmn:incoming>Flow_0554tjv</bpmn:incoming>
+ <bpmn:outgoing>Flow_04xvpee</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_04xvpee" sourceRef="Activity_1sj0nvr" targetRef="Event_02f7sr1" />
+ </bpmn:subProcess>
+ <bpmn:subProcess id="Activity_1dx9fz6" name="Java Exception Handling" triggeredByEvent="true">
+ <bpmn:startEvent id="Event_0zne7ch" name="error">
+ <bpmn:outgoing>Flow_0j1otrx</bpmn:outgoing>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_1p3h4ta" errorRef="Error_0rqvnym" camunda:errorCodeVariable="BPMN_javaExpCode" camunda:errorMessageVariable="BPMN_javaExpMsg" />
+ </bpmn:startEvent>
+ <bpmn:endEvent id="Event_0bcyh7u">
+ <bpmn:incoming>Flow_0oqv7vl</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_0j1otrx" sourceRef="Event_0zne7ch" targetRef="Activity_15uwy90" />
+ <bpmn:serviceTask id="Activity_15uwy90" name="Set Job Status to ERROR" camunda:asyncBefore="true" camunda:expression="${DeleteNsTask.setJobStatusToError(execution)}">
+ <bpmn:incoming>Flow_0j1otrx</bpmn:incoming>
+ <bpmn:outgoing>Flow_0oqv7vl</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_0oqv7vl" sourceRef="Activity_15uwy90" targetRef="Event_0bcyh7u" />
+ </bpmn:subProcess>
+ <bpmn:serviceTask id="Activity_0vlb2nk" name="Check NS Instance exists In DB " camunda:expression="${DeleteNsTask.checkIfNsInstanceExistsInDb(execution)}">
+ <bpmn:incoming>Flow_0fhodlp</bpmn:incoming>
+ <bpmn:outgoing>Flow_1duwqzf</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_09tqz8x" name="Check that NS Instance in DB is in NOT_INSTANTIATED state" camunda:expression="${DeleteNsTask.checkthatNsInstanceInDbIsInNotInstantiatedState(execution)}">
+ <bpmn:incoming>Flow_02g3nbb</bpmn:incoming>
+ <bpmn:outgoing>Flow_1ihvsfs</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_03ht66t" name="Delete NS Instance from DB" camunda:expression="${DeleteNsTask.deleteNsInstanceFromDb(execution)}">
+ <bpmn:incoming>Flow_04wub0a</bpmn:incoming>
+ <bpmn:outgoing>Flow_1rtsvpm</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_1rtsvpm" sourceRef="Activity_03ht66t" targetRef="Activity_1r4l8w8" />
+ <bpmn:sequenceFlow id="Flow_0fhodlp" sourceRef="Activity_15ksfz6" targetRef="Activity_0vlb2nk" />
+ <bpmn:sequenceFlow id="Flow_1duwqzf" sourceRef="Activity_0vlb2nk" targetRef="Gateway_1tjajb0" />
+ <bpmn:sequenceFlow id="Flow_1ihvsfs" sourceRef="Activity_09tqz8x" targetRef="Gateway_1voek52" />
+ <bpmn:serviceTask id="Activity_1rrzri0" name="Delete NS Instance from AAI" camunda:expression="${DeleteNsTask.deleteNsInstanceFromAai(execution)}">
+ <bpmn:incoming>Flow_1buncqe</bpmn:incoming>
+ <bpmn:outgoing>Flow_04wub0a</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_04wub0a" sourceRef="Activity_1rrzri0" targetRef="Activity_03ht66t" />
+ <bpmn:exclusiveGateway id="Gateway_1tjajb0" name="Does NS Instance Exist?">
+ <bpmn:incoming>Flow_1duwqzf</bpmn:incoming>
+ <bpmn:outgoing>Flow_02g3nbb</bpmn:outgoing>
+ <bpmn:outgoing>Flow_1swnlzf</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="Flow_02g3nbb" name="Yes" sourceRef="Gateway_1tjajb0" targetRef="Activity_09tqz8x">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{nsInstanceExists}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:exclusiveGateway id="Gateway_1voek52" name="Is NS Instance in NOT INSTANTIATED State?">
+ <bpmn:incoming>Flow_1ihvsfs</bpmn:incoming>
+ <bpmn:outgoing>Flow_1buncqe</bpmn:outgoing>
+ <bpmn:outgoing>Flow_1eozcur</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="Flow_1buncqe" name="Yes" sourceRef="Gateway_1voek52" targetRef="Activity_1rrzri0">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{isInNotInstantiatedState}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:endEvent id="Event_0dqc93c">
+ <bpmn:incoming>Flow_1swnlzf</bpmn:incoming>
+ <bpmn:incoming>Flow_1eozcur</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_0pfrgad" errorRef="Error_0rqvnym" />
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_1swnlzf" name="No" sourceRef="Gateway_1tjajb0" targetRef="Event_0dqc93c">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{not nsInstanceExists}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="Flow_1eozcur" name="No" sourceRef="Gateway_1voek52" targetRef="Event_0dqc93c">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{not isInNotInstantiatedState}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ </bpmn:process>
+ <bpmn:error id="Error_0s855yd" name="java.lang.Exception" errorCode="java.lang.Exception" />
+ <bpmn:error id="Error_0rqvnym" name="NsWorkflowProcessingException" errorCode="DELETE_NS_WORKFLOW_PROCESSING_EXCEPTION" />
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteNs">
+ <bpmndi:BPMNEdge id="Flow_1eozcur_di" bpmnElement="Flow_1eozcur">
+ <di:waypoint x="830" y="192" />
+ <di:waypoint x="830" y="270" />
+ <di:waypoint x="708" y="270" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="843" y="228" width="14" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1swnlzf_di" bpmnElement="Flow_1swnlzf">
+ <di:waypoint x="550" y="192" />
+ <di:waypoint x="550" y="270" />
+ <di:waypoint x="672" y="270" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="558" y="228" width="14" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1buncqe_di" bpmnElement="Flow_1buncqe">
+ <di:waypoint x="855" y="167" />
+ <di:waypoint x="960" y="167" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="890" y="149" width="19" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_02g3nbb_di" bpmnElement="Flow_02g3nbb">
+ <di:waypoint x="575" y="167" />
+ <di:waypoint x="640" y="167" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="598" y="149" width="19" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_04wub0a_di" bpmnElement="Flow_04wub0a">
+ <di:waypoint x="1060" y="167" />
+ <di:waypoint x="1100" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1ihvsfs_di" bpmnElement="Flow_1ihvsfs">
+ <di:waypoint x="740" y="167" />
+ <di:waypoint x="805" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1duwqzf_di" bpmnElement="Flow_1duwqzf">
+ <di:waypoint x="490" y="167" />
+ <di:waypoint x="525" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0fhodlp_di" bpmnElement="Flow_0fhodlp">
+ <di:waypoint x="350" y="167" />
+ <di:waypoint x="390" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1rtsvpm_di" bpmnElement="Flow_1rtsvpm">
+ <di:waypoint x="1200" y="167" />
+ <di:waypoint x="1240" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0t87ov3_di" bpmnElement="Flow_0t87ov3">
+ <di:waypoint x="1340" y="167" />
+ <di:waypoint x="1382" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1tqn5q5_di" bpmnElement="Flow_1tqn5q5">
+ <di:waypoint x="208" y="167" />
+ <di:waypoint x="250" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
+ <dc:Bounds x="172" y="149" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="158" y="192" width="67" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_0db1w1a_di" bpmnElement="EndEvent_1">
+ <dc:Bounds x="1382" y="149" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1369" y="192" width="63" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_15ksfz6_di" bpmnElement="Activity_15ksfz6">
+ <dc:Bounds x="250" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1r4l8w8_di" bpmnElement="Activity_1r4l8w8">
+ <dc:Bounds x="1240" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_06ko4e2_di" bpmnElement="Activity_06ko4e2" isExpanded="true">
+ <dc:Bounds x="431" y="360" width="438" height="130" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="Flow_04xvpee_di" bpmnElement="Flow_04xvpee">
+ <di:waypoint x="681" y="423" />
+ <di:waypoint x="813" y="423" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0554tjv_di" bpmnElement="Flow_0554tjv">
+ <di:waypoint x="489" y="423" />
+ <di:waypoint x="581" y="423" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="Event_1ibvrn2_di" bpmnElement="Event_1ibvrn2">
+ <dc:Bounds x="453" y="405" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="459" y="448" width="24" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_02f7sr1_di" bpmnElement="Event_02f7sr1">
+ <dc:Bounds x="813" y="405" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="823" y="447" width="19" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1sj0nvr_di" bpmnElement="Activity_1sj0nvr">
+ <dc:Bounds x="581" y="383" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1dx9fz6_di" bpmnElement="Activity_1dx9fz6" isExpanded="true">
+ <dc:Bounds x="431" y="520" width="438" height="130" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="Flow_0oqv7vl_di" bpmnElement="Flow_0oqv7vl">
+ <di:waypoint x="680" y="583" />
+ <di:waypoint x="772" y="583" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0j1otrx_di" bpmnElement="Flow_0j1otrx">
+ <di:waypoint x="522" y="583" />
+ <di:waypoint x="580" y="583" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="Event_0zne7ch_di" bpmnElement="Event_0zne7ch">
+ <dc:Bounds x="486" y="565" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="493" y="608" width="24" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_0bcyh7u_di" bpmnElement="Event_0bcyh7u">
+ <dc:Bounds x="772" y="565" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_15uwy90_di" bpmnElement="Activity_15uwy90">
+ <dc:Bounds x="580" y="543" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0vlb2nk_di" bpmnElement="Activity_0vlb2nk">
+ <dc:Bounds x="390" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_09tqz8x_di" bpmnElement="Activity_09tqz8x">
+ <dc:Bounds x="640" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_03ht66t_di" bpmnElement="Activity_03ht66t">
+ <dc:Bounds x="1100" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1rrzri0_di" bpmnElement="Activity_1rrzri0">
+ <dc:Bounds x="960" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_1tjajb0_di" bpmnElement="Gateway_1tjajb0" isMarkerVisible="true">
+ <dc:Bounds x="525" y="142" width="50" height="50" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="505" y="106" width="89" height="27" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_1voek52_di" bpmnElement="Gateway_1voek52" isMarkerVisible="true">
+ <dc:Bounds x="805" y="142" width="50" height="50" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="791" y="83" width="79" height="53" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_029a1ih_di" bpmnElement="Event_0dqc93c">
+ <dc:Bounds x="672" y="252" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="646" y="245" width="88" height="27" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/InstantiateNs.bpmn b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/InstantiateNs.bpmn
index ba9e641d84..bc34c144c9 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/InstantiateNs.bpmn
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/InstantiateNs.bpmn
@@ -133,7 +133,7 @@
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_1i36dw4" sourceRef="Activity_0gkpdft" targetRef="Activity_1w09i1k" />
</bpmn:process>
- <bpmn:error id="Error_0jsct8p" name="InstantiateNsProcessingException" errorCode="INSTANTIATE_NS_PROCESSING_EXCEPTION" />
+ <bpmn:error id="Error_0jsct8p" name="NsWorkflowProcessingException" errorCode="INSTANTIATE_NS_WORKFLOW_PROCESSING_EXCEPTION" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="InstantiateNs">
<bpmndi:BPMNEdge id="Flow_1p21p1m_di" bpmnElement="Flow_1p21p1m">
@@ -328,4 +328,4 @@
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
-</bpmn:definitions>
+</bpmn:definitions> \ No newline at end of file
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/TerminateNs.bpmn b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/TerminateNs.bpmn
index 36c52c8ad6..e971f6acf0 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/TerminateNs.bpmn
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/TerminateNs.bpmn
@@ -123,7 +123,7 @@
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_1i36dw4" sourceRef="Activity_0gkpdft" targetRef="Activity_1w09i1k" />
</bpmn:process>
- <bpmn:error id="Error_0jsct8p" name="TerminateNsProcessingException" errorCode="TERMINATE_NS_PROCESSING_EXCEPTION" />
+ <bpmn:error id="Error_0jsct8p" name="NsWorkflowProcessingException" errorCode="TERMINATE_NS_WORKFLOW_PROCESSING_EXCEPTION" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="TerminateNs">
<bpmndi:BPMNEdge id="Flow_1i36dw4_di" bpmnElement="Flow_1i36dw4">
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java
index 86f2879966..b6fd9e407a 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java
@@ -147,4 +147,9 @@ public abstract class BaseTest {
return runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null;
}
+ protected String getAaiServiceInstanceEndPoint() {
+ return "/aai/v[0-9]+/business/customers/customer/" + GLOBAL_CUSTOMER_ID
+ + "/service-subscriptions/service-subscription/" + SERVICE_TYPE
+ + "/service-instances/service-instance/.*";
+ }
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/CreateNsTaskTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/CreateNsTaskTest.java
index 05213a344f..3686cd620d 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/CreateNsTaskTest.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/CreateNsTaskTest.java
@@ -234,7 +234,7 @@ public class CreateNsTaskTest extends BaseTest {
assertNull(nsResponseVariable);
final HistoricVariableInstance workflowExceptionVariable = getVariable(processInstance.getProcessInstanceId(),
- CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
+ CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
final InlineResponse400 problemDetails = (InlineResponse400) workflowExceptionVariable.getValue();
assertNotNull(problemDetails);
@@ -306,7 +306,7 @@ public class CreateNsTaskTest extends BaseTest {
mockEtsiCatalogEndpoints(nsdId);
- final String modelEndpoint = getAiaServiceInstancelEndPoint(createNsRequest);
+ final String modelEndpoint = getAaiServiceInstanceEndPoint();
wireMockServer.stubFor(put(urlMatching(modelEndpoint)).willReturn(WireMock.serverError()));
wireMockServer.stubFor(get(urlMatching(modelEndpoint)).willReturn(WireMock.serverError()));
@@ -339,18 +339,12 @@ public class CreateNsTaskTest extends BaseTest {
}
private void mockAAIEndpoints(final CreateNsRequest createNsRequest) {
- final String modelEndpoint = getAiaServiceInstancelEndPoint(createNsRequest);
+ final String modelEndpoint = getAaiServiceInstanceEndPoint();
wireMockServer.stubFor(put(urlMatching(modelEndpoint)).willReturn(ok()));
wireMockServer.stubFor(get(urlMatching(modelEndpoint)).willReturn(notFound()));
}
- private String getAiaServiceInstancelEndPoint(final CreateNsRequest createNsRequest) {
- return "/aai/v[0-9]+/business/customers/customer/" + GLOBAL_CUSTOMER_ID
- + "/service-subscriptions/service-subscription/" + SERVICE_TYPE
- + "/service-instances/service-instance/.*";
- }
-
private void mockEtsiCatalogEndpoints(final String nsdId) {
mockRestServiceServer.expect(requestTo(ETSI_CATALOG_URL + "/nsd/v1/ns_descriptors/" + nsdId))
.andExpect(method(HttpMethod.GET))
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/DeleteNsTaskTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/DeleteNsTaskTest.java
new file mode 100644
index 0000000000..adb8a9e69b
--- /dev/null
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/DeleteNsTaskTest.java
@@ -0,0 +1,185 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 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.so.etsi.nfvo.ns.workflow.engine.tasks;
+
+import com.google.gson.Gson;
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.BaseTest;
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider;
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.NsRequestProcessingException;
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service.JobExecutorService;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
+import org.springframework.beans.factory.annotation.Autowired;
+import java.time.LocalDateTime;
+import java.util.Optional;
+import java.util.UUID;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.ok;
+import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ *
+ */
+public class DeleteNsTaskTest extends BaseTest {
+
+ @Autowired
+ private JobExecutorService objUnderTest;
+
+ @Autowired
+ private GsonProvider gsonProvider;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private Gson gson;
+
+ @Before
+ public void before() {
+ wireMockServer.resetAll();
+ gson = gsonProvider.getGson();
+ }
+
+ @After
+ public void after() {
+ wireMockServer.resetAll();
+ }
+
+ @Test
+ public void testRunDeleteNsJob_nsInstanceIdNotInDatabase_throwsException() {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ assertTrue(databaseServiceProvider.getNfvoNsInst(nsInstanceId).isEmpty());
+
+ expectedException.expect(NsRequestProcessingException.class);
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+ }
+
+ @Test
+ public void testRunDeleteNsJob_nsInstanceStateInstantiated_throwsException() {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ addDummyNsToDatabase(nsInstanceId, State.INSTANTIATED);
+
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInst.isPresent());
+ assertEquals(State.INSTANTIATED, optionalNfvoNsInst.get().getStatus());
+
+ expectedException.expect(NsRequestProcessingException.class);
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+ }
+
+ @Test
+ public void testRunDeleteNsJob_nsInstanceStateInstantiating_throwsException() {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ addDummyNsToDatabase(nsInstanceId, State.INSTANTIATING);
+
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInst.isPresent());
+ assertEquals(State.INSTANTIATING, optionalNfvoNsInst.get().getStatus());
+
+ expectedException.expect(NsRequestProcessingException.class);
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+ }
+
+ @Test
+ public void testRunDeleteNsJob_nsInstanceStateTerminating_throwsException() {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ addDummyNsToDatabase(nsInstanceId, State.TERMINATING);
+
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInst.isPresent());
+ assertEquals(State.TERMINATING, optionalNfvoNsInst.get().getStatus());
+
+ expectedException.expect(NsRequestProcessingException.class);
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+ }
+
+ @Test
+ public void testRunDeleteNsJob_nsInstanceStateFailed_throwsException() {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ addDummyNsToDatabase(nsInstanceId, State.FAILED);
+
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInst.isPresent());
+ assertEquals(State.FAILED, optionalNfvoNsInst.get().getStatus());
+
+ expectedException.expect(NsRequestProcessingException.class);
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+ }
+
+ @Test
+ public void testRunDeleteNsJob_SuccessfulCase() throws InterruptedException {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ addDummyNsToDatabase(nsInstanceId, State.NOT_INSTANTIATED);
+ mockAaiEndpoints();
+
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInst.isPresent());
+ assertEquals(State.NOT_INSTANTIATED, optionalNfvoNsInst.get().getStatus());
+
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+
+ final Optional<NfvoJob> optional = getJobByResourceId(nsInstanceId);
+ assertTrue(optional.isPresent());
+ final NfvoJob nfvoJob = optional.get();
+
+ // Confirm Process finishes in STATE_COMPLETED
+ assertTrue(waitForProcessInstanceToFinish(nfvoJob.getProcessInstanceId()));
+ final HistoricProcessInstance historicProcessInstance =
+ getHistoricProcessInstance(nfvoJob.getProcessInstanceId());
+ assertNotNull(historicProcessInstance);
+ assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState());
+
+ // Confirm NS Instance no longer in database
+ final Optional<NfvoNsInst> optionalNfvoNsInstance = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInstance.isEmpty());
+ }
+
+ private void addDummyNsToDatabase(final String nsInstanceId, final State state) {
+ final String nsPackageId = UUID.randomUUID().toString();
+ final NfvoNsInst nfvoNsInst = new NfvoNsInst().nsInstId(nsInstanceId).name("nsName").nsPackageId(nsPackageId)
+ .nsdId("nsdId").nsdInvariantId("nsdId").status(state).statusUpdatedTime(LocalDateTime.now())
+ .globalCustomerId(GLOBAL_CUSTOMER_ID).serviceType(SERVICE_TYPE);
+ databaseServiceProvider.saveNfvoNsInst(nfvoNsInst);
+ }
+
+ private void mockAaiEndpoints() {
+ final String modelEndpoint = getAaiServiceInstanceEndPoint();
+ final String resourceVersion = "12345";
+
+ final String body =
+ "{\"resource-version\": \"" + resourceVersion + "\",\n\"orchestration-status\": \"Assigned\"}";
+ wireMockServer.stubFor(get(urlMatching(modelEndpoint)).willReturn(ok()).willReturn(okJson(body)));
+
+ wireMockServer.stubFor(
+ delete(urlMatching(modelEndpoint + "\\?resource-version=" + resourceVersion)).willReturn(ok()));
+ }
+}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/MonitorSol003AdapterCreateJobTaskTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/MonitorSol003AdapterCreateJobTaskTest.java
index ff5c2a9105..aa8d8cf10e 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/MonitorSol003AdapterCreateJobTaskTest.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/MonitorSol003AdapterCreateJobTaskTest.java
@@ -132,7 +132,7 @@ public class MonitorSol003AdapterCreateJobTaskTest extends BaseTest {
assertNull(nsResponseVariable);
final HistoricVariableInstance workflowExceptionVariable = getVariable(processInstance.getProcessInstanceId(),
- CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
+ CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
final InlineResponse400 problemDetails = (InlineResponse400) workflowExceptionVariable.getValue();
assertNotNull(problemDetails);
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/TerminateNsTaskTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/TerminateNsTaskTest.java
index 14e5b1cafc..b821c85edd 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/TerminateNsTaskTest.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/TerminateNsTaskTest.java
@@ -75,15 +75,9 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
public class TerminateNsTaskTest extends BaseTest {
@Autowired
- @Qualifier(ETSI_CATALOG_REST_TEMPLATE_BEAN)
- private RestTemplate etsiCatalogRestTemplate;
-
- @Autowired
@Qualifier(SOL003_ADAPTER_REST_TEMPLATE_BEAN)
private RestTemplate sol003AdapterRestTemplate;
- private MockRestServiceServer mockEtsiCatalogRestServiceServer;
-
private MockRestServiceServer mockSol003AdapterRestServiceServer;
@Autowired
@@ -101,21 +95,14 @@ public class TerminateNsTaskTest extends BaseTest {
public void before() {
wireMockServer.resetAll();
gson = gsonProvider.getGson();
-
- mockEtsiCatalogRestServiceServer =
- MockRestServiceServer.bindTo(etsiCatalogRestTemplate).ignoreExpectOrder(true).build();
mockSol003AdapterRestServiceServer =
MockRestServiceServer.bindTo(sol003AdapterRestTemplate).ignoreExpectOrder(true).build();
-
- etsiCatalogRestTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson));
sol003AdapterRestTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson));
-
}
@After
public void after() {
wireMockServer.resetAll();
- mockEtsiCatalogRestServiceServer.reset();
}
@Test
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/pom.xml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/pom.xml
index e0439073bb..cf852c14b0 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/pom.xml
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/pom.xml
@@ -31,5 +31,17 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>nl.jqno.equalsverifier</groupId>
+ <artifactId>equalsverifier</artifactId>
+ <version>${equalsverifier-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project> \ No newline at end of file
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java
index 9453caac9e..ce2487ea9d 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java
@@ -238,14 +238,17 @@ public class NfvoJob {
@Override
public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
if (obj instanceof NfvoJob) {
final NfvoJob other = (NfvoJob) obj;
return Objects.equals(jobId, other.jobId) && Objects.equals(processInstanceId, other.processInstanceId)
&& Objects.equals(jobType, other.jobType) && Objects.equals(jobAction, other.jobAction)
&& Objects.equals(progress, other.progress) && Objects.equals(status, other.status)
&& Objects.equals(startTime, other.startTime) && Objects.equals(endTime, other.endTime)
- && Objects.equals(status, other.status) && Objects.equals(resourceId, other.resourceId)
- && Objects.equals(resourceName, other.resourceName)
+ && Objects.equals(resourceId, other.resourceId) && Objects.equals(resourceName, other.resourceName)
&& Utils.isEquals(nfvoJobStatuses, other.nfvoJobStatuses);
}
return false;
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java
index 89e07701ed..be673b47fa 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java
@@ -116,17 +116,21 @@ public class NfvoJobStatus {
@Override
public int hashCode() {
- return Objects.hash(id, status, updatedTime, description, nfvoJob.getJobId());
+ return Objects.hash(id, status, updatedTime, description, nfvoJob != null ? nfvoJob.getJobId() : 0);
}
@Override
public boolean equals(final Object obj) {
-
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
if (obj instanceof NfvoJobStatus) {
final NfvoJobStatus other = (NfvoJobStatus) obj;
return Objects.equals(id, other.id) && Objects.equals(status, other.status)
&& Objects.equals(updatedTime, other.updatedTime) && Objects.equals(description, other.description)
- && Objects.equals(nfvoJob.getJobId(), other.nfvoJob.getJobId());
+ && (nfvoJob == null ? other.nfvoJob == null
+ : other.nfvoJob != null && Objects.equals(nfvoJob.getJobId(), other.nfvoJob.getJobId()));
}
return false;
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java
index e901e10596..e685781308 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java
@@ -184,13 +184,15 @@ public class NfvoNfInst {
final NfvoNfInst that = (NfvoNfInst) object;
return Objects.equals(nfInstId, that.nfInstId) && Objects.equals(name, that.name)
&& Objects.equals(vnfdId, that.vnfdId) && Objects.equals(packageId, that.packageId)
- && Objects.equals(nsInst, that.nsInst) && Objects.equals(status, that.status)
- && Objects.equals(createTime, that.createTime) && Objects.equals(lastUpdateTime, that.lastUpdateTime);
+ && (nsInst == null ? that.nsInst == null : that.nsInst != null && Objects.equals(nsInst, that.nsInst))
+ && Objects.equals(status, that.status) && Objects.equals(createTime, that.createTime)
+ && Objects.equals(lastUpdateTime, that.lastUpdateTime);
}
@Override
public int hashCode() {
- return Objects.hash(nfInstId, name, vnfdId, packageId, nsInst, status, createTime, lastUpdateTime);
+ return Objects.hash(nfInstId, name, vnfdId, packageId, nsInst != null ? nsInst.getNsInstId() : 0, status,
+ createTime, lastUpdateTime);
}
@Override
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java
index dd8448fe56..146e5512fc 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java
@@ -251,6 +251,10 @@ public class NfvoNsInst {
@Override
public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
if (obj instanceof NfvoNsInst) {
final NfvoNsInst other = (NfvoNsInst) obj;
return Objects.equals(nsInstId, other.nsInstId) && Objects.equals(name, other.name)
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java
index c47bbdbefb..7668ed272d 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java
@@ -193,24 +193,26 @@ public class NsLcmOpOcc {
}
@Override
- public boolean equals(final Object object) {
- if (this == object)
+ public boolean equals(final Object obj) {
+ if (this == obj)
return true;
- if (object == null || getClass() != object.getClass())
+ if (obj == null || getClass() != obj.getClass())
return false;
- final NsLcmOpOcc that = (NsLcmOpOcc) object;
+ final NsLcmOpOcc that = (NsLcmOpOcc) obj;
return Objects.equals(id, that.id) && Objects.equals(operationState, that.operationState)
&& Objects.equals(stateEnteredTime, that.stateEnteredTime) && Objects.equals(startTime, that.startTime)
- && Objects.equals(nfvoNsInst, that.nfvoNsInst) && Objects.equals(operation, that.operation)
- && Objects.equals(isAutoInnovation, that.isAutoInnovation)
+ && (nfvoNsInst == null ? that.nfvoNsInst == null
+ : that.nfvoNsInst != null && Objects.equals(nfvoNsInst, that.nfvoNsInst))
+ && Objects.equals(operation, that.operation) && Objects.equals(isAutoInnovation, that.isAutoInnovation)
&& Objects.equals(operationParams, that.operationParams)
&& Objects.equals(isCancelPending, that.isCancelPending);
}
@Override
public int hashCode() {
- return Objects.hash(id, operationState, stateEnteredTime, startTime, nfvoNsInst, operation, isAutoInnovation,
- operationParams, isCancelPending);
+ return Objects.hash(id, operationState, stateEnteredTime, startTime,
+ nfvoNsInst != null ? nfvoNsInst.getNsInstId() : 0, operation, isAutoInnovation, operationParams,
+ isCancelPending);
}
@Override
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java
index c55ef5728e..b84f95aa50 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java
@@ -39,10 +39,11 @@ public class Utils {
if (first == null) {
return second == null;
}
+
if (first.isEmpty()) {
return second.isEmpty();
}
- if (first.size() == second.size()) {
+ if ((first != null && second != null) && (first.size() == second.size())) {
for (int index = 0; index < first.size(); index++) {
if (!Objects.equals(first.get(index), second.get(index))) {
return false;
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java
index 1aaddebc5e..1487b630c7 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java
@@ -120,11 +120,6 @@ public class DatabaseServiceProvider {
return nfvoNfInstRepository.save(nfvoNfInst) != null;
}
- public Optional<NfvoNfInst> getNfvoNfInstByNfInstId(final String nfInstId) {
- logger.info("Querying database for NfvoNfInst using nfInstId: {}", nfInstId);
- return nfvoNfInstRepository.findByNfInstId(nfInstId);
- }
-
public List<NfvoNfInst> getNfvoNfInstByNsInstId(final String nsInstId) {
logger.info("Querying database for NfvoNfInst using nsInstId: {}", nsInstId);
return nfvoNfInstRepository.findByNsInstNsInstId(nsInstId);
@@ -160,5 +155,8 @@ public class DatabaseServiceProvider {
return nsLcmOpOccRepository.findById(id);
}
-
+ public void deleteNfvoNsInst(final String nsInstId) {
+ logger.info("Deleting NfvoNsInst with nsInstId: {}", nsInstId);
+ nfvoNsInstRepository.deleteById(nsInstId);
+ }
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java
index 8108749d48..8070036791 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java
@@ -133,7 +133,7 @@ public class DatabaseServiceProviderTest {
.status(State.NOT_INSTANTIATED).createTime(CURRENT_DATE_TIME).lastUpdateTime(CURRENT_DATE_TIME);
databaseServiceProvider.saveNfvoNfInst(nfInst);
- final Optional<NfvoNfInst> actual = databaseServiceProvider.getNfvoNfInstByNfInstId(nfInst.getNfInstId());
+ final Optional<NfvoNfInst> actual = databaseServiceProvider.getNfvoNfInst(nfInst.getNfInstId());
final NfvoNfInst actualNfvoNfInst = actual.get();
assertEquals(nsInst.getNsInstId(), actualNfvoNfInst.getNsInst().getNsInstId());
assertEquals(nfInst.getNfInstId(), actualNfvoNfInst.getNfInstId());
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/PojoClassesTests.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/PojoClassesTests.java
new file mode 100644
index 0000000000..5f033a2438
--- /dev/null
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/PojoClassesTests.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 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.so.etsi.nfvo.ns.lcm.database;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import org.junit.Test;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
+import org.onap.so.openpojo.rules.ToStringTester;
+import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+import nl.jqno.equalsverifier.EqualsVerifier;
+import nl.jqno.equalsverifier.Warning;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+public class PojoClassesTests {
+
+ @Test
+ public void test_database_beans() throws ClassNotFoundException {
+
+ final Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester())
+ .with(new ToStringTester()).build();
+ validator.validate(NfvoNsInst.class.getPackageName(), new FilterPackageInfo());
+ }
+
+ @Test
+ public void test_database_nfvoJob_equalAndHashMethod() throws ClassNotFoundException {
+ EqualsVerifier.forClass(NfvoJob.class)
+ .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
+ .withPrefabValues(NfvoJobStatus.class, new NfvoJobStatus().nfvoJob(new NfvoJob()),
+ new NfvoJobStatus().nfvoJob(new NfvoJob()))
+ .withIgnoredAnnotations(Entity.class, Id.class).verify();
+ }
+
+ @Test
+ public void test_database_nfvoJobStatus_equalAndHashMethod() throws ClassNotFoundException {
+ EqualsVerifier.forClass(NfvoJobStatus.class)
+ .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
+ .withPrefabValues(NfvoJob.class, new NfvoJob(), new NfvoJob())
+ .withIgnoredAnnotations(Entity.class, Id.class).verify();
+ }
+
+ @Test
+ public void test_database_nfvoNsInst_equalAndHashMethod() throws ClassNotFoundException {
+ EqualsVerifier.forClass(NfvoNsInst.class)
+ .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
+ .withPrefabValues(NfvoNfInst.class, new NfvoNfInst(), new NfvoNfInst())
+ .withPrefabValues(NsLcmOpOcc.class, new NsLcmOpOcc(), new NsLcmOpOcc())
+ .withIgnoredAnnotations(Entity.class, Id.class).verify();
+ }
+
+ @Test
+ public void test_database_nfvoNfInst_equalAndHashMethod() throws ClassNotFoundException {
+ EqualsVerifier.forClass(NfvoNfInst.class)
+ .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
+ .withPrefabValues(NfvoNsInst.class, new NfvoNsInst(), new NfvoNsInst())
+ .withIgnoredAnnotations(Entity.class, Id.class).verify();
+ }
+
+ @Test
+ public void test_database_nsLcmOpOcc_equalAndHashMethod() throws ClassNotFoundException {
+ EqualsVerifier.forClass(NsLcmOpOcc.class)
+ .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
+ .withPrefabValues(NfvoNsInst.class, new NfvoNsInst(), new NfvoNsInst())
+ .withIgnoredAnnotations(Entity.class, Id.class).verify();
+ }
+}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/lifecycle/NsLifeCycleManager.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/lifecycle/NsLifeCycleManager.java
index 2ebf55ff7f..ae9f55e1c5 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/lifecycle/NsLifeCycleManager.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/lifecycle/NsLifeCycleManager.java
@@ -82,4 +82,9 @@ public class NsLifeCycleManager {
return etsiSoNsLcmManagerUrlProvider.getNsLcmOpOccUri(nsLcmOpOccId);
}
+
+ public void deleteNs(final String nsInstanceId) {
+ logger.info("Will execute Delete Ns for nsInstanceId: {}", nsInstanceId);
+ jobExecutorService.runDeleteNsJob(nsInstanceId);
+ }
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java
index cfda89f3f0..78ab9e96cc 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java
@@ -35,7 +35,6 @@ import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance;
import org.onap.so.etsi.nfvo.ns.lcm.model.TerminateNsRequest;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
@@ -109,7 +108,9 @@ public class NsLifecycleManagementController {
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> deleteNs(@PathVariable("nsInstanceId") final String nsInstanceId) {
logger.debug("Received delete NS request for nsInstanceId: {}", nsInstanceId);
- return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body("Operation is not supported yet");
+ nsLifeCycleManager.deleteNs(nsInstanceId);
+ logger.info("Successfully deleted NS for nsInstanceId: {}", nsInstanceId);
+ return ResponseEntity.noContent().build();
}
/**
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java
index 4b1195244c..585b0e1811 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java
@@ -19,17 +19,14 @@
*/
package org.onap.so.etsi.nfvo.ns.lcm.rest;
-/**
- * @author Waqas Ikram (waqas.ikram@est.tech)
- *
- */
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
import java.net.URISyntaxException;
-import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
import org.junit.Before;
@@ -173,11 +170,30 @@ public class NsLifecycleManagementControllerTest {
}
@Test
- public void testCreateNs_ValidDeleteNsRequest() {
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + UUID.randomUUID().toString();
+ public void testDeleteNs_SuccessfulCase() {
+ final String nsInstId = UUID.randomUUID().toString();
+ doNothing().when(mockedJobExecutorService).runDeleteNsJob(eq(nsInstId));
+
+ final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + nsInstId;
final ResponseEntity<Void> responseEntity =
testRestTemplate.exchange(baseUrl, HttpMethod.DELETE, null, Void.class);
- assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
+ assertEquals(HttpStatus.NO_CONTENT, responseEntity.getStatusCode());
+ }
+
+ @Test
+ public void testDeleteNs_nsRequestProcessingExceptionThrown_returnInlineResponse400() {
+ final String nsInstId = UUID.randomUUID().toString();
+ final String message = "Unable to process request";
+ doThrow(new NsRequestProcessingException(message, new InlineResponse400().detail(message)))
+ .when(mockedJobExecutorService).runDeleteNsJob(eq(nsInstId));
+
+ final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + nsInstId;
+ final ResponseEntity<InlineResponse400> responseEntity =
+ testRestTemplate.exchange(baseUrl, HttpMethod.DELETE, null, InlineResponse400.class);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode());
+ assertTrue(responseEntity.hasBody());
+ assertNotNull(responseEntity.getBody());
}
@Test
diff --git a/version.properties b/version.properties
index f56901fc20..e783874dbf 100644
--- a/version.properties
+++ b/version.properties
@@ -4,7 +4,7 @@
major=1
minor=7
-patch=2
+patch=3
base_version=${major}.${minor}.${patch}