Search in sources :

Example 1 with ConfigurationResourceCustomization

use of org.onap.so.db.catalog.beans.ConfigurationResourceCustomization in project so by onap.

the class ToscaResourceInstaller method processServiceProxyAndConfiguration.

protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
    List<IEntityDetails> spEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
    List<IEntityDetails> configEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.CONFIGURATION), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
    List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<>();
    List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<>();
    ServiceProxyResourceCustomization serviceProxy = null;
    if (spEntityList != null) {
        for (IEntityDetails spEntity : spEntityList) {
            serviceProxy = createServiceProxy(spEntity, service, toscaResourceStruct);
            serviceProxyList.add(serviceProxy);
            for (IEntityDetails configEntity : configEntityList) {
                List<RequirementAssignment> requirements = configEntity.getRequirements();
                for (RequirementAssignment requirement : requirements) {
                    if (requirement.getNodeTemplateName().equals(spEntity.getName())) {
                        ConfigurationResourceCustomization configurationResource = createConfiguration(configEntity, toscaResourceStruct, serviceProxy, service, configurationResourceList);
                        Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream().filter(configurationResourceCustomization -> configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID())).filter(configurationResourceCustomization -> configurationResourceCustomization.getModelInstanceName().equals(configurationResource.getModelInstanceName())).findFirst();
                        if (!matchingObject.isPresent()) {
                            configurationResourceList.add(configurationResource);
                        }
                        break;
                    }
                }
            }
        }
    }
    service.setConfigurationCustomizations(configurationResourceList);
    service.setServiceProxyCustomizations(serviceProxyList);
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) NetworkInstanceGroup(org.onap.so.db.catalog.beans.NetworkInstanceGroup) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) Property(org.onap.sdc.toscaparser.api.Property) VfModule(org.onap.so.db.catalog.beans.VfModule) PnfResourceRepository(org.onap.so.db.catalog.data.repository.PnfResourceRepository) Autowired(org.springframework.beans.factory.annotation.Autowired) WatchdogComponentDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository) EntityQueryBuilder(org.onap.sdc.tosca.parser.elements.queries.EntityQuery.EntityQueryBuilder) Matcher(java.util.regex.Matcher) VnfcCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository) Service(org.onap.so.db.catalog.beans.Service) VFModuleRepository(org.onap.so.db.catalog.data.repository.VFModuleRepository) Map(java.util.Map) ResourceStructure(org.onap.so.asdc.installer.ResourceStructure) EntityQuery(org.onap.sdc.tosca.parser.elements.queries.EntityQuery) VFCInstanceGroup(org.onap.so.db.catalog.beans.VFCInstanceGroup) ExternalServiceToInternalServiceRepository(org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) VnfcInstanceGroupCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) WatchdogDistributionStatus(org.onap.so.db.request.beans.WatchdogDistributionStatus) VfModuleArtifact(org.onap.so.asdc.installer.VfModuleArtifact) SdcTypes(org.onap.sdc.tosca.parser.enums.SdcTypes) HeatFiles(org.onap.so.db.catalog.beans.HeatFiles) HeatEnvironmentRepository(org.onap.so.db.catalog.data.repository.HeatEnvironmentRepository) Set(java.util.Set) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ASDCConfiguration(org.onap.so.asdc.client.ASDCConfiguration) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) NodeTemplate(org.onap.sdc.toscaparser.api.NodeTemplate) AllottedResource(org.onap.so.db.catalog.beans.AllottedResource) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) NetworkResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository) CollectionUtils(org.springframework.util.CollectionUtils) ConfigurationResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository) NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) InstanceGroupRepository(org.onap.so.db.catalog.data.repository.InstanceGroupRepository) CollectionResourceRepository(org.onap.so.db.catalog.data.repository.CollectionResourceRepository) IVfModuleData(org.onap.so.asdc.installer.IVfModuleData) ASDCElementInfo(org.onap.so.asdc.installer.ASDCElementInfo) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) VFModuleCustomizationRepository(org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository) TopologyTemplateQueryBuilder(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery.TopologyTemplateQueryBuilder) InstanceGroupType(org.onap.so.db.catalog.beans.InstanceGroupType) AllottedResourceRepository(org.onap.so.db.catalog.data.repository.AllottedResourceRepository) VnfResource(org.onap.so.db.catalog.beans.VnfResource) HeatFilesRepository(org.onap.so.db.catalog.data.repository.HeatFilesRepository) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) ErrorCode(org.onap.logging.filter.base.ErrorCode) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) ISdcCsarHelper(org.onap.sdc.tosca.parser.api.ISdcCsarHelper) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment) PnfResource(org.onap.so.db.catalog.beans.PnfResource) ToscaCsarRepository(org.onap.so.db.catalog.data.repository.ToscaCsarRepository) TopologyTemplateQuery(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) PnfResourceStructure(org.onap.so.asdc.installer.PnfResourceStructure) IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) CapabilityAssignment(org.onap.sdc.toscaparser.api.CapabilityAssignment) Input(org.onap.sdc.toscaparser.api.parameters.Input) MessageEnum(org.onap.so.logger.MessageEnum) SubType(org.onap.so.db.catalog.beans.SubType) NetworkResourceRepository(org.onap.so.db.catalog.data.repository.NetworkResourceRepository) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) WatchdogServiceModVerIdLookupRepository(org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) YamlEditor(org.onap.so.asdc.util.YamlEditor) TempNetworkHeatTemplateRepository(org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository) Collectors(java.util.stream.Collectors) List(java.util.List) ServiceInfo(org.onap.so.db.catalog.beans.ServiceInfo) Optional(java.util.Optional) LoggingAnchor(org.onap.so.logger.LoggingAnchor) Pattern(java.util.regex.Pattern) BigDecimalVersion(org.onap.so.asdc.installer.BigDecimalVersion) WatchdogDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository) TempNetworkHeatTemplateLookup(org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup) ServiceArtifact(org.onap.so.db.catalog.beans.ServiceArtifact) WatchdogServiceModVerIdLookup(org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup) HashMap(java.util.HashMap) CvnfcCustomizationRepository(org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository) ServiceProxyResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) ConfigurationResourceRepository(org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository) HashSet(java.util.HashSet) AllottedResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository) PnfCustomizationRepository(org.onap.so.db.catalog.data.repository.PnfCustomizationRepository) CollectionResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository) DistributionStatusEnum(org.onap.sdc.utils.DistributionStatusEnum) WatchdogComponentDistributionStatus(org.onap.so.db.request.beans.WatchdogComponentDistributionStatus) Logger(org.slf4j.Logger) EntityTemplateType(org.onap.sdc.tosca.parser.enums.EntityTemplateType) IStatusData(org.onap.sdc.api.notification.IStatusData) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) VnfResourceRepository(org.onap.so.db.catalog.data.repository.VnfResourceRepository) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) HeatTemplateRepository(org.onap.so.db.catalog.data.repository.HeatTemplateRepository) VfModuleStructure(org.onap.so.asdc.installer.VfModuleStructure) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) Component(org.springframework.stereotype.Component) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) ServiceRepository(org.onap.so.db.catalog.data.repository.ServiceRepository) SdcPropertyNames(org.onap.sdc.tosca.parser.impl.SdcPropertyNames) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization) GetInput(org.onap.sdc.toscaparser.api.functions.GetInput) Collections(java.util.Collections) WorkflowResource(org.onap.so.asdc.installer.bpmn.WorkflowResource) Transactional(org.springframework.transaction.annotation.Transactional) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) ArrayList(java.util.ArrayList) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment)

Example 2 with ConfigurationResourceCustomization

use of org.onap.so.db.catalog.beans.ConfigurationResourceCustomization in project so by onap.

the class ToscaResourceInstaller method getConfigurationResourceCustomization.

protected ConfigurationResourceCustomization getConfigurationResourceCustomization(IEntityDetails configEntity, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization, Service service) {
    Metadata metadata = configEntity.getMetadata();
    ConfigurationResource configResource = getConfigurationResource(configEntity);
    ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
    Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
    configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
    configCustomizationResource.setModelInstanceName(configEntity.getName());
    configCustomizationResource.setFunction(getLeafPropertyValue(configEntity, "function"));
    configCustomizationResource.setRole(getLeafPropertyValue(configEntity, "role"));
    configCustomizationResource.setType(getLeafPropertyValue(configEntity, "type"));
    configCustomizationResource.setServiceProxyResourceCustomization(spResourceCustomization);
    configCustomizationResource.setConfigurationResource(configResource);
    configCustomizationResource.setService(service);
    configResourceCustomizationSet.add(configCustomizationResource);
    configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
    return configCustomizationResource;
}
Also used : Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) HashSet(java.util.HashSet)

Example 3 with ConfigurationResourceCustomization

use of org.onap.so.db.catalog.beans.ConfigurationResourceCustomization in project so by onap.

the class BBInputSetupTest method testPopulateConfigurationReplace.

@Test
public void testPopulateConfigurationReplace() 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.setNewService(service);
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    configResourceKeys.setVnfcName(vnfcName);
    Vnfc vnfc = new Vnfc();
    vnfc.setVnfcName(vnfcName);
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
    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).setIsReplace(true).build();
    SPY_bbInputSetup.populateConfiguration(parameter);
    configResourceKeys.setVnfResourceCustomizationUUID("my-test-uuid");
    verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, 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) 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)

Example 4 with ConfigurationResourceCustomization

use of org.onap.so.db.catalog.beans.ConfigurationResourceCustomization in project so by onap.

the class BBInputSetupPopulateMethodsTest method test_getGBBMacro_populateConfiguration_shouldBeCalled.

@Test
public void test_getGBBMacro_populateConfiguration_shouldBeCalled() throws Exception {
    // given
    String requestAction = "createInstance";
    Service service = Mockito.mock(Service.class);
    GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
    GenericVnf aaiVnf = new GenericVnf();
    aaiVnf.setModelCustomizationId("modelCustId");
    Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
    executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName("AssignFabricConfigurationBB").setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
    Configuration configuration = new Configuration();
    configuration.setConfigurationId("configurationId");
    gBB.getServiceInstance().getConfigurations().add(configuration);
    List<ConfigurationResourceCustomization> configurationCustList = new ArrayList<>();
    ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
    configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
    configurationCustList.add(configurationCust);
    doReturn(configurationCustList).when(service).getConfigurationCustomizations();
    doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(service).when(bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
    doNothing().when(SPY_bbInputSetup).populateConfiguration(any(BBInputSetupParameter.class));
    // when
    SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
    // then
    verify(SPY_bbInputSetup, times(1)).populateConfiguration(any(BBInputSetupParameter.class));
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) File(java.io.File) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) Test(org.junit.Test)

Example 5 with ConfigurationResourceCustomization

use of org.onap.so.db.catalog.beans.ConfigurationResourceCustomization in project so by onap.

the class BBInputSetup method getGBBMacroUserParams.

protected GeneralBuildingBlock getGBBMacroUserParams(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String vnfType, String bbName, String key, GeneralBuildingBlock gBB, RequestParameters requestParams, Service service, String input) throws Exception {
    ServiceInstance serviceInstance = gBB.getServiceInstance();
    org.onap.so.serviceinstancebeans.Service serviceMacro = mapper.readValue(input, org.onap.so.serviceinstancebeans.Service.class);
    Resources resources = serviceMacro.getResources();
    Vnfs vnfs = null;
    VfModules vfModules = null;
    Networks networks = null;
    CloudConfiguration cloudConfiguration = requestDetails.getCloudConfiguration();
    CloudRegion cloudRegion = setCloudConfiguration(gBB, cloudConfiguration);
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(executeBB.getRequestId()).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).build();
    if (bbName.contains(VNF) || (bbName.contains(CONTROLLER) && (VNF).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) {
        String vnfInstanceName = lookupKeyMap.get(ResourceKey.VNF_INSTANCE_NAME);
        if (StringUtils.isNotBlank(vnfInstanceName)) {
            vnfs = findVnfsByInstanceName(vnfInstanceName, resources);
        } else {
            vnfs = findVnfsByKey(key, resources);
        }
        // Vnf level cloud configuration takes precedence over service level cloud configuration.
        if (vnfs.getCloudConfiguration() != null) {
            setCloudConfiguration(gBB, vnfs.getCloudConfiguration());
        }
        String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID);
        // This stores the vnf id in request db to be retrieved later when
        // working on a vf module or volume group
        InfraActiveRequests request = this.bbInputSetupUtils.getInfraActiveRequest(executeBB.getRequestId());
        if (request != null) {
            this.bbInputSetupUtils.updateInfraActiveRequestVnfId(request, vnfId);
        }
        parameter.setModelInfo(vnfs.getModelInfo());
        parameter.setInstanceName(vnfs.getInstanceName());
        parameter.setPlatform(vnfs.getPlatform());
        parameter.setLineOfBusiness(vnfs.getLineOfBusiness());
        parameter.setResourceId(vnfId);
        parameter.setVnfType(vnfType);
        parameter.setInstanceParams(vnfs.getInstanceParams());
        parameter.setProductFamilyId(requestDetails.getRequestInfo().getProductFamilyId());
        String applicationId = "";
        if (vnfs.getApplicationId() != null) {
            applicationId = vnfs.getApplicationId();
        }
        parameter.setApplicationId(applicationId);
        this.populateGenericVnf(parameter);
    } else if (bbName.contains(PNF) || (bbName.contains(CONTROLLER) && (PNF).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) {
        String pnfId = lookupKeyMap.get(ResourceKey.PNF);
        resources.getPnfs().stream().filter(pnfs -> Objects.equals(key, pnfs.getModelInfo().getModelCustomizationId())).findFirst().ifPresent(pnfs -> BBInputSetupPnf.populatePnfToServiceInstance(pnfs, pnfId, serviceInstance));
    } else if (bbName.contains(VF_MODULE) || bbName.contains(VOLUME_GROUP) || (bbName.contains(CONTROLLER) && (VF_MODULE).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) {
        String vfModuleInstanceName = lookupKeyMap.get(ResourceKey.VF_MODULE_INSTANCE_NAME);
        if (StringUtils.isNotBlank(vfModuleInstanceName)) {
            vfModules = getVfModulesByInstanceName(vfModuleInstanceName, resources);
        } else {
            vfModules = getVfModulesByKey(key, resources);
        }
        String vfModulesName = vfModules.getInstanceName();
        String vfModulesModelCustId = vfModules.getModelInfo().getModelCustomizationId();
        // Get the Vnf associated with vfModule
        Optional<org.onap.so.serviceinstancebeans.Vnfs> parentVnf = resources.getVnfs().stream().filter(aVnf -> aVnf.getCloudConfiguration() != null).filter(aVnf -> aVnf.getVfModules().stream().anyMatch(aVfModules -> aVfModules.getInstanceName().equals(vfModulesName) && aVfModules.getModelInfo().getModelCustomizationId().equals(vfModulesModelCustId))).findAny();
        // Get the cloud configuration from this Vnf
        if (parentVnf.isPresent()) {
            cloudRegion = setCloudConfiguration(gBB, parentVnf.get().getCloudConfiguration());
        }
        lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, getVnfId(executeBB, lookupKeyMap));
        parameter.setModelInfo(vfModules.getModelInfo());
        if (bbName.contains(VOLUME_GROUP)) {
            parameter.setResourceId(lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID));
            parameter.setInstanceName(vfModules.getVolumeGroupInstanceName());
            parameter.setVnfType(vnfType);
            parameter.setInstanceParams(vfModules.getInstanceParams());
            ServiceModel serviceModel = new ServiceModel();
            serviceModel.setCurrentService(service);
            parameter.setServiceModel(serviceModel);
            this.populateVolumeGroup(parameter);
        } else {
            parameter.setResourceId(lookupKeyMap.get(ResourceKey.VF_MODULE_ID));
            CloudConfiguration cloudConfig = new CloudConfiguration();
            cloudConfig.setLcpCloudRegionId(cloudRegion.getLcpCloudRegionId());
            cloudConfig.setCloudOwner(cloudRegion.getCloudOwner());
            ServiceModel serviceModel = new ServiceModel();
            serviceModel.setCurrentService(service);
            parameter.setServiceModel(serviceModel);
            parameter.setCloudConfiguration(cloudConfig);
            parameter.setInstanceName(vfModules.getInstanceName());
            parameter.setInstanceParams(vfModules.getInstanceParams());
            this.populateVfModule(parameter);
            gBB.getRequestContext().setIsHelm(parameter.getIsHelm());
        }
    } else if (bbName.contains(NETWORK)) {
        networks = findNetworksByKey(key, resources);
        String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID);
        if (networks != null) {
            // If service level cloud configuration is not provided then get it from networks.
            if (cloudConfiguration == null) {
                Optional<org.onap.so.serviceinstancebeans.Networks> netWithCloudConfig = resources.getNetworks().stream().filter(aNetwork -> aNetwork.getCloudConfiguration() != null).findAny();
                if (netWithCloudConfig.isPresent()) {
                    setCloudConfiguration(gBB, netWithCloudConfig.get().getCloudConfiguration());
                } else {
                    logger.debug("Could not find any cloud configuration for this request.");
                }
            }
            parameter.setInstanceName(networks.getInstanceName());
            parameter.setModelInfo(networks.getModelInfo());
            parameter.setInstanceParams(networks.getInstanceParams());
            parameter.setResourceId(networkId);
            this.populateL3Network(parameter);
        }
    } else if (bbName.contains("Configuration")) {
        String configurationId = lookupKeyMap.get(ResourceKey.CONFIGURATION_ID);
        ModelInfo configurationModelInfo = new ModelInfo();
        configurationModelInfo.setModelCustomizationUuid(key);
        ConfigurationResourceCustomization configurationCust = findConfigurationResourceCustomization(configurationModelInfo, service);
        if (configurationCust != null) {
            parameter.setModelInfo(configurationModelInfo);
            parameter.setResourceId(configurationId);
            parameter.setConfigurationResourceKeys(executeBB.getConfigurationResourceKeys());
            parameter.setRequestDetails(executeBB.getRequestDetails());
            this.populateConfiguration(parameter);
        } else {
            logger.debug("Could not find a configuration customization with key: {}", key);
        }
    }
    return gBB;
}
Also used : WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) AAIUriFactory(org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory) VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) Vnfs(org.onap.so.serviceinstancebeans.Vnfs) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) StringUtils(org.apache.commons.lang3.StringUtils) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) JavaDelegate(org.camunda.bpm.engine.delegate.JavaDelegate) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) Service(org.onap.so.db.catalog.beans.Service) Map(java.util.Map) Tenant(org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) NetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ServiceProxy(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) LineOfBusiness(org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) UUID(java.util.UUID) Pair(org.javatuples.Pair) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) Objects(java.util.Objects) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ModelType(org.onap.so.serviceinstancebeans.ModelType) Optional(java.util.Optional) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException) HashMap(java.util.HashMap) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ResourceNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ResourceNotFoundException) ArrayList(java.util.ArrayList) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) VfModules(org.onap.so.serviceinstancebeans.VfModules) RouteTableReference(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) OwningEntity(org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) Logger(org.slf4j.Logger) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Project(org.onap.so.bpmn.servicedecomposition.bbobjects.Project) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) Networks(org.onap.so.serviceinstancebeans.Networks) Component(org.springframework.stereotype.Component) Platform(org.onap.so.bpmn.servicedecomposition.bbobjects.Platform) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters) Resources(org.onap.so.serviceinstancebeans.Resources) SerializationFeature(com.fasterxml.jackson.databind.SerializationFeature) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VfModules(org.onap.so.serviceinstancebeans.VfModules) Networks(org.onap.so.serviceinstancebeans.Networks) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) Optional(java.util.Optional) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) Vnfs(org.onap.so.serviceinstancebeans.Vnfs) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) Resources(org.onap.so.serviceinstancebeans.Resources) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization)

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