Search in sources :

Example 1 with OrchestrationStatus

use of org.onap.so.db.catalog.beans.OrchestrationStatus in project so by onap.

the class BBInputSetupMapperLayerTest method testMapOrchestrationStatusFromAAI.

@Test
public void testMapOrchestrationStatusFromAAI() {
    OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
    String orchStatusInput = "Inventoried";
    OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
    assertThat(actual, sameBeanAs(expected));
    expected = OrchestrationStatus.ASSIGNED;
    orchStatusInput = "Assigned";
    actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
    assertThat(actual, sameBeanAs(expected));
    expected = OrchestrationStatus.ACTIVE;
    orchStatusInput = "Active";
    actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
    assertThat(actual, sameBeanAs(expected));
    expected = OrchestrationStatus.CREATED;
    orchStatusInput = "Created";
    actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
    assertThat(actual, sameBeanAs(expected));
    expected = OrchestrationStatus.PRECREATED;
    orchStatusInput = "PreCreated";
    actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
    assertThat(actual, sameBeanAs(expected));
    expected = OrchestrationStatus.PENDING_CREATE;
    orchStatusInput = "PendingCreate";
    actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
    assertThat(actual, sameBeanAs(expected));
    expected = OrchestrationStatus.PENDING_DELETE;
    orchStatusInput = "PendingDelete";
    actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
    assertThat(actual, sameBeanAs(expected));
    expected = OrchestrationStatus.PENDING;
    orchStatusInput = "Pending";
    actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
    assertThat(actual, sameBeanAs(expected));
    expected = OrchestrationStatus.PENDING_ACTIVATION;
    orchStatusInput = "PendingActivation";
    actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
    assertThat(actual, sameBeanAs(expected));
}
Also used : OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) Test(org.junit.Test)

Example 2 with OrchestrationStatus

use of org.onap.so.db.catalog.beans.OrchestrationStatus in project so by onap.

the class AAIObjectMapperTest method pnfMap.

@Test
public void pnfMap() {
    final String pnfId = "PNF_id1";
    final String pnfName = "PNF_name1";
    final String modelCustomizationId = "8421fe03-fd1b-4bf7-845a-c3fe91edb03e";
    final String modelInvariantId = "341a6f84-2cf9-4942-8f9e-2472ffe4e1d8";
    final String modelVersionId = "b13a0706-46b9-4a98-a9f9-5b28431235e7";
    final OrchestrationStatus orchestrationStatus = OrchestrationStatus.PRECREATED;
    Pnf pnf = new Pnf();
    pnf.setPnfId(pnfId);
    pnf.setPnfName(pnfName);
    pnf.setModelInfoPnf(new ModelInfoPnf());
    pnf.getModelInfoPnf().setModelCustomizationUuid(modelCustomizationId);
    pnf.getModelInfoPnf().setModelInvariantUuid(modelInvariantId);
    pnf.getModelInfoPnf().setModelUuid(modelVersionId);
    pnf.setOrchestrationStatus(orchestrationStatus);
    org.onap.aai.domain.yang.Pnf aaiPnf = aaiObjectMapper.mapPnf(pnf);
    assertEquals(aaiPnf.getPnfId(), pnfId);
    assertEquals(aaiPnf.getPnfName(), pnfName);
    assertEquals(aaiPnf.getModelCustomizationId(), modelCustomizationId);
    assertEquals(aaiPnf.getModelInvariantId(), modelInvariantId);
    assertEquals(aaiPnf.getModelVersionId(), modelVersionId);
    assertEquals(aaiPnf.getOrchestrationStatus(), orchestrationStatus.toString());
}
Also used : ModelInfoPnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) ModelInfoPnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) Test(org.junit.Test)

Example 3 with OrchestrationStatus

use of org.onap.so.db.catalog.beans.OrchestrationStatus in project so by onap.

the class OrchestrationStatusValidator method getOrchestrationStatus.

private OrchestrationStatus getOrchestrationStatus(BuildingBlockExecution execution, String buildingBlockFlowName, BuildingBlockDetail buildingBlockDetail) throws BBObjectNotFoundException, OrchestrationStatusValidationException {
    OrchestrationStatus orchestrationStatus = null;
    switch(buildingBlockDetail.getResourceType()) {
        case SERVICE:
            ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
            orchestrationStatus = serviceInstance.getOrchestrationStatus();
            break;
        case VNF:
            GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
            orchestrationStatus = genericVnf.getOrchestrationStatus();
            break;
        case VF_MODULE:
            VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
            orchestrationStatus = vfModule.getOrchestrationStatus();
            break;
        case VOLUME_GROUP:
            VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
            orchestrationStatus = volumeGroup.getOrchestrationStatus();
            break;
        case NETWORK:
            L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
            orchestrationStatus = network.getOrchestrationStatus();
            break;
        case NETWORK_COLLECTION:
            Collection networkCollection = getNetworkCollection(execution);
            orchestrationStatus = networkCollection.getOrchestrationStatus();
            break;
        case CONFIGURATION:
            Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
            orchestrationStatus = configuration.getOrchestrationStatus();
            break;
        case INSTANCE_GROUP:
            InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
            orchestrationStatus = instanceGroup.getOrchestrationStatus();
            break;
        case NO_VALIDATE:
            // short circuit and exit method
            execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.VALIDATION_SKIPPED);
            break;
        default:
            // code
            throw new OrchestrationStatusValidationException(String.format(UNKNOWN_RESOURCE_TYPE, buildingBlockFlowName, buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction()));
    }
    return orchestrationStatus;
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) OrchestrationStatusValidationException(org.onap.so.client.exception.OrchestrationStatusValidationException) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Example 4 with OrchestrationStatus

use of org.onap.so.db.catalog.beans.OrchestrationStatus in project so by onap.

the class OrchestrationStatusValidator method validateOrchestrationStatus.

/**
 * This method validate's the status of the OrchestrationStatus against the buildingBlockDetail ResourceType
 */
public void validateOrchestrationStatus(BuildingBlockExecution execution) {
    try {
        execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, null);
        String buildingBlockFlowName = execution.getFlowToBeCalled();
        BuildingBlockDetail buildingBlockDetail = catalogDbClient.getBuildingBlockDetail(buildingBlockFlowName);
        if (buildingBlockDetail == null) {
            throw new OrchestrationStatusValidationException(String.format(BUILDING_BLOCK_DETAIL_NOT_FOUND, buildingBlockFlowName));
        }
        OrchestrationStatus orchestrationStatus = getOrchestrationStatus(execution, buildingBlockFlowName, buildingBlockDetail);
        if (buildingBlockDetail.getResourceType().equals(ResourceType.NO_VALIDATE)) {
            return;
        }
        if (orchestrationStatus == null) {
            throw new OrchestrationStatusValidationException("The resource's orchstration status is null. Cannot perform task on a null orchestration status");
        }
        OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = catalogDbClient.getOrchestrationStatusStateTransitionDirective(buildingBlockDetail.getResourceType(), orchestrationStatus, buildingBlockDetail.getTargetAction());
        if (orchestrationStatusStateTransitionDirective.getFlowDirective() == OrchestrationStatusValidationDirective.FAIL) {
            throw new OrchestrationStatusValidationException(String.format(ORCHESTRATION_VALIDATION_FAIL, buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction(), orchestrationStatus));
        }
        execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, orchestrationStatusStateTransitionDirective.getFlowDirective());
        if (buildingBlockFlowName.matches("Create(.*)|Delete(.*)") && orchestrationStatusStateTransitionDirective.getFlowDirective() == OrchestrationStatusValidationDirective.SILENT_SUCCESS) {
            updatedResourceStatus(execution, buildingBlockDetail);
        }
    } catch (BBObjectNotFoundException ex) {
        logger.error("Error occurred for bb object notfound in OrchestrationStatusValidator validateOrchestrationStatus ", ex);
        if (execution.getFlowToBeCalled().contains("Unassign")) {
            execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.SILENT_SUCCESS);
        } else {
            exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex);
        }
    } catch (Exception e) {
        logger.error("Exception occurred", e);
        exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e);
    }
}
Also used : OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) OrchestrationStatusValidationException(org.onap.so.client.exception.OrchestrationStatusValidationException) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) OrchestrationStatusValidationException(org.onap.so.client.exception.OrchestrationStatusValidationException) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException)

Aggregations

OrchestrationStatus (org.onap.so.db.catalog.beans.OrchestrationStatus)4 Test (org.junit.Test)2 OrchestrationStatusValidationException (org.onap.so.client.exception.OrchestrationStatusValidationException)2 Collection (org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)1 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)1 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)1 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)1 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)1 Pnf (org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf)1 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)1 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)1 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)1 ModelInfoPnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf)1 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)1 BuildingBlockDetail (org.onap.so.db.catalog.beans.BuildingBlockDetail)1 OrchestrationStatusStateTransitionDirective (org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1