aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java/org
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-03-14 21:06:49 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-03-14 21:07:03 -0400
commit1414f938b6fb86e6a15f3dfb9080f90f5d78b292 (patch)
tree424df33630c5bfc3c99898fc6af3500035be9365 /mso-api-handlers/mso-api-handler-infra/src/main/java/org
parent1e22f36f9d682875754c927506d1d299389260eb (diff)
Saved vnfOperationalEnvironmentId to be used later
Removed unnecessary lines in junit test class. Saved vnfOperationalEnvironmentId to the model table to be used for AAI status update call later. Change-Id: I812d21d483d716bb5135c408369a160e4600efc2 Issue-ID: SO-1662 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java34
3 files changed, 39 insertions, 6 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java
index eb0721270d..de1d9e9cfb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java
@@ -50,7 +50,8 @@ public class ActivateVnfDBHelper {
String status,
String recoveryAction,
int retryCount,
- String workloadContext) {
+ String workloadContext,
+ String vnfOperationalEnvironmentId) {
OperationalEnvServiceModelStatus serviceModelStatus = new OperationalEnvServiceModelStatus();
serviceModelStatus.setRequestId(requestId);
serviceModelStatus.setOperationalEnvId(operationalEnvironmentId);
@@ -59,6 +60,7 @@ public class ActivateVnfDBHelper {
serviceModelStatus.setRecoveryAction(recoveryAction);
serviceModelStatus.setRetryCount(new Integer(retryCount));
serviceModelStatus.setWorkloadContext(workloadContext);
+ serviceModelStatus.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
return serviceModelStatus;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
index f70fe71554..554aafc73b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
@@ -119,7 +119,7 @@ public class ActivateVnfOperationalEnvironment {
HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
}
- processActivateSDCRequest(requestId, ecompOperationalEnvironmentId, serviceModelVersionIdList, workloadContext);
+ processActivateSDCRequest(requestId, ecompOperationalEnvironmentId, serviceModelVersionIdList, workloadContext, vnfOperationalEnvironmentId);
}
@@ -134,7 +134,7 @@ public class ActivateVnfOperationalEnvironment {
*/
public void processActivateSDCRequest(String requestId, String operationalEnvironmentId,
List<ServiceModelList> serviceModelVersionIdList,
- String workloadContext) throws ApiException {
+ String workloadContext, String vnfOperationalEnvironmentId) throws ApiException {
JSONObject jsonResponse = null;
int retryCount = 0;
@@ -157,7 +157,8 @@ public class ActivateVnfOperationalEnvironment {
DISTRIBUTION_STATUS_SENT,
recoveryAction,
retryCount,
- workloadContext);
+ workloadContext,
+ vnfOperationalEnvironmentId);
client.save(serviceModelStatus);
String distributionId = "";
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
index 352bf8fb0b..c12828aeb3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
@@ -24,21 +24,25 @@ package org.onap.so.apihandlerinfra.tenantisolation.process;
import java.util.List;
+import java.util.Optional;
import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
import org.json.JSONObject;
+import org.onap.aai.domain.yang.OperationalEnvironment;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.SDCClientHelper;
import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution;
import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
import org.onap.so.logger.MessageEnum;
@@ -57,7 +61,8 @@ public class ActivateVnfStatusOperationalEnvironment {
private String errorMessage = "";
private OperationalEnvDistributionStatus queryDistributionDbResponse = null;
private OperationalEnvServiceModelStatus queryServiceModelResponse = null;
-
+ private boolean isOverallSuccess = false;
+
private final int RETRY_COUNT_ZERO = 0;
private final String ERROR_REASON_ABORTED = "ABORTED";
private final String RECOVERY_ACTION_RETRY = "RETRY";
@@ -77,6 +82,8 @@ public class ActivateVnfStatusOperationalEnvironment {
private SDCClientHelper sdcClientHelper;
@Autowired
private RequestsDbClient client;
+ @Autowired
+ private AAIClientHelper aaiHelper;
/**
* The Point-Of-Entry from APIH with activate status from SDC
@@ -107,8 +114,19 @@ public class ActivateVnfStatusOperationalEnvironment {
// to determine the OVERALL status if "COMPLETE" or "FAILURE":
checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId);
+ // Update AAI to ACTIVE if Overall success
+ if (isOverallSuccess) {
+ OperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(this.queryServiceModelResponse.getVnfOperationalEnvId());
+ if (aaiOpEnv != null) {
+ aaiOpEnv.setOperationalEnvironmentStatus("ACTIVE");
+ aaiHelper.updateAaiOperationalEnvironment(operationalEnvironmentId, aaiOpEnv);
+ }else {
+ requestDb.updateInfraFailureCompletion("Unable to update ACTIVATE status in AAI. ", this.origRequestId, this.queryServiceModelResponse.getVnfOperationalEnvId());
+ }
+ }
+
} catch(Exception e) {
- requestDb.updateInfraFailureCompletion(e.getMessage(), this.origRequestId, this.queryDistributionDbResponse.getOperationalEnvId());
+ requestDb.updateInfraFailureCompletion(e.getMessage(), this.origRequestId, this.queryServiceModelResponse.getVnfOperationalEnvId());
}
}
@@ -280,6 +298,7 @@ public class ActivateVnfStatusOperationalEnvironment {
if (status.equals("Completed") && queryServiceModelResponseList.size() == count) {
String messageStatus = "Overall Activation process is complete. " + status;
+ isOverallSuccess = true;
requestDb.updateInfraSuccessCompletion(messageStatus, origRequestId, operationalEnvironmentId);
} else {
if (status.equals("Failure") && queryServiceModelResponseList.size() == count) {
@@ -293,4 +312,15 @@ public class ActivateVnfStatusOperationalEnvironment {
}
}
+
+ /**
+ * Get OperationalEnvironment object
+ * @param operationalEnvironmentId - String
+ * @return operationalEnv - OperationalEnvironment object
+ */
+ private OperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) {
+ AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId);
+ Optional<OperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(OperationalEnvironment.class);
+ return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null;
+ }
}