Search in sources :

Example 1 with WorkflowResourceIds

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);
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)

Example 2 with WorkflowResourceIds

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;
}
Also used : WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Arrays(java.util.Arrays) BBConstants(org.onap.so.bpmn.common.BBConstants) AAIUriFactory(org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Vnfc(org.onap.aai.domain.yang.Vnfc) ServiceEBBLoader(org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.ServiceEBBLoader) CREATE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE) StringUtils(org.apache.commons.lang3.StringUtils) Matcher(java.util.regex.Matcher) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) Map(java.util.Map) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) VnfEBBLoader(org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.VnfEBBLoader) UPGRADE_CNF(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UPGRADE_CNF) BBInputSetupUtils(org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils) VnfcMultipleRelationshipException(org.onap.so.bpmn.infrastructure.workflow.tasks.excpetion.VnfcMultipleRelationshipException) WORKFLOW_ACTION_ERROR_MESSAGE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) FABRIC_CONFIGURATION(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION) BBInputSetup(org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup) Set(java.util.Set) UUID(java.util.UUID) ASSIGN_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE) Collectors(java.util.stream.Collectors) Pair(org.javatuples.Pair) CatalogDbClient(org.onap.so.db.catalog.client.CatalogDbClient) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) HEALTH_CHECK(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.HEALTH_CHECK) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RECREATE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.RECREATE_INSTANCE) AAIObjectName(org.onap.aaiclient.client.aai.AAIObjectName) Environment(org.springframework.core.env.Environment) CollectionUtils(org.springframework.util.CollectionUtils) ModelType(org.onap.so.serviceinstancebeans.ModelType) Optional(java.util.Optional) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Pattern(java.util.regex.Pattern) WorkflowResourceIdsUtils(org.onap.so.bpmn.infrastructure.workflow.tasks.utils.WorkflowResourceIdsUtils) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) DELETE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DELETE_INSTANCE) HashMap(java.util.HashMap) SerializationUtils(org.apache.commons.lang3.SerializationUtils) UPDATE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UPDATE_INSTANCE) ArrayList(java.util.ArrayList) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) LinkedHashSet(java.util.LinkedHashSet) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) REPLACEINSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE) Logger(org.slf4j.Logger) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) AAIEntityNotFoundException(org.onap.so.client.orchestration.AAIEntityNotFoundException) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) REPLACEINSTANCERETAINASSIGNMENTS(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS) SERVICE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE) Component(org.springframework.stereotype.Component) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Comparator(java.util.Comparator) CONTROLLER(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) ArrayList(java.util.ArrayList) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Vnfc(org.onap.aai.domain.yang.Vnfc) AAIEntityNotFoundException(org.onap.so.client.orchestration.AAIEntityNotFoundException) VnfcMultipleRelationshipException(org.onap.so.bpmn.infrastructure.workflow.tasks.excpetion.VnfcMultipleRelationshipException) AAIEntityNotFoundException(org.onap.so.client.orchestration.AAIEntityNotFoundException) IOException(java.io.IOException) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) Vnfc(org.onap.aai.domain.yang.Vnfc)

Example 3 with WorkflowResourceIds

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);
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)

Example 4 with WorkflowResourceIds

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;
}
Also used : WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)

Example 5 with 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));
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) File(java.io.File) Test(org.junit.Test)

Aggregations

WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)53 Test (org.junit.Test)44 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)43 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)15 GenericVnf (org.onap.aai.domain.yang.GenericVnf)14 ArrayList (java.util.ArrayList)10 VfModule (org.onap.aai.domain.yang.VfModule)9 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)8 OrchestrationFlow (org.onap.so.db.catalog.beans.macro.OrchestrationFlow)7 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)7 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 HashMap (java.util.HashMap)6 List (java.util.List)6 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)6 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)6 ConfigurationResource (org.onap.so.db.catalog.beans.ConfigurationResource)6 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)5 VolumeGroup (org.onap.aai.domain.yang.VolumeGroup)5