From 63842b9394eaf8eefc227024fc5ecba62dfea3d5 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Tue, 18 Jun 2019 17:58:42 +0000 Subject: VNFM adapter handle getOperation after VNF delete Change-Id: Iaa8d792f5660b1caf16d081779c14799d827a544 Issue-ID: SO-2030 Signed-off-by: MichaelMorris --- .../vnfmadapter/jobmanagement/JobManager.java | 64 +++++++++++++++------- .../vnfmadapter/jobmanagement/VnfmOperation.java | 18 ++++++ .../notificationhandling/NotificationHandler.java | 1 + 3 files changed, 62 insertions(+), 21 deletions(-) (limited to 'adapters/mso-vnfm-adapter') diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java index b3552c780e..537bb77b32 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java @@ -84,42 +84,53 @@ public class JobManager { throw new JobNotFoundException("No job found with ID: " + jobId); } - final Optional operationOptional = - vnfmServiceProvider.getOperation(vnfmOperation.getVnfmId(), vnfmOperation.getOperationId()); - if (!operationOptional.isPresent()) { - return response.operationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.OPERATION_NOT_FOUND); + if (vnfmOperation.isVnfDeleted()) { + response.setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND); + return response.operationState(getOperationState(vnfmOperation, null)); } - final InlineResponse200 operation = operationOptional.get(); - logger.debug("Job Id: " + jobId + ", operationId: " + operation.getId() + ", operation details: " + operation); + try { + final Optional operationOptional = + vnfmServiceProvider.getOperation(vnfmOperation.getVnfmId(), vnfmOperation.getOperationId()); - if (operation.getOperationState() == null) { - return response.operationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS); - } + if (!operationOptional.isPresent()) { + return response.operationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.OPERATION_NOT_FOUND); + } + final InlineResponse200 operation = operationOptional.get(); + + logger.debug( + "Job Id: " + jobId + ", operationId: " + operation.getId() + ", operation details: " + operation); + + if (operation.getOperationState() == null) { + return response.operationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS); + } - response.setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND); - response.setId(operation.getId()); - response.setOperation(OperationEnum.fromValue(operation.getOperation().getValue())); - response.setOperationState(getOperationState(vnfmOperation, operation)); - response.setStartTime(operation.getStartTime()); - response.setStateEnteredTime(operation.getStateEnteredTime()); - response.setVnfInstanceId(operation.getVnfInstanceId()); + response.setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND); + response.setId(operation.getId()); + response.setOperation(OperationEnum.fromValue(operation.getOperation().getValue())); + response.setOperationState(getOperationState(vnfmOperation, operation)); + response.setStartTime(operation.getStartTime()); + response.setStateEnteredTime(operation.getStateEnteredTime()); + response.setVnfInstanceId(operation.getVnfInstanceId()); - return response; + return response; + } catch (final Exception exception) { + logger.error("Exception encountered trying to get operation status for operation id " + + vnfmOperation.getOperationId(), exception); + return response.operationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS); + } } private OperationStateEnum getOperationState(final VnfmOperation vnfmOperation, final InlineResponse200 operationResponse) { - final OperationStateEnum operationState = - OperationStateEnum.fromValue(operationResponse.getOperationState().getValue()); switch (vnfmOperation.getNotificationStatus()) { case NOTIFICATION_PROCESSING_NOT_REQUIRED: default: - return operationState; + return OperationStateEnum.fromValue(operationResponse.getOperationState().getValue()); case NOTIFICATION_PROCESSING_PENDING: return org.onap.vnfmadapter.v1.model.OperationStateEnum.PROCESSING; case NOTIFICATION_PROCEESING_SUCCESSFUL: - return operationState; + return org.onap.vnfmadapter.v1.model.OperationStateEnum.COMPLETED; case NOTIFICATION_PROCESSING_FAILED: return org.onap.vnfmadapter.v1.model.OperationStateEnum.FAILED; } @@ -138,4 +149,15 @@ public class JobManager { } } + public void vnfDeleted(final String operationId) { + logger.debug("VNF deleyed for operation ID {}", operationId); + final java.util.Optional relatedOperation = mapOfJobIdToVnfmOperation.values().stream() + .filter(operation -> operation.getOperationId().equals(operationId)).findFirst(); + if (relatedOperation.isPresent()) { + relatedOperation.get().setVnfDeleted();; + } else { + logger.debug("No operation found for operation ID " + operationId); + } + } + } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java index 7ce08df52f..3bfe48af12 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java @@ -28,6 +28,7 @@ public class VnfmOperation { private final String vnfmId; private final String operationId; private NotificationStatus notificationStatus; + private boolean vnfDeleted; public VnfmOperation(final String vnfmId, final String operationId, final boolean waitForNotificationForSuccess) { this.vnfmId = vnfmId; @@ -75,6 +76,23 @@ public class VnfmOperation { return notificationStatus; } + /** + * Set the VNF has been deleted from the VNFM. + */ + public void setVnfDeleted() { + this.vnfDeleted = true; + } + + /** + * Check if the VNF has been deleted from the VNFM + * + * @return true of the VNF has been deleted from the VNFM, false otherwise + */ + public boolean isVnfDeleted() { + return vnfDeleted; + } + + public enum NotificationStatus { /** * No notification handling is required to determine the status of the operation diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java index c09aa0cd48..93c7ea91ff 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java @@ -161,6 +161,7 @@ public class NotificationHandler implements Runnable { } finally { jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId(), deleteSuccessful); + jobManager.vnfDeleted(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId()); genericVnf.setOrchestrationStatus("Assigned"); genericVnf.setSelflink(""); aaiServiceProvider.invokePutGenericVnf(genericVnf); -- cgit 1.2.3-korg