aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java30
-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.java51
-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/CreateInstantiateVnfTask.java15
-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/TerminateVnfTask.java11
-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/repository/NSLcmOpOccRepository.java11
-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/repository/NfvoNfInstRepository.java12
-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/repository/NfvoNsInstRepository.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/service/DatabaseServiceProvider.java23
10 files changed, 111 insertions, 53 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java
index 6b7ceedbb8..5196ffffda 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java
@@ -276,7 +276,7 @@ public class StackService extends ExternalTaskUtils {
networkAdapterImpl.createNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
req.getModelCustomizationUuid(), req.getNetworkName(), physicalNetworkName, vlans, routeTargets, shared,
external, req.getFailIfExists(), false, req.getSubnets(), fqdns, routeTable, req.getMsoRequest(),
- networkId, neutronNetworkId, networkFqdn, subnetIdMap, networkRollback, false);
+ networkId, neutronNetworkId, networkFqdn, subnetIdMap, networkRollback, true);
success.setTrue();
backout.setValue(req.getBackout());
canonicalStackId.value = networkRollback.value.getNetworkStackId();
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 6a62a5de61..45b29244d1 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
@@ -245,7 +245,7 @@ public class HeatBridgeImpl implements HeatBridgeApi {
@Override
public List<org.openstack4j.model.compute.Image> extractOpenstackImagesFromServers(final List<Server> servers) {
Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT);
- return servers.stream().map(Server::getImage)
+ return servers.stream().filter(s -> s.getImage() != null).map(Server::getImage)
.filter(distinctByProperty(org.openstack4j.model.compute.Image::getId)).collect(Collectors.toList());
}
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 531496cc8f..ebc7c3a81e 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
@@ -102,6 +102,8 @@ import org.openstack4j.model.network.Port;
import org.openstack4j.model.network.Subnet;
import org.openstack4j.openstack.heat.domain.HeatResource;
import org.openstack4j.openstack.heat.domain.HeatResource.Resources;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -118,6 +120,8 @@ public class HeatBridgeImplTest {
private static final String TENANT_ID = "7320ec4a5b9d4589ba7c4412ccfd290f";
private static final ObjectMapper MAPPER = new ObjectMapper();
+ private static Logger logger = LoggerFactory.getLogger(HeatBridgeImplTest.class);
+
@Mock
private OpenstackClient osClient;
@@ -139,6 +143,12 @@ public class HeatBridgeImplTest {
private Server server;
@Mock
+ private Server server2;
+
+ @Mock
+ private Image image;
+
+ @Mock
private AAIDSLQueryClient dSLQueryClient;
@Spy
@@ -626,6 +636,25 @@ public class HeatBridgeImplTest {
verify(osClient, times(5)).getNetworkById(anyString());
}
+
+ @Test
+ public void testExtractOpenstackImagesFromServers() throws HeatBridgeException {
+ // Arrange
+ List<Server> serverList = new ArrayList<>();
+ serverList.add(server);
+ serverList.add(server2);
+ when(server.getImage()).thenReturn(null);
+ when(server.getImage()).thenReturn(image);
+ when(image.getId()).thenReturn("imageId");
+ // Act
+
+ List<Image> images = heatbridge.extractOpenstackImagesFromServers(serverList);
+
+
+ // Assert
+ assertEquals(1, images.size());
+ }
+
private List<? extends Resource> extractTestStackResources() {
List<HeatResource> stackResources = null;
try {
@@ -638,6 +667,7 @@ public class HeatBridgeImplTest {
return stackResources;
}
+
private String readTestResourceFile(String filePath) {
String content = null;
String pathname = Objects.requireNonNull(getClass().getClassLoader().getResource(filePath)).getFile();
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 e94b3de81e..a785a5199b 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,9 +19,9 @@
*/
package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
-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.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.OCC_ID_PARAM_NAME;
import java.time.LocalDateTime;
import java.util.Optional;
@@ -31,7 +31,6 @@ import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum;
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.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;
@@ -109,21 +108,8 @@ public abstract class AbstractNetworkServiceTask {
public void updateNsLcmOpOccStatusToCompleted(final DelegateExecution execution) {
logger.info("Executing updateNsLcmOpOccStatusToCompleted ...");
- final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME);
- final Optional<NsLcmOpOcc> optional = databaseServiceProvider.getNsLcmOpOcc(occId);
-
- if (optional.isEmpty()) {
- final String message = "Unable to find record for NSLcmOpOcc in database using id: " + occId;
- logger.error(message);
- abortOperation(execution, message);
- }
-
- final NsLcmOpOcc nsLcmOpOcc = optional.get();
- final OperationStateEnum operationStateCompleted = OperationStateEnum.COMPLETED;
- logger.info("Setting operation state to {} for id: {}", operationStateCompleted, occId);
- nsLcmOpOcc.setOperationState(operationStateCompleted);
- databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc);
+ updateNsLcmOpOccOperationState(execution, OperationStateEnum.COMPLETED);
logger.info("Finished executing updateNsLcmOpOccStatusToCompleted ...");
@@ -131,20 +117,8 @@ public abstract class AbstractNetworkServiceTask {
public void updateNsLcmOpOccStatusToFailed(final DelegateExecution execution) {
logger.info("Executing updateNsLcmOpOccStatusToFailed ...");
- final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME);
-
- final Optional<NsLcmOpOcc> optional = databaseServiceProvider.getNsLcmOpOcc(occId);
- if (optional.isPresent()) {
- final NsLcmOpOcc nsLcmOpOcc = optional.get();
- final OperationStateEnum operationStateFailed = OperationStateEnum.FAILED;
- logger.info("Setting operation state to {} for id: {}", operationStateFailed, occId);
- nsLcmOpOcc.setOperationState(operationStateFailed);
-
- databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc);
- } else {
- logger.error("Unable to find record for NSLcmOpOcc in database using id: {}", occId);
- }
+ updateNsLcmOpOccOperationState(execution, OperationStateEnum.FAILED);
logger.info("Finished executing updateNsLcmOpOccStatusToFailed ...");
@@ -154,6 +128,19 @@ public abstract class AbstractNetworkServiceTask {
abortOperation(execution, message, new InlineResponse400().detail(message));
}
+ private void updateNsLcmOpOccOperationState(final DelegateExecution execution,
+ final OperationStateEnum operationState) {
+ final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME);
+
+ final boolean isSuccessful = databaseServiceProvider.updateNsLcmOpOccOperationState(occId, operationState);
+ if (!isSuccessful) {
+ final String message =
+ "Unable to update NsLcmOpOcc " + occId + " operationState to" + operationState + " in database";
+ logger.error(message);
+ abortOperation(execution, message);
+ }
+ }
+
protected void abortOperation(final DelegateExecution execution, final String message,
final InlineResponse400 problemDetails) {
logger.error(message);
@@ -175,10 +162,10 @@ public abstract class AbstractNetworkServiceTask {
}
protected void updateNsInstanceStatus(final DelegateExecution execution, final State nsStatus) {
- final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution);
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+
logger.info("Updating NfvoNsInst Status to {} and saving to DB", nsStatus);
- nfvoNsInst.setStatus(nsStatus);
- databaseServiceProvider.saveNfvoNsInst(nfvoNsInst);
+ databaseServiceProvider.updateNsInstState(nsInstId, nsStatus);
}
protected NfvoNsInst getNfvoNsInst(final DelegateExecution execution) {
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/CreateInstantiateVnfTask.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/CreateInstantiateVnfTask.java
index 600792acc0..0d4cbbe24f 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/CreateInstantiateVnfTask.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/CreateInstantiateVnfTask.java
@@ -195,7 +195,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask {
}
public void updateNfInstanceStatusToFailed(final DelegateExecution execution) {
- logger.info("Executing updateNfInstanceStatusToActive");
+ logger.info("Executing updateNfInstanceStatusToFailed");
updateNfInstanceStatus(execution, State.FAILED);
final CreateInstantiateRequest request =
@@ -203,22 +203,19 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask {
addJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName()
+ " will set status to " + State.FAILED);
- logger.info("Finished executing updateNfInstanceStatusToInstantiated ...");
+ logger.info("Finished executing updateNfInstanceStatusToFailed ...");
}
private void updateNfInstanceStatus(final DelegateExecution execution, final State vnfStatus) {
final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME);
- final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(nfInstId);
- if (optional.isEmpty()) {
- final String message = "Unable to find NfvoNfInst record in database using nfInstId: " + nfInstId;
+ final boolean isSuccessful = databaseServiceProvider.updateNfInstState(nfInstId, vnfStatus);
+ if (!isSuccessful) {
+ final String message =
+ "Unable to update NfvoNfInst " + nfInstId + " status to" + vnfStatus + " in database";
logger.error(message);
abortOperation(execution, message);
}
-
- final NfvoNfInst nfvoNfInst = optional.get();
- nfvoNfInst.setStatus(vnfStatus);
- databaseServiceProvider.saveNfvoNfInst(nfvoNfInst);
}
}
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/TerminateVnfTask.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/TerminateVnfTask.java
index 049a6f38b0..f3e7eea212 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/TerminateVnfTask.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/TerminateVnfTask.java
@@ -31,7 +31,6 @@ import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse;
import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider;
import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterServiceProvider;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum;
-import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
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;
@@ -170,16 +169,12 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask {
private void updateNfInstanceStatus(final DelegateExecution execution, final State vnfStatus) {
final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME);
- final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(vnfId);
- if (optional.isEmpty()) {
- final String message = "Unable to find NfvoNfInst record in database using vnfId: " + vnfId;
+ final boolean isSuccessful = databaseServiceProvider.updateNfInstState(vnfId, vnfStatus);
+ if (!isSuccessful) {
+ final String message = "Unable to update NfvoNfInst " + vnfId + " status to" + vnfStatus + " in database";
logger.error(message);
abortOperation(execution, message);
}
-
- final NfvoNfInst nfvoNfInst = optional.get();
- nfvoNfInst.setStatus(vnfStatus);
- databaseServiceProvider.saveNfvoNfInst(nfvoNfInst);
}
}
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/repository/NSLcmOpOccRepository.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/repository/NSLcmOpOccRepository.java
index 696c7be5dd..d52dcd6192 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/repository/NSLcmOpOccRepository.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/repository/NSLcmOpOccRepository.java
@@ -19,9 +19,13 @@
*/
package org.onap.so.etsi.nfvo.ns.lcm.database.repository;
+import java.util.Optional;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
-import java.util.Optional;
+import org.springframework.data.repository.query.Param;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -30,4 +34,9 @@ import java.util.Optional;
public interface NSLcmOpOccRepository extends CrudRepository<NsLcmOpOcc, String> {
Optional<NsLcmOpOcc> findById(final String id);
+
+ @Modifying(clearAutomatically = true)
+ @Query("UPDATE NsLcmOpOcc SET operationState = (:operationState) WHERE id = (:id)")
+ int updateNsLcmOpOccOperationState(@Param("id") final String id,
+ @Param("operationState") final OperationStateEnum operationState);
}
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/repository/NfvoNfInstRepository.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/repository/NfvoNfInstRepository.java
index de14d43de4..5560ea7af3 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/repository/NfvoNfInstRepository.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/repository/NfvoNfInstRepository.java
@@ -22,7 +22,11 @@ package org.onap.so.etsi.nfvo.ns.lcm.database.repository;
import java.util.List;
import java.util.Optional;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.query.Param;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -35,4 +39,12 @@ public interface NfvoNfInstRepository extends CrudRepository<NfvoNfInst, String>
List<NfvoNfInst> findByNsInstNsInstId(final String nsInstId);
List<NfvoNfInst> findByNsInstNsInstIdAndName(final String nsInstId, final String name);
+
+ @Modifying(clearAutomatically = true)
+ @Query("UPDATE NfvoNfInst SET status = (:state) WHERE nfInstId = (:nfInstId)")
+ int updateNfInstState(@Param("nfInstId") final String nfInstId, @Param("state") final State state);
+
+ @Modifying(clearAutomatically = true)
+ @Query("DELETE FROM NfvoNfInst WHERE nfInstId = (:nfInstId)")
+ void deleteNfvoNfInstUsingNfInstId(@Param("nfInstId") final String nfInstId);
}
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/repository/NfvoNsInstRepository.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/repository/NfvoNsInstRepository.java
index beeeacf8cf..2a6abda558 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/repository/NfvoNsInstRepository.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/repository/NfvoNsInstRepository.java
@@ -21,7 +21,11 @@ package org.onap.so.etsi.nfvo.ns.lcm.database.repository;
import java.util.Optional;
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.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.query.Param;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -35,5 +39,8 @@ public interface NfvoNsInstRepository extends CrudRepository<NfvoNsInst, String>
boolean existsNfvoNsInstByName(final String name);
+ @Modifying(clearAutomatically = true)
+ @Query("UPDATE NfvoNsInst SET status = (:state) WHERE nsInstId = (:nsInstId)")
+ int updateNsInstState(@Param("nsInstId") final String nsInstId, @Param("state") final State state);
}
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 1487b630c7..58ca76eec9 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
@@ -25,6 +25,8 @@ import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
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.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.repository.NSLcmOpOccRepository;
import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoJobRepository;
import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoNfInstRepository;
@@ -105,6 +107,12 @@ public class DatabaseServiceProvider {
return nfvoNsInstRepository.save(nfvoNsInst) != null;
}
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public boolean updateNsInstState(final String nsInstId, final State state) {
+ logger.info("Updating NfvoNsInst: {} State to {}", nsInstId, state);
+ return nfvoNsInstRepository.updateNsInstState(nsInstId, state) > 0;
+ }
+
public Optional<NfvoNsInst> getNfvoNsInst(final String nsInstId) {
logger.info("Querying database for NfvoNsInst using nsInstId: {}", nsInstId);
return nfvoNsInstRepository.findById(nsInstId);
@@ -120,6 +128,12 @@ public class DatabaseServiceProvider {
return nfvoNfInstRepository.save(nfvoNfInst) != null;
}
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public boolean updateNfInstState(final String nfInstId, final State state) {
+ logger.info("Updating NfvoNfInst: {} State to {}", nfInstId, state);
+ return nfvoNfInstRepository.updateNfInstState(nfInstId, state) > 0;
+ }
+
public List<NfvoNfInst> getNfvoNfInstByNsInstId(final String nsInstId) {
logger.info("Querying database for NfvoNfInst using nsInstId: {}", nsInstId);
return nfvoNfInstRepository.findByNsInstNsInstId(nsInstId);
@@ -140,9 +154,10 @@ public class DatabaseServiceProvider {
return nfvoNfInstRepository.findByNfInstId(nfInstId).isPresent();
}
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
public void deleteNfvoNfInst(final String nfInstId) {
logger.info("Deleting NfvoNfInst with nfInstId: {} from database", nfInstId);
- nfvoNfInstRepository.deleteById(nfInstId);
+ nfvoNfInstRepository.deleteNfvoNfInstUsingNfInstId(nfInstId);
}
public boolean addNSLcmOpOcc(final NsLcmOpOcc nsLcmOpOcc) {
@@ -150,6 +165,12 @@ public class DatabaseServiceProvider {
return nsLcmOpOccRepository.save(nsLcmOpOcc) != null;
}
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public boolean updateNsLcmOpOccOperationState(final String id, final OperationStateEnum operationState) {
+ logger.info("Updating NsLcmOpOcc: {} operationState to {}", id, operationState);
+ return nsLcmOpOccRepository.updateNsLcmOpOccOperationState(id, operationState) > 0;
+ }
+
public Optional<NsLcmOpOcc> getNsLcmOpOcc(final String id) {
logger.info("Querying database for NsLcmOpOcc using id: {}", id);
return nsLcmOpOccRepository.findById(id);