Search in sources :

Example 1 with OperationalEnvironment

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;
}
Also used : AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment)

Example 2 with OperationalEnvironment

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());
    }
}
Also used : Distribution(org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution) ApiException(org.onap.so.apihandlerinfra.exceptions.ApiException) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment)

Example 3 with OperationalEnvironment

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);
}
Also used : ServiceModelList(org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList) ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment)

Example 4 with OperationalEnvironment

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;
}
Also used : AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment)

Example 5 with OperationalEnvironment

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());
}
Also used : OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Aggregations

OperationalEnvironment (org.onap.aai.domain.yang.OperationalEnvironment)13 Test (org.junit.Test)6 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)6 BaseTest (org.onap.so.apihandlerinfra.BaseTest)6 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)3 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)3 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 NotFoundException (javax.ws.rs.NotFoundException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)1 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)1 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)1 TenantIsolationException (org.onap.so.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException)1 AAIClientObjectBuilder (org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder)1 Distribution (org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution)1 ServiceModelList (org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList)1 ServiceEndPoint (org.onap.so.client.grm.beans.ServiceEndPoint)1 ServiceEndPointList (org.onap.so.client.grm.beans.ServiceEndPointList)1 ServiceEndPointRequest (org.onap.so.client.grm.beans.ServiceEndPointRequest)1