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);
}
}
}
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));
}
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);
}
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());
}
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;
}
Aggregations