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));
}
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());
}
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;
}
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);
}
}
Aggregations