use of org.onap.sdc.toscaparser.api.elements.Metadata in project so by onap.
the class ToscaResourceInstaller method createPnfResource.
/**
* Construct the {@link PnfResource} from {@link IEntityDetails} object.
*/
private PnfResource createPnfResource(IEntityDetails entity) {
PnfResource pnfResource = new PnfResource();
Metadata metadata = entity.getMetadata();
pnfResource.setModelInvariantUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
pnfResource.setModelVersion(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
pnfResource.setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
pnfResource.setToscaNodeType(entity.getToscaType());
return pnfResource;
}
use of org.onap.sdc.toscaparser.api.elements.Metadata in project so by onap.
the class ToscaResourceInstaller method createService.
protected Service createService(ToscaResourceStructure toscaResourceStructure, ResourceStructure resourceStructure) {
Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
List<Service> services = serviceRepo.findByModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
Service service;
if (!services.isEmpty() && services.size() > 0) {
service = services.get(0);
} else {
service = new Service();
}
if (serviceMetadata != null) {
if (toscaResourceStructure.getServiceVersion() != null) {
service.setModelVersion(toscaResourceStructure.getServiceVersion());
}
service.setServiceType(serviceMetadata.getValue("serviceType"));
service.setServiceRole(serviceMetadata.getValue("serviceRole"));
service.setServiceFunction(serviceMetadata.getValue("serviceFunction"));
service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
if (resourceStructure != null)
service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext());
service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
service.setNamingPolicy(serviceMetadata.getValue("namingPolicy"));
String generateNaming = serviceMetadata.getValue("ecompGeneratedNaming");
Boolean generateNamingValue = null;
if (generateNaming != null) {
generateNamingValue = "true".equalsIgnoreCase(generateNaming);
}
service.setOnapGeneratedNaming(generateNamingValue);
List<Input> serviceInputs = toscaResourceStructure.getSdcCsarHelper().getServiceInputs();
logger.debug("serviceInputs: {} " + serviceInputs);
if (!serviceInputs.isEmpty()) {
serviceInputs.forEach(input -> {
if (CDS_MODEL_NAME.equalsIgnoreCase(input.getName())) {
String value = input.getDefault() != null ? input.getDefault().toString() : null;
service.setBlueprintName(value);
}
if (CDS_MODEL_VERSION.equalsIgnoreCase(input.getName())) {
String value = input.getDefault() != null ? input.getDefault().toString() : null;
service.setBlueprintVersion(value);
}
if (CONTROLLER_ACTOR.equalsIgnoreCase(input.getName())) {
String value = input.getDefault() != null ? input.getDefault().toString() : null;
service.setControllerActor(value);
}
if (SKIP_POST_INST_CONF.equalsIgnoreCase(input.getName())) {
String value = input.getDefault() != null ? input.getDefault().toString() : "false";
service.setSkipPostInstConf(Boolean.valueOf(value));
}
});
}
}
toscaResourceStructure.setCatalogService(service);
return service;
}
use of org.onap.sdc.toscaparser.api.elements.Metadata 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.sdc.toscaparser.api.elements.Metadata in project so by onap.
the class ToscaResourceInstaller method createFabricConfiguration.
protected ConfigurationResource createFabricConfiguration(IEntityDetails fabricEntity, ToscaResourceStructure toscaResourceStructure) {
Metadata fabricMetadata = fabricEntity.getMetadata();
ConfigurationResource configResource = new ConfigurationResource();
configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
configResource.setToscaNodeType(fabricEntity.getToscaType());
return configResource;
}
use of org.onap.sdc.toscaparser.api.elements.Metadata in project so by onap.
the class ToscaResourceInstaller method setHeatInformationForVfModule.
protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization, Metadata vfMetadata) {
Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream().filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID().equalsIgnoreCase(vfMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))).findFirst();
if (matchingObject.isPresent()) {
List<HeatFiles> heatFilesList = new ArrayList<>();
List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<>();
List<HeatTemplate> heatChildTemplates = new ArrayList<>();
HeatTemplate parentHeatTemplate = new HeatTemplate();
String parentArtifactType = null;
Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
List<HeatTemplate> childNestedHeatTemplates = new ArrayList<>();
if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact, childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
}
if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
if (!childNestedHeatTemplates.isEmpty()) {
if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
} else {
heatChildTemplates.add(childNestedHeatTemplates.get(0));
}
}
}
}
if (!heatFilesList.isEmpty()) {
vfModule.setHeatFiles(heatFilesList);
}
// Set all Child Templates related to HEAT_VOLUME
if (!volumeHeatChildTemplates.isEmpty()) {
if (vfModule.getVolumeHeatTemplate() != null) {
vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
} else {
logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
}
}
// Set all Child Templates related to HEAT
if (!heatChildTemplates.isEmpty()) {
if (vfModule.getModuleHeatTemplate() != null) {
vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
} else {
logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
}
}
}
}
Aggregations