use of org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds in project so by onap.
the class ExecuteActivity method buildExecuteBuildingBlock.
protected ExecuteBuildingBlock buildExecuteBuildingBlock(DelegateExecution execution, String requestId, BuildingBlock buildingBlock) throws IOException {
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId((String) execution.getVariable(SERVICE_INSTANCE_ID));
workflowResourceIds.setVnfId((String) execution.getVariable(VNF_ID));
String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST);
ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
RequestDetails requestDetails = sIRequest.getRequestDetails();
return new ExecuteBuildingBlock().setaLaCarte(true).setRequestAction((String) execution.getVariable(G_ACTION)).setResourceId((String) execution.getVariable(VNF_ID)).setVnfType((String) execution.getVariable(VNF_TYPE)).setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock).setRequestDetails(requestDetails);
}
use of org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds 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.bpmn.servicedecomposition.entities.WorkflowResourceIds in project so by onap.
the class WorkflowActionBBTasks method getExecuteBBForConfig.
protected ExecuteBuildingBlock getExecuteBBForConfig(String bbName, ExecuteBuildingBlock ebb, String configurationId, ConfigurationResourceKeys configurationResourceKeys) {
BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(bbName).setMsoId(UUID.randomUUID().toString());
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(ebb.getWorkflowResourceIds());
workflowResourceIds.setConfigurationId(configurationId);
return new ExecuteBuildingBlock().setaLaCarte(ebb.isaLaCarte()).setApiVersion(ebb.getApiVersion()).setRequestAction(ebb.getRequestAction()).setVnfType(ebb.getVnfType()).setRequestId(ebb.getRequestId()).setRequestDetails(ebb.getRequestDetails()).setBuildingBlock(buildingBlock).setWorkflowResourceIds(workflowResourceIds).setConfigurationResourceKeys(configurationResourceKeys);
}
use of org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds in project so by onap.
the class WorkflowResourceIdsUtils method getWorkflowResourceIdsFromExecution.
public static WorkflowResourceIds getWorkflowResourceIdsFromExecution(DelegateExecution execution) {
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId((String) execution.getVariable("serviceInstanceId"));
workflowResourceIds.setNetworkId((String) execution.getVariable("networkId"));
workflowResourceIds.setVfModuleId((String) execution.getVariable("vfModuleId"));
workflowResourceIds.setVnfId((String) execution.getVariable("vnfId"));
workflowResourceIds.setVolumeGroupId((String) execution.getVariable("volumeGroupId"));
workflowResourceIds.setInstanceGroupId((String) execution.getVariable("instanceGroupId"));
workflowResourceIds.setVnfInstanceName((String) execution.getVariable("vnfInstanceName"));
workflowResourceIds.setVfModuleInstanceName((String) execution.getVariable("vfModuleInstanceName"));
return workflowResourceIds;
}
use of org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds in project so by onap.
the class BBInputSetupTest method testGetGBBCMAddMembersAction.
@Test
public void testGetGBBCMAddMembersAction() throws Exception {
GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockInstanceGroupExpected.json"), GeneralBuildingBlock.class);
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_instanceGroupAddMembers.json"), RequestDetails.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
String requestAction = "addMembers";
String instanceGroupId = "instance-group-001";
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setInstanceGroupId(instanceGroupId);
executeBB.setWorkflowResourceIds(workflowResourceIds);
lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId);
org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = new org.onap.aai.domain.yang.InstanceGroup();
aaiInstanceGroup.setId(instanceGroupId);
aaiInstanceGroup.setInstanceGroupName("test instance group 1");
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
aaiServiceInstance.setServiceInstanceId("service-instance-001");
aaiServiceInstance.setServiceInstanceName("test service instance 1");
Optional<org.onap.aai.domain.yang.ServiceInstance> optSI = Optional.of(aaiServiceInstance);
org.onap.aai.domain.yang.GenericVnf vnf1 = new org.onap.aai.domain.yang.GenericVnf();
vnf1.setVnfId("vnf-001");
vnf1.setVnfName("test vnf 1");
org.onap.aai.domain.yang.GenericVnf vnf2 = new org.onap.aai.domain.yang.GenericVnf();
vnf2.setVnfId("vnf-002");
vnf2.setVnfName("test vnf 2");
doReturn(aaiInstanceGroup).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(instanceGroupId);
doReturn(optSI).when(SPY_bbInputSetupUtils).getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
doReturn(vnf1).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-001");
doReturn(vnf2).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-002");
GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction, instanceGroupId);
assertThat(actual, sameBeanAs(expected));
}
Aggregations