use of org.onap.so.db.catalog.beans.ConfigurationResourceCustomization in project so by onap.
the class ToscaResourceInstaller method createConfiguration.
protected ConfigurationResourceCustomization createConfiguration(IEntityDetails configEntity, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization, Service service, List<ConfigurationResourceCustomization> configurationResourceList) {
ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization(configEntity, toscaResourceStructure, spResourceCustomization, service);
ConfigurationResource configResource = null;
ConfigurationResource existingConfigResource = findExistingConfiguration(service, configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID), configurationResourceList);
if (existingConfigResource == null) {
configResource = getConfigurationResource(configEntity);
} else {
configResource = existingConfigResource;
}
configCustomizationResource.setConfigurationResource(configResource);
return configCustomizationResource;
}
use of org.onap.so.db.catalog.beans.ConfigurationResourceCustomization in project so by onap.
the class ToscaResourceInstaller method correlateConfigCustomResources.
/*
* ConfigurationResourceCustomization objects have their IDs auto incremented in the database. Unless we know their
* IDs we cannot possibly associate their related records. So these ConfigResourceCustomizations are persisted first
* and subsequently correlated.
*/
protected void correlateConfigCustomResources(Service service) {
/* Assuming that we have only one pair of VRF-VNR */
ConfigurationResourceCustomization vrfConfigCustomResource = null;
ConfigurationResourceCustomization vnrConfigCustomResource = null;
List<ConfigurationResourceCustomization> configCustomList = service.getConfigurationCustomizations();
for (ConfigurationResourceCustomization configResource : configCustomList) {
String nodeType = configResource.getConfigurationResource().getToscaNodeType();
if (NODES_VRF_ENTRY.equalsIgnoreCase(nodeType)) {
vrfConfigCustomResource = configResource;
} else if (VLAN_NETWORK_RECEPTOR.equalsIgnoreCase(nodeType)) {
vnrConfigCustomResource = configResource;
}
}
if (vrfConfigCustomResource != null) {
vrfConfigCustomResource.setConfigResourceCustomization(vnrConfigCustomResource);
configCustomizationRepo.save(vrfConfigCustomResource);
}
if (vnrConfigCustomResource != null) {
vnrConfigCustomResource.setConfigResourceCustomization(vrfConfigCustomResource);
configCustomizationRepo.save(vnrConfigCustomResource);
}
}
use of org.onap.so.db.catalog.beans.ConfigurationResourceCustomization in project so by onap.
the class BBInputSetupTest method testPopulateConfiguration.
@Test
public void testPopulateConfiguration() 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");
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);
ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
service.getConfigurationCustomizations().add(configurationCust);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
ServiceModel serviceModel = new ServiceModel();
serviceModel.setCurrentService(service);
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
configResourceKeys.setVnfcName(vnfcName);
Vnfc vnfc = new Vnfc();
vnfc.setVnfcName(vnfcName);
RequestDetails requestDetails = new RequestDetails();
doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
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);
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, null);
SPY_bbInputSetup.populateConfiguration(parameter);
verify(SPY_bbInputSetup, times(2)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
instanceName = "configurationName2";
resourceId = "resourceId2";
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId2");
parameter.setInstanceName(instanceName);
parameter.setResourceId(resourceId);
Configuration configuration2 = SPY_bbInputSetup.createConfiguration(lookupKeyMap, instanceName, resourceId);
doReturn(configuration2).when(SPY_bbInputSetup).createConfiguration(lookupKeyMap, instanceName, resourceId);
doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys);
SPY_bbInputSetup.populateConfiguration(parameter);
verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys);
}
Aggregations