use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowAction method getConfigBuildingBlocks.
protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ConfigBuildingBlocksDataObject dataObj) throws AAIEntityNotFoundException, VnfcMultipleRelationshipException {
List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>();
List<OrchestrationFlow> result = dataObj.getOrchFlows().stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList());
String vnfId = dataObj.getWorkflowResourceIds().getVnfId();
String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId();
String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
String vfModuleCustomizationUUID;
org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId);
if (aaiVfModule == null) {
logger.error("No matching VfModule is found in Generic-Vnf in AAI for vnfId: {} and vfModuleId : {}", vnfId, vfModuleId);
throw new AAIEntityNotFoundException("No matching VfModule is found in Generic-Vnf in AAI for vnfId: " + vnfId + " and vfModuleId : " + vfModuleId);
} else {
vfModuleCustomizationUUID = aaiVfModule.getModelCustomizationId();
}
String replaceVfModuleCustomizationUUID = "";
String replaceVnfModuleCustomizationUUID = "";
boolean isReplace = false;
if (dataObj.getRequestAction().equalsIgnoreCase("replaceInstance") || dataObj.getRequestAction().equalsIgnoreCase("replaceInstanceRetainAssignments")) {
for (RelatedInstanceList relatedInstList : dataObj.getRequestDetails().getRelatedInstanceList()) {
RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
replaceVnfModuleCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
}
}
replaceVfModuleCustomizationUUID = dataObj.getRequestDetails().getModelInfo().getModelCustomizationId();
isReplace = true;
}
List<org.onap.aai.domain.yang.Vnfc> vnfcs = getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Vnfc.class, Types.VNFC);
for (org.onap.aai.domain.yang.Vnfc vnfc : vnfcs) {
WorkflowResourceIds workflowIdsCopy = SerializationUtils.clone(dataObj.getWorkflowResourceIds());
org.onap.aai.domain.yang.Configuration configuration = getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, Types.CONFIGURATION);
if (configuration == null) {
logger.warn(String.format("No configuration found for VNFC %s in AAI", vnfc.getVnfcName()));
continue;
}
workflowIdsCopy.setConfigurationId(configuration.getConfigurationId());
for (OrchestrationFlow orchFlow : result) {
if (!isReplace || (isReplace && (orchFlow.getFlowName().contains("Delete")))) {
if (!isReplace) {
dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
} else {
if (orchFlow.getFlowName().contains("Delete")) {
dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
} else {
dataObj.getResourceKey().setVfModuleCustomizationId(replaceVfModuleCustomizationUUID);
dataObj.getResourceKey().setVnfCustomizationId(replaceVnfModuleCustomizationUUID);
}
}
dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
String vnfcName = vnfc.getVnfcName();
if (vnfcName == null || vnfcName.isEmpty()) {
buildAndThrowException(dataObj.getExecution(), "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match"));
}
ExecuteBuildingBlock ebb = executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), workflowIdsCopy, dataObj.getRequestDetails(), false, null, vnfcName, true, null);
flowsToExecuteConfigs.add(ebb);
}
}
}
return flowsToExecuteConfigs;
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowActionTest method selectExecutionListALaCarteNetworkCreateTest.
/**
* ALACARTE TESTS
*/
@Test
public void selectExecutionListALaCarteNetworkCreateTest() throws Exception {
String gAction = "createInstance";
String resource = "Network";
String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON);
initExecution(gAction, bpmnRequest, true);
execution.setVariable("requestUri", "v6/networks/123");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("AssignNetwork1802BB", "CreateNetworkBB", "ActivateNetworkBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "AssignNetwork1802BB", "CreateNetworkBB", "ActivateNetworkBB");
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowActionTest method selectExecutionListServiceMacroCreateWithNetworkCollectionTest.
@Test
public void selectExecutionListServiceMacroCreateWithNetworkCollectionTest() throws Exception {
String gAction = "createInstance";
String resource = "Service";
String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
initExecution(gAction, bpmnRequest, false);
execution.setVariable("requestUri", "v6/serviceInstances/123");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
northBoundRequest.setIsToplevelflow(true);
List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB", "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
Service service = new Service();
List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
networkCust.setModelCustomizationUUID("123");
networkCustomizations.add(networkCust);
service.setNetworkCustomizations(networkCustomizations);
NetworkCollectionResourceCustomization collectionResourceCustomization = new NetworkCollectionResourceCustomization();
collectionResourceCustomization.setModelCustomizationUUID("123");
CollectionResource collectionResource = new CollectionResource();
collectionResource.setToscaNodeType("NetworkCollection");
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setToscaNodeType("NetworkCollectionResource");
instanceGroup.setCollectionNetworkResourceCustomizations(new ArrayList<>());
CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
collectionNetworkResourceCust.setModelCustomizationUUID("123");
collectionNetworkResourceCust.setNetworkResourceCustomization(collectionResourceCustomization);
instanceGroup.getCollectionNetworkResourceCustomizations().add(collectionNetworkResourceCust);
List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
collectionInstanceGroupCustomization.setModelCustomizationUUID("123");
collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
collectionInstanceGroupCustomization.setInstanceGroup(instanceGroup);
collectionInstanceGroupCustomization.setCollectionResourceCust(collectionResourceCustomization);
instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
collectionResource.setInstanceGroup(instanceGroup);
collectionResourceCustomization.setCollectionResource(collectionResource);
;
service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
doReturn(collectionResourceCustomization).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
assertEquals("Network id not empty", !ebbs.get(2).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
assertEquals("Network id not empty", !ebbs.get(3).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
assertEquals("Network id not empty", !ebbs.get(4).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB", ebbs.get(2).getWorkflowResourceIds().getNetworkId() == ebbs.get(3).getWorkflowResourceIds().getNetworkId() && ebbs.get(3).getWorkflowResourceIds().getNetworkId() == ebbs.get(4).getWorkflowResourceIds().getNetworkId(), true);
assertEquals("Network id not empty", !ebbs.get(5).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
assertEquals("Network id not empty", !ebbs.get(6).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
assertEquals("Network id not empty", !ebbs.get(7).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB", ebbs.get(5).getWorkflowResourceIds().getNetworkId() == ebbs.get(6).getWorkflowResourceIds().getNetworkId() && ebbs.get(6).getWorkflowResourceIds().getNetworkId() == ebbs.get(7).getWorkflowResourceIds().getNetworkId(), true);
assertEquals("Network id not empty", !ebbs.get(8).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
assertEquals("Network id not empty", !ebbs.get(9).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
assertEquals("Network id not empty", !ebbs.get(10).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB", ebbs.get(8).getWorkflowResourceIds().getNetworkId() == ebbs.get(9).getWorkflowResourceIds().getNetworkId() && ebbs.get(9).getWorkflowResourceIds().getNetworkId() == ebbs.get(10).getWorkflowResourceIds().getNetworkId(), true);
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowActionTest method selectExecutionListMacroResumeTest.
@Test
public void selectExecutionListMacroResumeTest() throws Exception {
String gAction = "createInstance";
String resource = "Service";
String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON);
initExecution(gAction, bpmnRequest, false);
execution.setVariable("requestUri", "v6/serviceInstances/123");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
Service service = new Service();
service.setModelUUID("3c40d244-808e-42ca-b09a-256d83d19d0a");
ServiceInstance si = new ServiceInstance();
when(bbSetupUtils.getAAIServiceInstanceById("123")).thenReturn(si);
when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
String flowsToExecuteString = "[{\"buildingBlock\":{\"mso-id\":\"2f9ddc4b-4dcf-4129-a35f-be1625ae0176\",\"bpmn-flow-name\":\"AssignServiceInstanceBB\",\"key\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"is-virtual-link\":false,\"virtual-link-key\":null},\"requestId\":\"9c944122-d161-4280-8594-48c06a9d96d5\",\"apiVersion\":\"7\",\"resourceId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"requestAction\":\"deleteInstance\",\"vnfType\":\"\",\"aLaCarte\":true,\"homing\":false,\"workflowResourceIds\":{\"serviceInstanceId\":\"ff9dae72-05bb-4277-ad2b-1b082467c138\",\"vnfId\":\"84a29830-e533-4f20-a838-910c740bf24c\",\"networkId\":\"\",\"volumeGroupId\":\"\",\"vfModuleId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"networkCollectionId\":null,\"configurationId\":\"10f8a3a3-91bf-4821-9515-c01b2864dff0\",\"instanceGroupId\":\"\"},\"requestDetails\":{\"modelInfo\":{\"modelCustomizationName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelInvariantId\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelType\":\"vfModule\",\"modelId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelVersionId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelCustomizationId\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelUuid\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelInvariantUuid\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelInstanceName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\"},\"requestInfo\":{\"source\":\"VID\",\"suppressRollback\":false,\"requestorId\":\"pj8646\"},\"cloudConfiguration\":{\"tenantId\":\"e2a6af59d1cb43b2874e943bbbf8470a\",\"cloudOwner\":\"att-nc\",\"lcpCloudRegionId\":\"auk51b\"},\"requestParameters\":{\"testApi\":\"GR_API\"}},\"configurationResourceKeys\":{\"vfModuleCustomizationUUID\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"vnfResourceCustomizationUUID\":\"a80f05b8-d651-44af-b999-8ed78fb4582f\",\"cvnfcCustomizationUUID\":\"69cce457-9ffd-4359-962b-0596a1e83ad1\",\"vnfcName\":\"zauk51bmcmr01mcm001\"}}]";
ObjectMapper om = new ObjectMapper();
List<ExecuteBuildingBlock> flowsToExecute = null;
try {
ExecuteBuildingBlock[] asArray = om.readValue(flowsToExecuteString, ExecuteBuildingBlock[].class);
flowsToExecute = Arrays.asList(asArray);
} catch (Exception e) {
e.printStackTrace();
}
when(bbSetupUtils.loadOriginalFlowExecutionPath(anyString())).thenReturn(flowsToExecute);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB");
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowActionTest method createFlowList.
private List<OrchestrationFlow> createFlowList(String... flowNames) {
List<OrchestrationFlow> result = new ArrayList<>();
int sequenceNumber = 1;
for (String flowName : flowNames) {
OrchestrationFlow orchFlow = new OrchestrationFlow();
orchFlow.setFlowName(flowName);
orchFlow.setSequenceNumber(sequenceNumber++);
result.add(orchFlow);
}
return result;
}
Aggregations