Search in sources :

Example 11 with ConfigurationResourceCustomization

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;
}
Also used : ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization)

Example 12 with ConfigurationResourceCustomization

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);
    }
}
Also used : ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization)

Example 13 with ConfigurationResourceCustomization

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);
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) HashMap(java.util.HashMap) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) File(java.io.File) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) Test(org.junit.Test)

Aggregations

ConfigurationResourceCustomization (org.onap.so.db.catalog.beans.ConfigurationResourceCustomization)13 Service (org.onap.so.db.catalog.beans.Service)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)5 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)5 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)5 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)5 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)5 File (java.io.File)4 HashMap (java.util.HashMap)4 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)4 BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys)4 ConfigurationResource (org.onap.so.db.catalog.beans.ConfigurationResource)4 CvnfcConfigurationCustomization (org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization)4 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)4 Vnfc (org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc)3 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)3 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)3 ServiceModel (org.onap.so.bpmn.servicedecomposition.entities.ServiceModel)3 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)3