Search in sources :

Example 6 with CollectionResourceInstanceGroupCustomization

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

the class ServiceEBBLoaderTest method traverseCatalogDbServiceMultipleNetworkTest.

@Test
public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException, VrfBondingServiceException {
    execution.setVariable("testProcessKey", "testProcessKeyValue");
    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();
    List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
    CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
    collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
    collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
    instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
    collectionResource.setInstanceGroup(instanceGroup);
    collectionResourceCustomization.setCollectionResource(collectionResource);
    ;
    service.setModelUUID("abc");
    service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
    service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
    doReturn(service).when(mockCatalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
    doReturn(collectionResourceCustomization).when(mockCatalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
    String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
    ObjectMapper mapper = new ObjectMapper();
    ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
    List<Resource> resource = new ArrayList<>();
    List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
    serviceEBBLoader.traverseCatalogDbService(execution, sIRequest, resource, aaiResourceIds);
    assertEquals(resource.size(), 2);
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) ArrayList(java.util.ArrayList) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) Service(org.onap.so.db.catalog.beans.Service) Mockito.anyString(org.mockito.Mockito.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Pair(org.javatuples.Pair) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 7 with CollectionResourceInstanceGroupCustomization

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

the class BBInputSetupMapperLayerTest method testMapCatalogInstanceGroupToInstanceGroup.

@Test
public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
    ModelInfoInstanceGroup expected = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"), ModelInfoInstanceGroup.class);
    InstanceGroup instanceGroup = mapper.readValue(new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
    instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
    CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust = new CollectionResourceInstanceGroupCustomization();
    collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
    collectionInstanceGroupCust.setFunction("function");
    collectionInstanceGroupCust.setDescription("description");
    instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
    CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
    collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
    ModelInfoInstanceGroup actual = bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
    assertThat(actual, sameBeanAs(expected));
}
Also used : ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) File(java.io.File) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) Test(org.junit.Test)

Example 8 with CollectionResourceInstanceGroupCustomization

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

the class ToscaResourceInstaller method createNetworkCollection.

protected CollectionNetworkResourceCustomization createNetworkCollection(IEntityDetails cnrEntity, ToscaResourceStructure toscaResourceStructure, Service service) {
    CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
    // **** Build Object to populate Collection_Resource table
    CollectionResource collectionResource = new CollectionResource();
    collectionResource.setModelName(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
    collectionResource.setModelInvariantUUID(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
    collectionResource.setModelUUID(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
    collectionResource.setModelVersion(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
    collectionResource.setDescription(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
    collectionResource.setToscaNodeType(cnrEntity.getToscaType());
    toscaResourceStructure.setCatalogCollectionResource(collectionResource);
    // **** Build object to populate Collection_Resource_Customization table
    NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
    ncfc.setFunction(getLeafPropertyValue(cnrEntity, "cr_function"));
    ncfc.setRole(getLeafPropertyValue(cnrEntity, "cr_role"));
    ncfc.setType(getLeafPropertyValue(cnrEntity, "cr_type"));
    ncfc.setModelInstanceName(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
    ncfc.setModelCustomizationUUID(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
    Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
    networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
    ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
    ncfc.setCollectionResource(collectionResource);
    toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
    // *** Build object to populate the Instance_Group table
    List<IEntityDetails> ncEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder("org.openecomp.groups.NetworkCollection"), TopologyTemplateQuery.newBuilder(SdcTypes.CR).customizationUUID(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)), false);
    List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
    List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<>();
    for (IEntityDetails ncGroupEntity : ncEntityList) {
        NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
        Metadata instanceMetadata = ncGroupEntity.getMetadata();
        networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
        networkInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
        networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
        networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
        networkInstanceGroup.setToscaNodeType(ncGroupEntity.getToscaType());
        // Set
        networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString());
        // Role
        // Set
        networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK);
        // type
        networkInstanceGroup.setCollectionResource(collectionResource);
        // ****Build object to populate
        // Collection_Resource_Instance_Group_Customization table
        CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
        crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
        crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
        crInstanceGroupCustomization.setModelCustomizationUUID(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
        // Loop through the template policy to find the subinterface_network_quantity property name. Then extract
        // the value for it.
        List<IEntityDetails> policyEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder("org.openecomp.policies.scaling.Fixed"), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), true);
        if (policyEntityList != null) {
            for (IEntityDetails policyEntity : policyEntityList) {
                for (String policyNetworkCollection : policyEntity.getTargets()) {
                    if (policyNetworkCollection.equalsIgnoreCase(ncGroupEntity.getName())) {
                        Map<String, Property> propMap = policyEntity.getProperties();
                        if (propMap.get("quantity") != null) {
                            String quantity = getLeafPropertyValue(cnrEntity, getPropertyInput(propMap.get("quantity").toString()));
                            if (quantity != null) {
                                crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
                            }
                        }
                    }
                }
            }
        }
        crInstanceGroupCustomization.setDescription(getLeafPropertyValue(cnrEntity, instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME) + "_network_collection_description"));
        crInstanceGroupCustomization.setFunction(getLeafPropertyValue(cnrEntity, instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME) + "_network_collection_function"));
        crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
        collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
        networkInstanceGroup.setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
        networkInstanceGroupList.add(networkInstanceGroup);
        toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
        List<IEntityDetails> networkEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.VL), TopologyTemplateQuery.newBuilder(SdcTypes.CR).customizationUUID(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)), false);
        List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
        // *****Build object to populate the NetworkResource table
        NetworkResource networkResource = new NetworkResource();
        for (IEntityDetails networkEntity : networkEntityList) {
            String providerNetwork = getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
            if ("true".equalsIgnoreCase(providerNetwork)) {
                networkResource.setNeutronNetworkType(PROVIDER);
            } else {
                networkResource.setNeutronNetworkType(BASIC);
            }
            networkResource.setModelName(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
            networkResource.setModelInvariantUUID(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
            networkResource.setModelUUID(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
            networkResource.setModelVersion(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
            networkResource.setAicVersionMax(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
            TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
            if (tempNetworkLookUp != null) {
                HeatTemplate heatTemplate = heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
                networkResource.setHeatTemplate(heatTemplate);
                networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
            }
            networkResource.setToscaNodeType(networkEntity.getToscaType());
            networkResource.setDescription(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
            networkResource.setOrchestrationMode(HEAT);
            // Collection_Network_Resource_Customization table
            for (IEntityDetails networkMemberEntity : ncGroupEntity.getMemberNodes()) {
                collectionNetworkResourceCustomization.setModelInstanceName(networkMemberEntity.getName());
            }
            collectionNetworkResourceCustomization.setModelCustomizationUUID(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
            collectionNetworkResourceCustomization.setNetworkTechnology(getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
            collectionNetworkResourceCustomization.setNetworkType(getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
            collectionNetworkResourceCustomization.setNetworkRole(getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
            collectionNetworkResourceCustomization.setNetworkScope(getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
            collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
            collectionNetworkResourceCustomization.setNetworkResource(networkResource);
            collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
            collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
        }
    }
    return collectionNetworkResourceCustomization;
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) ArrayList(java.util.ArrayList) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) TempNetworkHeatTemplateLookup(org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkInstanceGroup(org.onap.so.db.catalog.beans.NetworkInstanceGroup) Property(org.onap.sdc.toscaparser.api.Property) HashSet(java.util.HashSet)

Example 9 with CollectionResourceInstanceGroupCustomization

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

the class BBInputSetupTest method testMapCatalogCollectionAndInstanceGroup.

@Test
public void testMapCatalogCollectionAndInstanceGroup() {
    ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
    modelInfoCollection.setCollectionFunction("collectionFunction");
    modelInfoCollection.setCollectionRole("collectionRole");
    modelInfoCollection.setCollectionType("collectionType");
    modelInfoCollection.setDescription("description");
    modelInfoCollection.setModelInvariantUUID("modelInvariantUUID");
    modelInfoCollection.setQuantity(0);
    ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
    modelInfoInstanceGroup.setFunction("function");
    modelInfoInstanceGroup.setInstanceGroupRole("instanceGroupRole");
    modelInfoInstanceGroup.setModelInvariantUUID("modelInvariantUUID");
    modelInfoInstanceGroup.setModelUUID("modelUUID");
    modelInfoInstanceGroup.setType("VNFC");
    modelInfoInstanceGroup.setDescription("description");
    InstanceGroup instanceGroup = new InstanceGroup();
    Collection collection = new Collection();
    collection.setInstanceGroup(instanceGroup);
    CollectionResource collectionResource = new CollectionResource();
    org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
    collectionResource.setToscaNodeType("NetworkCollection");
    collectionResource.setInstanceGroup(catalogInstanceGroup);
    CollectionResourceCustomization collectionCust = new NetworkCollectionResourceCustomization();
    collectionCust.setModelCustomizationUUID("modelCustomizationUUID");
    collectionCust.setCollectionResource(collectionResource);
    Service service = new Service();
    service.getCollectionResourceCustomizations().add(collectionCust);
    ServiceInstance serviceInstance = new ServiceInstance();
    serviceInstance.setCollection(collection);
    List<CollectionResourceInstanceGroupCustomization> instanceGroupCustList = new ArrayList<>();
    CollectionResourceInstanceGroupCustomization instanceGroupCust = new CollectionResourceInstanceGroupCustomization();
    instanceGroupCust.setFunction("function");
    instanceGroupCust.setDescription("description");
    doReturn(modelInfoCollection).when(bbInputSetupMapperLayer).mapCatalogCollectionToCollection(collectionCust, collectionResource);
    doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(collectionCust, catalogInstanceGroup);
    SPY_bbInputSetup.mapCatalogCollection(service, serviceInstance.getCollection(), "modelCustomizationUUID");
    SPY_bbInputSetup.mapCatalogNetworkCollectionInstanceGroup(service, serviceInstance.getCollection().getInstanceGroup(), collectionCust.getModelCustomizationUUID());
    assertThat(collection.getModelInfoCollection(), sameBeanAs(modelInfoCollection));
    assertThat(instanceGroup.getModelInfoInstanceGroup(), sameBeanAs(modelInfoInstanceGroup));
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) ArrayList(java.util.ArrayList) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) Test(org.junit.Test)

Aggregations

CollectionResourceInstanceGroupCustomization (org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization)9 Test (org.junit.Test)6 InstanceGroup (org.onap.so.db.catalog.beans.InstanceGroup)5 NetworkCollectionResourceCustomization (org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization)5 ArrayList (java.util.ArrayList)4 CollectionNetworkResourceCustomization (org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization)4 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)4 ModelInfoInstanceGroup (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)3 CollectionResourceCustomization (org.onap.so.db.catalog.beans.CollectionResourceCustomization)3 Service (org.onap.so.db.catalog.beans.Service)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)2 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)2 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Transactional (javax.transaction.Transactional)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1