Search in sources :

Example 1 with InstanceGroup

use of org.onap.so.db.catalog.beans.InstanceGroup in project so by onap.

the class ServiceEBBLoader method traverseNetworkCollectionResourceCustomization.

private void traverseNetworkCollectionResourceCustomization(List<Resource> resourceList, Resource serviceResource, CollectionResourceCustomization collectionResourceCustomization) {
    if (collectionResourceCustomizationShouldNotBeProcessed(resourceList, serviceResource, collectionResourceCustomization))
        return;
    int minNetworks = 0;
    org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = collectionResourceCustomization.getCollectionResource().getInstanceGroup();
    CollectionResourceInstanceGroupCustomization collectionInstCust = null;
    if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) {
        for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup.getCollectionInstanceGroupCustomizations()) {
            if (collectionInstanceGroupTemp.getModelCustomizationUUID().equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) {
                collectionInstCust = collectionInstanceGroupTemp;
                break;
            }
        }
        if (interfaceNetworkQuantityIsAvailableInCollection(collectionInstCust)) {
            minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity();
        }
    }
    logger.debug("minNetworks: {}", minNetworks);
    CollectionNetworkResourceCustomization collectionNetworkResourceCust = getCollectionNetworkResourceCustomization(collectionResourceCustomization, instanceGroup);
    for (int i = 0; i < minNetworks; i++) {
        if (collectionNetworkResourceCust != null) {
            Resource resource = new Resource(WorkflowType.VIRTUAL_LINK, collectionNetworkResourceCust.getModelCustomizationUUID(), false, serviceResource);
            resource.setVirtualLinkKey(Integer.toString(i));
            resourceList.add(resource);
        }
    }
}
Also used : CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization)

Example 2 with InstanceGroup

use of org.onap.so.db.catalog.beans.InstanceGroup in project so by onap.

the class NetworkCollectionCatalogDbQueryTest method networkCollectionTest.

@Test
@Transactional
public void networkCollectionTest() {
    logger.debug("TEST IS STARTING UP...");
    String modelUUID = "4694a55f-58b3-4f17-92a5-796d6f5ffd0d";
    boolean found = false;
    logger.debug(Integer.toString(port));
    InstanceGroup instanceGroup = null;
    List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupList = null;
    org.onap.so.db.catalog.beans.Service service = client.getServiceByID(modelUUID);
    if (service == null) {
        logger.debug("null");
    } else {
        List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations();
        if (customizations.isEmpty()) {
            logger.debug("No Network Collection found. CollectionResourceCustomizations is empty");
        }
        for (CollectionResourceCustomization crc : customizations) {
            if (client.getNetworkCollectionResourceCustomizationByID(crc.getModelCustomizationUUID()) instanceof NetworkCollectionResourceCustomization) {
                if (crc.getCollectionResource() != null) {
                    if (crc.getCollectionResource().getToscaNodeType() != null) {
                        String toscaNodeType = crc.getCollectionResource().getToscaNodeType();
                        if (toscaNodeType.contains(NETWORKCOLLECTION)) {
                            logger.debug("Found a network collection");
                            instanceGroup = crc.getCollectionResource().getInstanceGroup();
                            collectionInstanceGroupList = instanceGroup.getCollectionInstanceGroupCustomizations();
                            CollectionNetworkResourceCustomization collectionNetworkCust = instanceGroup.getCollectionNetworkResourceCustomizations().get(0);
                            logger.debug("Found Collection Network Resource Customization: " + collectionNetworkCust.getModelCustomizationUUID());
                        } else {
                            logger.debug("No Network Collection found. toscaNodeType does not contain NetworkCollection");
                        }
                    } else {
                        logger.debug("No Network Collection found. toscaNodeType is null");
                    }
                } else {
                    logger.debug("No Network Collection found. collectionResource is null");
                }
                found = true;
            } else {
                logger.debug("Not a Network Collection Resource Customization Instance");
            }
        }
    }
    assertEquals("Number of CollectionResourceInstanceGroupCustomization in list", 2, collectionInstanceGroupList.size());
    assertNotNull(instanceGroup);
    assertTrue(found);
}
Also used : CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) Test(org.junit.Test) CatalogDbAdapterBaseTest(org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest) Transactional(javax.transaction.Transactional)

Example 3 with InstanceGroup

use of org.onap.so.db.catalog.beans.InstanceGroup in project so by onap.

the class QueryGroups method JSON2.

@Override
public String JSON2(boolean isArray, boolean isEmbed) {
    StringBuilder sb = new StringBuilder();
    if (!isEmbed && isArray)
        sb.append("{ ");
    if (isArray)
        sb.append("\"groups\": [");
    Map<String, String> valueMap = new HashMap<>();
    String sep = "";
    boolean first = true;
    for (VnfcInstanceGroupCustomization o : vnfcInstanceGroupCustomizations) {
        if (first)
            sb.append("\n");
        first = false;
        boolean vnfcCustomizationNull = o.getVnfcCustomizations() == null;
        InstanceGroup instanceGroup = o.getInstanceGroup();
        if (instanceGroup != null) {
            put(valueMap, "MODEL_NAME", instanceGroup.getModelName());
            put(valueMap, "MODEL_UUID", instanceGroup.getModelUUID());
            put(valueMap, "MODEL_INVARIANT_ID", instanceGroup.getModelInvariantUUID());
            put(valueMap, "MODEL_VERSION", instanceGroup.getModelVersion());
        }
        String subItem = new QueryVnfcs(vnfcCustomizationNull ? null : o.getVnfcCustomizations()).JSON2(true, true);
        valueMap.put("_VNFCS_", subItem.replaceAll("(?m)^", "\t\t"));
        sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
        sep = ",\n";
    }
    if (!first)
        sb.append("\n");
    if (isArray)
        sb.append("]");
    if (!isEmbed && isArray)
        sb.append("}");
    return sb.toString();
}
Also used : HashMap(java.util.HashMap) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup)

Example 4 with InstanceGroup

use of org.onap.so.db.catalog.beans.InstanceGroup in project so by onap.

the class CatalogDbClientTest method testGetInstanceGroupByModelUUID.

@Test
public void testGetInstanceGroupByModelUUID() {
    InstanceGroup instanceGroup = client.getInstanceGroupByModelUUID("0c8692ef-b9c0-435d-a738-edf31e71f38b");
    assertNotNull(instanceGroup);
    assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName());
    assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806", instanceGroup.getToscaNodeType().toString());
}
Also used : InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) Test(org.junit.Test) CatalogDbAdapterBaseTest(org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)

Example 5 with InstanceGroup

use of org.onap.so.db.catalog.beans.InstanceGroup 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);
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) ArrayList(java.util.ArrayList) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Service(org.onap.so.db.catalog.beans.Service) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

InstanceGroup (org.onap.so.db.catalog.beans.InstanceGroup)9 Test (org.junit.Test)5 CollectionResourceInstanceGroupCustomization (org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization)5 CollectionNetworkResourceCustomization (org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization)3 NetworkCollectionResourceCustomization (org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization)3 ArrayList (java.util.ArrayList)2 CatalogDbAdapterBaseTest (org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)2 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)2 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)2 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)2 CollectionResourceCustomization (org.onap.so.db.catalog.beans.CollectionResourceCustomization)2 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)2 Service (org.onap.so.db.catalog.beans.Service)2 VnfcInstanceGroupCustomization (org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Transactional (javax.transaction.Transactional)1 GET (javax.ws.rs.GET)1