use of org.onap.aai.domain.yang.OperationalEnvironment in project so by onap.
the class ActivateVnfStatusOperationalEnvironment method getAAIOperationalEnvironment.
/**
* 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;
}
use of org.onap.aai.domain.yang.OperationalEnvironment in project so by onap.
the class ActivateVnfStatusOperationalEnvironment method execute.
/**
* The Point-Of-Entry from APIH with activate status from SDC
*
* @param requestId - String
* @param request - CloudOrchestrationRequest - object
* @return void - nothing
*/
public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException {
try {
String operationalEnvironmentId = "";
String sdcDistributionId = request.getDistributionId();
Distribution sdcStatus = request.getDistribution();
// Distribution, Query for operationalEnvironmentId, serviceModelVersionId, origRequestId
this.queryDistributionDbResponse = client.getDistributionStatusById(sdcDistributionId);
operationalEnvironmentId = this.queryDistributionDbResponse.getOperationalEnvId();
this.origRequestId = this.queryDistributionDbResponse.getRequestId();
// ServiceModel, Query for recoveryAction, retryCountString
this.queryServiceModelResponse = client.findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId(operationalEnvironmentId, queryDistributionDbResponse.getServiceModelVersionId(), this.origRequestId);
processActivateSDCStatus(sdcDistributionId, sdcStatus, this.queryDistributionDbResponse, this.queryServiceModelResponse);
// After EVERY status processed, need to query the status of all service modelId
// to determine the OVERALL status if "COMPLETE" or "FAILURE":
checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId);
// Update AAI to ACTIVE if Overall success
if (isOverallSuccess) {
String vnfOperationalEnvironmentId = this.queryServiceModelResponse.getVnfOperationalEnvId();
OperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(vnfOperationalEnvironmentId);
if (aaiOpEnv != null) {
aaiOpEnv.setOperationalEnvironmentStatus("ACTIVE");
aaiHelper.updateAaiOperationalEnvironment(vnfOperationalEnvironmentId, aaiOpEnv);
} else {
requestDb.updateInfraFailureCompletion("Unable to update ACTIVATE status in AAI. ", this.origRequestId, this.queryServiceModelResponse.getVnfOperationalEnvId());
}
}
} catch (Exception e) {
logger.error("Exception in execute", e);
requestDb.updateInfraFailureCompletion(e.getMessage(), this.origRequestId, this.queryServiceModelResponse.getVnfOperationalEnvId());
}
}
use of org.onap.aai.domain.yang.OperationalEnvironment in project so by onap.
the class ActivateVnfOperationalEnvironment method execute.
/**
* The Point-Of-Entry from APIH with VID request to send activate request
*
* @param requestId - String
* @param request - CloudOrchestrationRequest object
* @return void - nothing
*/
public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException {
String vnfOperationalEnvironmentId = request.getOperationalEnvironmentId();
String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext();
List<ServiceModelList> serviceModelVersionIdList = request.getRequestDetails().getRequestParameters().getManifest().getServiceModelList();
String ecompOperationalEnvironmentId = null;
AAIResultWrapper wrapper = getAAIOperationalEnvironment(vnfOperationalEnvironmentId);
Optional<Relationships> optRelationships = wrapper.getRelationships();
if (optRelationships.isPresent()) {
Relationships relationships = optRelationships.get();
List<AAIResourceUri> operationalEnvironments = relationships.getRelatedUris(Types.OPERATIONAL_ENVIRONMENT);
if (!operationalEnvironments.isEmpty()) {
ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get(AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT.getUriParams().operationalEnvironmentId);
}
}
logger.debug(" vnfOperationalEnvironmentId : {}", vnfOperationalEnvironmentId);
logger.debug(" ecompOperationalEnvironmentId : {}", ecompOperationalEnvironmentId);
OperationalEnvironment operationalEnv = wrapper.asBean(OperationalEnvironment.class).get();
String workloadContext = operationalEnv.getWorkloadContext();
logger.debug(" aai workloadContext: {}", workloadContext);
if (!vidWorkloadContext.equals(workloadContext)) {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcessError).build();
throw new ValidateException.Builder(" The vid workloadContext did not match from aai record. " + " vid workloadContext:" + vidWorkloadContext + " aai workloadContext:" + workloadContext, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
}
if (ecompOperationalEnvironmentId == null) {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcessError).build();
throw new ValidateException.Builder(" The ECOMP OE was not in aai record; the value of relationship.relationship-data key: " + AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT.getUriParams().operationalEnvironmentId, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
}
processActivateSDCRequest(requestId, ecompOperationalEnvironmentId, serviceModelVersionIdList, workloadContext, vnfOperationalEnvironmentId);
}
use of org.onap.aai.domain.yang.OperationalEnvironment in project so by onap.
the class DeactivateVnfOperationalEnvironment method getAAIOperationalEnvironment.
private OperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) {
AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId);
Optional<OperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(OperationalEnvironment.class);
return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null;
}
use of org.onap.aai.domain.yang.OperationalEnvironment in project so by onap.
the class ActivateVnfOperationalEnvironmentTest method getAAIOperationalEnvironmentTest.
@Test
public void getAAIOperationalEnvironmentTest() {
OperationalEnvironment aaiOpEnv;
wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironmentWithRelationship.json").withStatus(HttpStatus.SC_ACCEPTED)));
AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001");
aaiOpEnv = wrapper.asBean(OperationalEnvironment.class).get();
assertEquals("EMOE-001", aaiOpEnv.getOperationalEnvironmentId());
assertEquals("1dfe7154-eae0-44f2-8e7a-8e5e7882e55d", aaiOpEnv.getRelationshipList().getRelationship().get(0).getRelationshipData().get(0).getRelationshipValue());
assertNotNull(activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId));
assertEquals("EMOE-001", activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId).asBean(OperationalEnvironment.class).get().getOperationalEnvironmentId());
}
Aggregations