Search in sources :

Example 1 with CollectionNetworkResourceCustomization

use of org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization 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 CollectionNetworkResourceCustomization

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

the class BBInputSetupMapperLayerTest method testMapCollectionNetworkResourceCustToNetworkResourceCust.

@Test
public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
    String modelCustomizationUUID = "modelCustomizationUUID";
    String modelInstanceName = "modelInstanceName";
    String networkRole = "networkRole";
    String networkScope = "networkScope";
    String networkTechnology = "networkTechnology";
    String networkType = "networkType";
    NetworkResourceCustomization expected = new NetworkResourceCustomization();
    expected.setModelCustomizationUUID(modelCustomizationUUID);
    expected.setModelInstanceName(modelInstanceName);
    expected.setNetworkRole(networkRole);
    expected.setNetworkScope(networkScope);
    expected.setNetworkTechnology(networkTechnology);
    expected.setNetworkType(networkType);
    CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
    collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
    collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
    collectionNetworkResourceCust.setNetworkRole(networkRole);
    collectionNetworkResourceCust.setNetworkScope(networkScope);
    collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
    collectionNetworkResourceCust.setNetworkType(networkType);
    NetworkResourceCustomization actual = bbInputSetupMapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
    assertThat(actual, sameBeanAs(expected));
}
Also used : CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) Test(org.junit.Test)

Example 3 with CollectionNetworkResourceCustomization

use of org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization 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 4 with CollectionNetworkResourceCustomization

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

the class NetworkCollectionCatalogDbQueryTest method CollectionNetworkResourceCustomizationTest.

@Test
public void CollectionNetworkResourceCustomizationTest() {
    String modelCustId = "1a61be4b-3378-4c9a-91c8-c919519b2d01";
    CollectionNetworkResourceCustomization collectionNetworkCust = client.getCollectionNetworkResourceCustomizationByID(modelCustId);
    assertNotNull(collectionNetworkCust);
    logger.debug(collectionNetworkCust.getModelCustomizationUUID());
}
Also used : CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) Test(org.junit.Test) CatalogDbAdapterBaseTest(org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)

Example 5 with CollectionNetworkResourceCustomization

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

the class MsoNetworkAdapterImpl method networkCheck.

private NetworkResource networkCheck(long startTime, String networkType, String modelCustomizationUuid, String networkName, String physicalNetworkName, List<Integer> vlans, List<RouteTarget> routeTargets, String cloudSiteId, CloudSite cloudSite) throws NetworkException {
    // Retrieve the Network Resource definition
    NetworkResource networkResource = null;
    NetworkResourceCustomization networkCust = null;
    CollectionNetworkResourceCustomization collectionNetworkCust = null;
    if (commonUtils.isNullOrEmpty(modelCustomizationUuid)) {
        if (!commonUtils.isNullOrEmpty(networkType)) {
            networkResource = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
        }
    } else {
        networkCust = networkCustomRepo.findOneByModelCustomizationUUID(modelCustomizationUuid);
        if (networkCust == null) {
            collectionNetworkCust = collectionNetworkCustomRepo.findOneByModelCustomizationUUID(modelCustomizationUuid);
        }
    }
    if (networkCust != null) {
        logger.debug("Got Network Customization definition from Catalog: {}", networkCust);
        networkResource = networkCust.getNetworkResource();
    } else if (collectionNetworkCust != null) {
        logger.debug("Retrieved Collection Network Resource Customization from Catalog: {}", collectionNetworkCust);
        networkResource = collectionNetworkCust.getNetworkResource();
    }
    if (networkResource == null) {
        String error = String.format("Create/UpdateNetwork: Unable to get network resource with NetworkType: %s or ModelCustomizationUUID:%s", networkType, modelCustomizationUuid);
        logger.error(LoggingAnchor.THREE, MessageEnum.RA_UNKOWN_PARAM, ErrorCode.DataError.getValue(), error);
        throw new NetworkException(error, MsoExceptionCategory.USERDATA);
    }
    logger.debug(LOG_DEBUG_MSG, networkResource);
    String mode = networkResource.getOrchestrationMode();
    NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType());
    // All Networks are orchestrated via HEAT or Neutron
    if (!("HEAT".equals(mode) || NEUTRON_MODE.equals(mode))) {
        String error = "CreateNetwork: Configuration Error: Network Type = " + networkType;
        logger.error(LoggingAnchor.THREE, MessageEnum.RA_NETWORK_ORCHE_MODE_NOT_SUPPORT, ErrorCode.DataError.getValue(), error);
        throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
    }
    MavenLikeVersioning osV = new MavenLikeVersioning();
    osV.setVersion(cloudSite.getCloudVersion());
    if ((osV.isMoreRecentThan(networkResource.getAicVersionMin()) || // os
    osV.isTheSameVersion(networkResource.getAicVersionMin())) && // min
    (osV.isTheSameVersion(networkResource.getAicVersionMax()) || // os <= max
    !(osV.isMoreRecentThan(networkResource.getAicVersionMax())))) {
        logger.debug("Network Type:{} VersionMin:{} VersionMax:{} supported on Cloud:{} with AIC_Version:{}", networkType, networkResource.getAicVersionMin(), networkResource.getAicVersionMax(), cloudSiteId, cloudSite.getCloudVersion());
    } else {
        String error = String.format("Network Type:%s Version_Min:%s Version_Max:%s not supported on Cloud:%s with AIC_Version:%s", networkType, networkResource.getAicVersionMin(), networkResource.getAicVersionMax(), cloudSiteId, cloudSite.getCloudVersion());
        logger.error(LoggingAnchor.THREE, MessageEnum.RA_CONFIG_EXC, ErrorCode.DataError.getValue(), error);
        throw new NetworkException(error, MsoExceptionCategory.USERDATA);
    }
    // Validate the Network parameters.
    String missing = validateNetworkParams(neutronNetworkType, networkName, physicalNetworkName, vlans, routeTargets);
    if (!missing.isEmpty()) {
        String error = "Create Network: Missing parameters: " + missing;
        logger.error(LoggingAnchor.THREE, MessageEnum.RA_MISSING_PARAM, ErrorCode.DataError.getValue(), error);
        throw new NetworkException(error, MsoExceptionCategory.USERDATA);
    }
    return networkResource;
}
Also used : NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) NetworkType(org.onap.so.openstack.utils.MsoNeutronUtils.NetworkType) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) NetworkException(org.onap.so.adapters.network.exceptions.NetworkException) MavenLikeVersioning(org.onap.so.db.catalog.utils.MavenLikeVersioning)

Aggregations

CollectionNetworkResourceCustomization (org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization)11 Test (org.junit.Test)7 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)6 ArrayList (java.util.ArrayList)4 CollectionResourceInstanceGroupCustomization (org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization)4 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)3 InstanceGroup (org.onap.so.db.catalog.beans.InstanceGroup)3 NetworkCollectionResourceCustomization (org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization)3 Service (org.onap.so.db.catalog.beans.Service)3 File (java.io.File)2 CatalogDbAdapterBaseTest (org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)2 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)2 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)2 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)2 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)2 BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys)2 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)2 NetworkResource (org.onap.so.db.catalog.beans.NetworkResource)2 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)2 HashSet (java.util.HashSet)1