use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class ServiceEBBLoader method traverseServiceInstanceMSOPnfs.
private void traverseServiceInstanceMSOPnfs(List<Resource> resourceList, Resource serviceResource, List<Pair<WorkflowType, String>> aaiResourceIds, org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) {
if (serviceInstanceMSO.getPnfs() == null) {
return;
}
for (org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf : serviceInstanceMSO.getPnfs()) {
aaiResourceIds.add(new Pair<>(WorkflowType.PNF, pnf.getPnfId()));
Resource resource = new Resource(WorkflowType.PNF, pnf.getPnfId(), false, serviceResource);
ModelInfoPnf modelInfo = pnf.getModelInfoPnf();
if (modelInfo != null) {
resource.setModelVersionId(modelInfo.getModelUuid());
resource.setModelCustomizationId(modelInfo.getModelCustomizationUuid());
}
resourceList.add(resource);
}
}
use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class SkipCDSBuildingBlockListener method run.
/**
* Skip the CDS Building block according to the Skip Flag.
*
* @param flowsToExecute - List of ExecuteBuildingBlock object.
* @param execution - BuildingBlockExecution object
* @param currentBB - ExecuteBuildingBlock object
*/
@Override
public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, BuildingBlockExecution execution) {
String resourceKey = currentBB.getBuildingBlock().getKey();
List<Resource> resources = execution.getVariable("resources");
Resource resource = resources.stream().filter(r -> resourceKey.equals(r.getResourceId())).findFirst().orElseThrow(() -> new IllegalArgumentException("Resource not found for key:" + resourceKey));
String scope = currentBB.getBuildingBlock().getBpmnScope();
if ("SERVICE".equalsIgnoreCase(scope)) {
Service service = catalogDbClient.getServiceByID(resource.getModelVersionId());
currentSequenceSkipCheck(execution, service.getSkipPostInstConf());
} else if ("VNF".equalsIgnoreCase(scope) && containsIgnoreCaseAction(currentBB, vnfActions)) {
VnfResourceCustomization vrc = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(resource.getModelCustomizationId());
if (vrc != null) {
logger.debug("getSkipPostInstConf value: " + vrc.getSkipPostInstConf());
boolean skipConfigVNF = vrc.getSkipPostInstConf();
currentSequenceSkipCheck(execution, skipConfigVNF);
}
} else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VFModule") && containsIgnoreCaseAction(currentBB, vFModuleAction)) {
VfModuleCustomization vfc = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(resource.getModelCustomizationId());
if (null != vfc) {
logger.debug("getSkipPostInstConf value: " + vfc.getSkipPostInstConf().booleanValue());
boolean skipVfModule = vfc.getSkipPostInstConf();
currentSequenceSkipCheck(execution, skipVfModule);
}
} else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("PNF") && containsIgnoreCaseAction(currentBB, pnfActions)) {
PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resource.getModelCustomizationId());
if (null != pnfResourceCustomization) {
logger.debug("getSkipPostInstConf value: " + pnfResourceCustomization.getSkipPostInstConf());
boolean skipConfigPNF = pnfResourceCustomization.getSkipPostInstConf();
currentSequenceSkipCheck(execution, skipConfigPNF);
}
}
}
use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class ServiceEBBLoaderTest method getResourceListForServiceWithRequestActionAssignInstance.
@Test
public void getResourceListForServiceWithRequestActionAssignInstance() throws IOException, VrfBondingServiceException {
String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON);
ObjectMapper mapper = new ObjectMapper();
ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
String requestAction = "assignInstance";
String serviceInstanceId = "123";
String resourceId = "si0";
List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
doReturn(prepareListWithResources()).when(mockUserParamsServiceTraversal).getResourceListFromUserParams(any(), anyList(), anyString(), anyString());
List<Resource> resources = serviceEBBLoader.getResourceListForService(sIRequest, requestAction, execution, serviceInstanceId, resourceId, aaiResourceIds);
assertNotNull(resources);
assertEquals(resources.size(), 6);
}
use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class ServiceEBBLoaderTest method foundRelatedTest.
@Test
public void foundRelatedTest() {
List<Resource> resourceList = new ArrayList<>();
resourceList.add(new Resource(WorkflowType.PNF, "model customization id", false, null));
resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false, null));
resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false, null));
resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false, null));
assertTrue(serviceEBBLoader.foundRelated(resourceList));
}
use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class ServiceEBBLoaderTest method traverseAAIServiceTest.
@Test
public void traverseAAIServiceTest() {
List<Resource> resourceCounter = new ArrayList<>();
String resourceId = "si0";
List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId(resourceId);
org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = setServiceInstance();
GenericVnf genericVnf = setGenericVnf();
setVfModule(true);
setVolumeGroup();
setL3Network();
setCollection();
setConfiguration();
org.onap.aai.domain.yang.GenericVnf genericVnfAai = new org.onap.aai.domain.yang.GenericVnf();
genericVnfAai.setModelCustomizationId(genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid());
Configuration config = new Configuration();
config.setConfigurationId("testConfigurationId2");
serviceInstance.getConfigurations().add(config);
Relationship relationship1 = new Relationship();
relationship1.setRelatedTo("vnfc");
RelationshipList relationshipList1 = new RelationshipList();
relationshipList1.getRelationship().add(relationship1);
Relationship relationship2 = new Relationship();
relationship2.setRelatedTo("vpn-binding");
RelationshipList relationshipList2 = new RelationshipList();
relationshipList2.getRelationship().add(relationship2);
org.onap.aai.domain.yang.Configuration aaiConfiguration1 = new org.onap.aai.domain.yang.Configuration();
aaiConfiguration1.setConfigurationId("testConfigurationId");
aaiConfiguration1.setRelationshipList(relationshipList1);
org.onap.aai.domain.yang.Configuration aaiConfiguration2 = new org.onap.aai.domain.yang.Configuration();
aaiConfiguration2.setConfigurationId("testConfigurationId2");
aaiConfiguration2.setRelationshipList(relationshipList1);
org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
aaiVfModule.setIsBaseVfModule(true);
try {
doReturn(genericVnfAai).when(mockBbInputSetupUtils).getAAIGenericVnf(genericVnf.getVnfId());
doReturn(serviceInstanceAAI).when(mockBbInputSetupUtils).getAAIServiceInstanceById(resourceId);
doReturn(serviceInstance).when(mockBbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
doReturn(Optional.of(aaiConfiguration1)).when(mockAaiConfigurationResources).getConfiguration("testConfigurationId");
doReturn(Optional.of(aaiConfiguration2)).when(mockAaiConfigurationResources).getConfiguration("testConfigurationId2");
doReturn(aaiVfModule).when(mockBbInputSetupUtils).getAAIVfModule(any(), any());
serviceEBBLoader.traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds);
assertEquals(8, resourceCounter.size());
assertTrue(resourceCounter.get(2).isBaseVfModule());
assertThat(aaiResourceIds, sameBeanAs(getExpectedResourceIds()));
} catch (Exception e) {
fail("Unexpected exception was thrown.");
}
}
Aggregations