Search in sources :

Example 1 with Configuration

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration in project so by onap.

the class AAICreateTasks method createConfiguration.

/**
 * This method is used for configuring the service in A&AI.
 *
 * @param execution @throws
 */
public void createConfiguration(BuildingBlockExecution execution) {
    try {
        Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
        aaiConfigurationResources.createConfiguration(configuration);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 2 with Configuration

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration in project so by onap.

the class BuildingBlockTestDataSetup method buildConfiguration.

public Configuration buildConfiguration() {
    configurationCounter++;
    Configuration configuration = new Configuration();
    configuration.setConfigurationId("testConfigurationId" + configurationCounter);
    configuration.setConfigurationName("testConfigurationName" + configurationCounter);
    ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
    modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter);
    modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter);
    modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter);
    configuration.setModelInfoConfiguration(modelInfoConfiguration);
    return configuration;
}
Also used : ModelInfoConfiguration(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ModelInfoConfiguration(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration)

Example 3 with Configuration

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration in project so by onap.

the class VnfEBBLoader method addConfigToResources.

private void addConfigToResources(Optional<Relationships> relationshipsOp, List<Resource> resourceList, Resource vfModuleResource, List<Pair<WorkflowType, String>> aaiResourceIds) {
    if (relationshipsOp.isPresent()) {
        Optional<Configuration> config = workflowActionUtils.extractRelationshipsConfiguration(relationshipsOp.get());
        if (config.isPresent()) {
            aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.get().getConfigurationId()));
            resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false, vfModuleResource));
        }
    }
}
Also used : Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)

Example 4 with Configuration

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration in project so by onap.

the class ServiceEBBLoader method traverseAAIService.

public void traverseAAIService(DelegateExecution execution, List<Resource> resourceList, String resourceId, List<Pair<WorkflowType, String>> aaiResourceIds) {
    try {
        ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(resourceId);
        org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
        var serviceResource = new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null);
        serviceResource.setModelInvariantId(serviceInstanceAAI.getModelInvariantId());
        serviceResource.setModelVersionId(serviceInstanceAAI.getModelVersionId());
        resourceList.add(serviceResource);
        traverseServiceInstanceMSOVnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
        traverseServiceInstanceMSOPnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
        if (serviceInstanceMSO.getNetworks() != null) {
            for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO.getNetworks()) {
                aaiResourceIds.add(new Pair<>(WorkflowType.NETWORK, network.getNetworkId()));
                Resource networkResource = new Resource(WorkflowType.NETWORK, network.getNetworkId(), false, serviceResource);
                ModelInfoNetwork modelInfoNetwork = network.getModelInfoNetwork();
                if (modelInfoNetwork != null) {
                    networkResource.setModelCustomizationId(modelInfoNetwork.getModelCustomizationUUID());
                    networkResource.setModelVersionId(modelInfoNetwork.getModelUUID());
                    networkResource.setModelCustomizationId(modelInfoNetwork.getModelCustomizationUUID());
                }
                resourceList.add(networkResource);
            }
        }
        if (serviceInstanceMSO.getCollection() != null) {
            logger.debug("found networkcollection");
            aaiResourceIds.add(new Pair<>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId()));
            resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId(), false, serviceResource));
        }
        if (serviceInstanceMSO.getConfigurations() != null) {
            for (Configuration config : serviceInstanceMSO.getConfigurations()) {
                Optional<org.onap.aai.domain.yang.Configuration> aaiConfig = aaiConfigurationResources.getConfiguration(config.getConfigurationId());
                if (aaiConfig.isPresent() && aaiConfig.get().getRelationshipList() != null) {
                    for (Relationship relationship : aaiConfig.get().getRelationshipList().getRelationship()) {
                        if (relationship.getRelatedTo().contains("vnfc") || relationship.getRelatedTo().contains("vpn-binding")) {
                            aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.getConfigurationId()));
                            resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(), false, serviceResource));
                            break;
                        }
                    }
                }
            }
        }
    } catch (Exception ex) {
        logger.error("Exception in traverseAAIService", ex);
        buildAndThrowException(execution, "Could not find existing Service Instance or related Instances to execute the request on.");
    }
}
Also used : Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) VrfBondingServiceException(org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) Relationship(org.onap.aai.domain.yang.Relationship) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)

Example 5 with Configuration

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration 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)

Aggregations

Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)41 Test (org.junit.Test)23 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)13 ArrayList (java.util.ArrayList)11 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)11 ModelInfoConfiguration (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration)10 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)9 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)8 Service (org.onap.so.db.catalog.beans.Service)8 File (java.io.File)7 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)7 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)7 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)6 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)6 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)6 BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys)6 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)6 GenericVnf (org.onap.aai.domain.yang.GenericVnf)5 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)5 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)5