use of org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup in project so by onap.
the class TempNetworkHeatTemplateLookupTest method tempNetworkHeatTemplateLookupDataTest.
@Test
public final void tempNetworkHeatTemplateLookupDataTest() {
TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup = new TempNetworkHeatTemplateLookup();
tempNetworkHeatTemplateLookup.setAicVersionMax("aicVersionMax");
assertTrue(tempNetworkHeatTemplateLookup.getAicVersionMax().equalsIgnoreCase("aicVersionMax"));
tempNetworkHeatTemplateLookup.setAicVersionMin("aicVersionMin");
assertTrue(tempNetworkHeatTemplateLookup.getAicVersionMin().equalsIgnoreCase("aicVersionMin"));
tempNetworkHeatTemplateLookup.setHeatTemplateArtifactUuid("heatTemplateArtifactUuid");
assertTrue(tempNetworkHeatTemplateLookup.getHeatTemplateArtifactUuid().equalsIgnoreCase("heatTemplateArtifactUuid"));
tempNetworkHeatTemplateLookup.setNetworkResourceModelName("networkResourceModelName");
assertTrue(tempNetworkHeatTemplateLookup.getNetworkResourceModelName().equalsIgnoreCase("networkResourceModelName"));
// assertTrue(tempNetworkHeatTemplateLookup.toString() != null);
}
use of org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup 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;
}
use of org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup in project so by onap.
the class ToscaResourceInstaller method processNetworks.
protected void processNetworks(ToscaResourceStructure toscaResourceStruct, Service service) throws ArtifactInstallerException {
List<IEntityDetails> vlEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.VL), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
if (vlEntityList != null) {
for (IEntityDetails vlEntity : vlEntityList) {
String networkResourceModelName = vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(networkResourceModelName);
if (tempNetworkLookUp != null) {
HeatTemplate heatTemplate = heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
if (heatTemplate != null) {
NetworkResourceCustomization networkCustomization = createNetwork(vlEntity, toscaResourceStruct, heatTemplate, tempNetworkLookUp.getAicVersionMax(), tempNetworkLookUp.getAicVersionMin(), service);
// only insert unique entries
if (!service.getNetworkCustomizations().contains(networkCustomization)) {
service.getNetworkCustomizations().add(networkCustomization);
}
} else {
throw new ArtifactInstallerException("No HeatTemplate found for artifactUUID: " + tempNetworkLookUp.getHeatTemplateArtifactUuid());
}
} else {
NetworkResourceCustomization networkCustomization = createNetwork(vlEntity, toscaResourceStruct, null, null, null, service);
networkCustomization.setResourceInput(getResourceInput(toscaResourceStruct, networkCustomization.getModelCustomizationUUID()));
service.getNetworkCustomizations().add(networkCustomization);
logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for {}", networkResourceModelName);
}
}
}
}
use of org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup in project so by onap.
the class ToscaResourceStructureTest method toscaResourceStructureBeanTest.
@Test
public void toscaResourceStructureBeanTest() {
artifactInfo = mock(ArtifactInfoImpl.class);
sdcCsarHelper = mock(SdcCsarHelperImpl.class);
toscaResourceStructure = new ToscaResourceStructure();
toscaResourceStructure.setHeatTemplateUUID("heatTemplateUUID");
toscaResourceStructure.setAllottedList(new ArrayList<NodeTemplate>());
toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
toscaResourceStructure.setServiceMetadata(new Metadata(new HashMap<>()));
toscaResourceStructure.setCatalogService(new Service());
toscaResourceStructure.setNetworkTypes(new ArrayList<>());
toscaResourceStructure.setVfTypes(new ArrayList<>());
toscaResourceStructure.setCatalogResourceCustomization(new AllottedResourceCustomization());
toscaResourceStructure.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
toscaResourceStructure.setCatalogNetworkResource(new NetworkResource());
toscaResourceStructure.setCatalogVfModule(new VfModule());
toscaResourceStructure.setVnfResourceCustomization(new VnfResourceCustomization());
toscaResourceStructure.setVfModuleCustomization(new VfModuleCustomization());
toscaResourceStructure.setAllottedResource(new AllottedResource());
toscaResourceStructure.setAllottedResourceCustomization(new AllottedResourceCustomization());
toscaResourceStructure.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
toscaResourceStructure.setHeatFilesUUID("heatFilesUUID");
toscaResourceStructure.setToscaArtifact(artifactInfo);
toscaResourceStructure.setToscaCsar(new ToscaCsar());
toscaResourceStructure.setVolHeatTemplateUUID("volHeatTemplateUUID");
toscaResourceStructure.setEnvHeatTemplateUUID("envHeatTemplateUUID");
toscaResourceStructure.setServiceVersion("serviceVersion");
toscaResourceStructure.setWorkloadPerformance("workloadPerformance");
toscaResourceStructure.setVfModule(new VfModule());
toscaResourceStructure.setTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
toscaResourceStructure.setSuccessfulDeployment();
assertEquals("heatTemplateUUID", toscaResourceStructure.getHeatTemplateUUID());
assertThat(toscaResourceStructure.getAllottedList(), sameBeanAs(new ArrayList<NodeTemplate>()));
assertEquals(sdcCsarHelper, toscaResourceStructure.getSdcCsarHelper());
assertThat(toscaResourceStructure.getServiceMetadata(), sameBeanAs(new Metadata(new HashMap<>())));
assertThat(toscaResourceStructure.getCatalogService(), sameBeanAs(new Service()));
assertThat(toscaResourceStructure.getNetworkTypes(), sameBeanAs(new ArrayList<>()));
assertThat(toscaResourceStructure.getVfTypes(), sameBeanAs(new ArrayList<>()));
assertThat(toscaResourceStructure.getCatalogResourceCustomization(), sameBeanAs(new AllottedResourceCustomization()));
assertThat(toscaResourceStructure.getCatalogNetworkResourceCustomization(), sameBeanAs(new NetworkResourceCustomization()));
assertThat(toscaResourceStructure.getCatalogNetworkResource(), sameBeanAs(new NetworkResource()));
assertThat(toscaResourceStructure.getCatalogVfModule(), sameBeanAs(new VfModule()));
assertThat(toscaResourceStructure.getVnfResourceCustomization(), sameBeanAs(new VnfResourceCustomization()));
assertThat(toscaResourceStructure.getVfModuleCustomization(), sameBeanAs(new VfModuleCustomization()));
assertThat(toscaResourceStructure.getAllottedResource(), sameBeanAs(new AllottedResource()));
assertThat(toscaResourceStructure.getAllottedResourceCustomization(), sameBeanAs(new AllottedResourceCustomization()));
assertThat(toscaResourceStructure.getCatalogTempNetworkHeatTemplateLookup(), sameBeanAs(new TempNetworkHeatTemplateLookup()));
assertEquals("heatFilesUUID", toscaResourceStructure.getHeatFilesUUID());
assertEquals(artifactInfo, toscaResourceStructure.getToscaArtifact());
assertThat(toscaResourceStructure.getToscaCsar(), sameBeanAs(new ToscaCsar()));
assertEquals("volHeatTemplateUUID", toscaResourceStructure.getVolHeatTemplateUUID());
assertEquals("envHeatTemplateUUID", toscaResourceStructure.getEnvHeatTemplateUUID());
assertEquals("serviceVersion", toscaResourceStructure.getServiceVersion());
assertEquals("workloadPerformance", toscaResourceStructure.getWorkloadPerformance());
assertThat(toscaResourceStructure.getVfModule(), sameBeanAs(new VfModule()));
assertThat(toscaResourceStructure.getTempNetworkHeatTemplateLookup(), sameBeanAs(new TempNetworkHeatTemplateLookup()));
assertEquals(true, toscaResourceStructure.isDeployedSuccessfully());
}
Aggregations