Search in sources :

Example 16 with Resource

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);
    }
}
Also used : ModelInfoPnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)

Example 17 with 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);
        }
    }
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) Service(org.onap.so.db.catalog.beans.Service) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization)

Example 18 with Resource

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);
}
Also used : ArrayList(java.util.ArrayList) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) Mockito.anyString(org.mockito.Mockito.anyString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) Pair(org.javatuples.Pair) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 19 with Resource

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));
}
Also used : Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ArrayList(java.util.ArrayList) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 20 with Resource

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.");
    }
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) Mockito.anyString(org.mockito.Mockito.anyString) VrfBondingServiceException(org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException) ExpectedException(org.junit.rules.ExpectedException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) Relationship(org.onap.aai.domain.yang.Relationship) Pair(org.javatuples.Pair) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)40 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)10 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)9 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)8 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)7 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)6 Pair (org.javatuples.Pair)5 Service (org.onap.so.db.catalog.beans.Service)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)4 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)4 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)4 Mockito.anyString (org.mockito.Mockito.anyString)3 Relationship (org.onap.aai.domain.yang.Relationship)3 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)3 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)3 ConfigurationResource (org.onap.so.db.catalog.beans.ConfigurationResource)3 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)3