use of org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization in project so by onap.
the class ToscaResourceInstaller method createVFModuleResource.
protected VfModuleCustomization createVFModuleResource(IEntityDetails vfModuleEntityDetails, ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet, List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom) {
VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource, vfModuleData.getVfModuleModelCustomizationUUID());
if (vfModuleCustomization == null) {
VfModule vfModule = findExistingVfModule(vnfResource, vfModuleEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
Metadata vfMetadata = vfModuleEntityDetails.getMetadata();
if (vfModule == null)
vfModule = createVfModule(vfModuleEntityDetails, toscaResourceStructure, vfModuleData, vfMetadata);
vfModuleCustomization = createVfModuleCustomization(vfModuleEntityDetails, toscaResourceStructure, vfModule, vfModuleData);
vfModuleCustomization.setVnfCustomization(vnfResource);
setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization, vfMetadata);
vfModuleCustomization.setVfModule(vfModule);
vfModule.getVfModuleCustomization().add(vfModuleCustomization);
vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
} else {
vfResourceStructure.setAlreadyDeployed(true);
}
// ******************************************************************************************************************
// * Extract VFC's and CVFC's then add them to VFModule
// ******************************************************************************************************************
List<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations = new ArrayList<>();
List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<>();
Set<VnfcCustomization> vnfcCustomizations = new HashSet<>();
// Only set the CVNFC if this vfModule group is a member of it.
List<IEntityDetails> groupMembers = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder("org.openecomp.groups.VfModule").uUID(vfModuleCustomization.getVfModule().getModelUUID()), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
String vfModuleMemberName = null;
// Extract CVFC lists
List<IEntityDetails> cvnfcEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.CVFC), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
for (IEntityDetails cvfcEntity : cvnfcEntityList) {
boolean cvnfcVfModuleNameMatch = false;
for (IEntityDetails entity : groupMembers) {
List<IEntityDetails> groupMembersNodes = entity.getMemberNodes();
for (IEntityDetails groupMember : groupMembersNodes) {
vfModuleMemberName = groupMember.getName();
if (vfModuleMemberName.equalsIgnoreCase(cvfcEntity.getName())) {
cvnfcVfModuleNameMatch = true;
break;
}
}
}
if (vfModuleMemberName != null && cvnfcVfModuleNameMatch) {
// Extract associated VFC - Should always be just one
List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.VFC), TopologyTemplateQuery.newBuilder(SdcTypes.CVFC).customizationUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)), false);
for (IEntityDetails vfcEntity : vfcEntityList) {
VnfcCustomization vnfcCustomization = new VnfcCustomization();
VnfcCustomization existingVnfcCustomization = null;
existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
if (existingVnfcCustomization == null) {
vnfcCustomization = new VnfcCustomization();
} else {
vnfcCustomization = existingVnfcCustomization;
}
// Only Add Abstract VNFC's to our DB, ignore all others
if (existingVnfcCustomization == null && vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) {
vnfcCustomization.setModelCustomizationUUID(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
vnfcCustomization.setModelInstanceName(vfcEntity.getName());
vnfcCustomization.setModelInvariantUUID(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
vnfcCustomization.setModelName(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
vnfcCustomization.setModelUUID(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
vnfcCustomization.setModelVersion(testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
vnfcCustomization.setDescription(testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
vnfcCustomization.setToscaNodeType(testNull(vfcEntity.getToscaType()));
vnfcCustomizations.add(vnfcCustomization);
existingVnfcSet.add(vnfcCustomization);
}
// skip adding that record to our DB.
if (vnfcCustomization.getModelCustomizationUUID() != null) {
CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
cvnfcCustomization.setModelCustomizationUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
cvnfcCustomization.setModelInstanceName(cvfcEntity.getName());
cvnfcCustomization.setModelInvariantUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
cvnfcCustomization.setModelName(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
cvnfcCustomization.setModelUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
cvnfcCustomization.setModelVersion(testNull(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
cvnfcCustomization.setDescription(testNull(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
cvnfcCustomization.setToscaNodeType(testNull(cvfcEntity.getToscaType()));
if (existingVnfcCustomization != null) {
cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
} else {
cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
}
cvnfcCustomization.setNfcFunction(getLeafPropertyValue(cvfcEntity, "nfc_function"));
cvnfcCustomization.setNfcNamingCode(getLeafPropertyValue(cvfcEntity, "nfc_naming_code"));
cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
// *****************************************************************************************************************************************
// * Extract Fabric Configuration
// *****************************************************************************************************************************************
List<IEntityDetails> fabricEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.CONFIGURATION), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
for (IEntityDetails fabricEntity : fabricEntityList) {
List<RequirementAssignment> requirements = fabricEntity.getRequirements();
for (RequirementAssignment requirement : requirements) {
if (requirement.getNodeTemplateName().equals(cvfcEntity.getName())) {
ConfigurationResource fabricConfig = null;
ConfigurationResource existingConfig = findExistingConfiguration(existingCvnfcConfigurationCustom, fabricEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
if (existingConfig == null) {
fabricConfig = createFabricConfiguration(fabricEntity, toscaResourceStructure);
} else {
fabricConfig = existingConfig;
}
CvnfcConfigurationCustomization cvnfcConfigurationCustomization = createCvnfcConfigurationCustomization(fabricEntity, toscaResourceStructure, vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfModuleMemberName);
cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
existingCvnfcConfigurationCustom.add(cvnfcConfigurationCustomization);
}
}
}
cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
cvnfcCustomizations.add(cvnfcCustomization);
existingCvnfcSet.add(cvnfcCustomization);
}
}
}
}
vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
return vfModuleCustomization;
}
use of org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization in project so by onap.
the class BBInputSetupMapperLayerTest method testmapCatalogConfigurationToFabricConfiguration.
@Test
public void testmapCatalogConfigurationToFabricConfiguration() {
String modelCustUUID = "modelCustomizationUUID";
String modelInvariantUUID = "modelInvariantUUID";
String modelVersionUUID = "modelUUID";
String policyName = "policyName";
ModelInfoConfiguration expected = new ModelInfoConfiguration();
expected.setModelCustomizationId(modelCustUUID);
expected.setModelInvariantId(modelInvariantUUID);
expected.setModelVersionId(modelVersionUUID);
expected.setPolicyName(policyName);
CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
fabricCustomization.setPolicyName(policyName);
fabricCustomization.setModelCustomizationUUID(modelCustUUID);
ConfigurationResource configurationResource = new ConfigurationResource();
configurationResource.setModelUUID(modelVersionUUID);
configurationResource.setModelInvariantUUID(modelInvariantUUID);
fabricCustomization.setConfigurationResource(configurationResource);
ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
assertThat(actual, sameBeanAs(expected));
}
use of org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization in project so by onap.
the class UserParamsServiceTraversal method setConfigurationWorkFlowTypeToResourceList.
private void setConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Resource vnfResource, Service validate, Vnfs vnf, VfModules vfModule, Resource resource) {
if (!vnfCustomizationUUID.isEmpty() && !vfModuleCustomizationUUID.isEmpty()) {
List<CvnfcConfigurationCustomization> configs = traverseCatalogDbForConfiguration(validate.getModelInfo().getModelVersionId());
for (CvnfcConfigurationCustomization config : configs) {
Resource configResource = new Resource(WorkflowType.CONFIGURATION, config.getConfigurationResource().getModelUUID(), false, vnfResource);
resource.setVnfCustomizationId(vnf.getModelInfo().getModelCustomizationId());
resource.setVfModuleCustomizationId(vfModule.getModelInfo().getModelCustomizationId());
resourceList.add(configResource);
}
}
}
use of org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization in project so by onap.
the class BBInputSetupTest method testPopulateFabricConfiguration.
@Test
public void testPopulateFabricConfiguration() throws JsonParseException, JsonMappingException, IOException {
String instanceName = "configurationName";
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationUuid("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
ServiceInstance serviceInstance = new ServiceInstance();
Configuration configuration = new Configuration();
configuration.setConfigurationId("configurationId");
configuration.setConfigurationName("configurationName");
configuration.setConfigurationSubType("Fabric Config");
serviceInstance.getConfigurations().add(configuration);
String resourceId = "configurationId";
String vnfcName = "vnfcName";
// Mock service
Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
configResourceKeys.setVnfcName(vnfcName);
Vnfc vnfc = new Vnfc();
vnfc.setVnfcName(vnfcName);
RequestDetails requestDetails = new RequestDetails();
ServiceModel serviceModel = new ServiceModel();
serviceModel.setCurrentService(service);
CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
ConfigurationResource configurationResource = new ConfigurationResource();
configurationResource.setModelUUID("modelUUID");
configurationResource.setModelInvariantUUID("modelInvariantUUID");
vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
doReturn(null).when(SPY_bbInputSetup).findConfigurationResourceCustomization(modelInfo, service);
doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName);
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setInstanceName(instanceName).setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails).setServiceModel(serviceModel).build();
SPY_bbInputSetup.populateConfiguration(parameter);
verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
}
use of org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization in project so by onap.
the class BBInputSetup method mapCatalogConfiguration.
protected void mapCatalogConfiguration(Configuration configuration, ModelInfo modelInfo, Service service, ConfigurationResourceKeys configurationResourceKeys) {
ConfigurationResourceCustomization configurationResourceCustomization = findConfigurationResourceCustomization(modelInfo, service);
CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = findVnfVfmoduleCvnfcConfigurationCustomization(service.getModelUUID(), configurationResourceKeys.getVfModuleCustomizationUUID(), configurationResourceKeys.getVnfResourceCustomizationUUID(), configurationResourceKeys.getCvnfcCustomizationUUID(), configurationResourceCustomization);
if (configurationResourceCustomization != null && vnfVfmoduleCvnfcConfigurationCustomization != null) {
configuration.setModelInfoConfiguration(this.mapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization, vnfVfmoduleCvnfcConfigurationCustomization));
} else {
logger.debug("for Fabric configuration mapping by VF MODULE CUST UUID: " + configurationResourceKeys.getVfModuleCustomizationUUID());
vnfVfmoduleCvnfcConfigurationCustomization = findVnfVfmoduleCvnfcConfigurationCustomization(service.getModelUUID(), configurationResourceKeys.getVnfResourceCustomizationUUID(), configurationResourceKeys.getVfModuleCustomizationUUID(), configurationResourceKeys.getCvnfcCustomizationUUID());
if (vnfVfmoduleCvnfcConfigurationCustomization != null) {
configuration.setModelInfoConfiguration(this.mapperLayer.mapCatalogConfigurationToConfiguration(vnfVfmoduleCvnfcConfigurationCustomization));
}
}
}
Aggregations