Search in sources :

Example 61 with GeneralBuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.

the class CnfAdapterCreateTasks method prepareForCnfUpdateOrDelete.

public void prepareForCnfUpdateOrDelete(BuildingBlockExecution execution) {
    GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
    GenericVnf genericVnfId = null;
    VfModule vfModuleId = null;
    try {
        genericVnfId = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        vfModuleId = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
    } catch (Exception ex) {
        logger.error("Exception occurred", ex);
    }
    String heatStackId = execution.getVariable("heatStackId");
    logger.debug("heatStackId: {}", heatStackId);
    CloudRegion cloudRegion = gBBInput.getCloudRegion();
    String requestId = execution.getVariable("mso-request-id");
    String callbackUrl = "http://so-bpmn-infra.onap:8081/mso/WorkflowMessage/" + CNF_ADAPTER_MESSAGE_TYPE + "/" + requestId;
    CnfAaiUpdateRequest aaiRequest = createCnfAaiUpdateRequest(heatStackId, cloudRegion, callbackUrl, genericVnfId, vfModuleId);
    logger.debug("aaiRequest: {}", aaiRequest);
    String cnfRequestPayload = "";
    try {
        cnfRequestPayload = mapper.writeValueAsString(aaiRequest);
    } catch (JsonProcessingException e) {
        logger.error("Exception occurred", e);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
    }
    // Prepare values to pass in execution variable for CNF Adapter async Handling
    execution.setVariable("messageType", CNF_ADAPTER_MESSAGE_TYPE);
    execution.setVariable("correlator", requestId);
    execution.setVariable("timeout", CNF_ADAPTER_CALLBACK_TIMEOUT);
    String currentFlow = execution.getFlowToBeCalled();
    logger.debug("currentFlow: {}", currentFlow);
    String apiPath = "http://so-cnf-adapter:8090";
    if ("CreateVfModuleBB".equals(currentFlow)) {
        apiPath = apiPath + "/api/cnf-adapter/v1/aai-update/";
    } else if ("DeleteVfModuleBB".equals(currentFlow)) {
        apiPath = apiPath + "/api/cnf-adapter/v1/aai-delete/";
    }
    // Set variables in execution variable\
    execution.setVariable("apiPath", apiPath);
    execution.setVariable("cnfRequestPayload", cnfRequestPayload);
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) CnfAaiUpdateRequest(org.onap.so.client.adapter.cnf.entities.CnfAaiUpdateRequest) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException)

Example 62 with GeneralBuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.

the class CnfAdapterCreateTasks method createInstance.

/**
 * This method is used for creating the request for an Instance in Multicloud K8s Plugin.
 *
 * @param execution
 * @return
 */
public void createInstance(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
        GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        RequestContext requestContext = gBBInput.getRequestContext();
        CloudRegion cloudRegion = gBBInput.getCloudRegion();
        String sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId());
        String sdncVnfQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId());
        Map<String, Object> paramsMap = vfModuleMapper.buildVfModuleParamsMap(requestContext, serviceInstance, genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
        Map<String, String> sdncDirectives = getSdncDirectives(paramsMap);
        InstanceRequest createInstanceRequest = createInstanceRequest(vfModule, cloudRegion, sdncDirectives);
        InstanceResponse response = cnfAdapterClient.createVfModule(createInstanceRequest);
        execution.setVariable("heatStackId", response.getId());
    } catch (Exception ex) {
        logger.error("Exception occurred", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) JsonParseException(com.fasterxml.jackson.core.JsonParseException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) InstanceResponse(org.onap.so.client.adapter.cnf.entities.InstanceResponse) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) InstanceRequest(org.onap.so.client.adapter.cnf.entities.InstanceRequest)

Example 63 with GeneralBuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.

the class NetworkAdapterCreateTasks method createNetwork.

public void createNetwork(BuildingBlockExecution execution) {
    execution.setVariable("networkAdapterCreateRollback", false);
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        Map<String, String> userInput = gBBInput.getUserInput();
        String cloudRegionPo = execution.getVariable("cloudRegionPo");
        CreateNetworkRequest createNetworkRequest = networkAdapterObjectMapper.createNetworkRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, gBBInput.getCustomer());
        execution.setVariable("networkAdapterRequest", createNetworkRequest.toXmlString());
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)

Example 64 with GeneralBuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.

the class VnfAdapterDeleteTasks method deleteVolumeGroup.

public void deleteVolumeGroup(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
        DeleteVolumeGroupRequest deleteVolumeGroupRequest = vnfAdapterVolumeGroupResources.deleteVolumeGroupRequest(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, volumeGroup);
        execution.setVariable(VNFREST_REQUEST, deleteVolumeGroupRequest.toXmlString());
        execution.setVariable("deleteVolumeGroupRequest", "true");
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) DeleteVolumeGroupRequest(org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)

Example 65 with GeneralBuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.

the class VnfmAdapterCreateVnfTask method buildCreateVnfRequest.

/**
 * Create {@link CreateVnfRequest} object with required fields and store it in
 * {@link org.camunda.bpm.engine.delegate.DelegateExecution}
 *
 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
 */
public void buildCreateVnfRequest(final BuildingBlockExecution execution) {
    try {
        LOGGER.debug("Executing buildCreateVnfRequest  ...");
        final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock();
        final CloudRegion cloudRegion = buildingBlock.getCloudRegion();
        final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
        final ModelInfoGenericVnf modelInfoGenericVnf = vnf.getModelInfoGenericVnf();
        final InputParameter inputParameter = getInputParameter(execution);
        final CreateVnfRequest createVnfRequest = new CreateVnfRequest();
        createVnfRequest.setName(getName(vnf.getVnfName(), modelInfoGenericVnf.getModelInstanceName()));
        createVnfRequest.setTenant(getTenant(cloudRegion));
        createVnfRequest.setAdditionalParams(inputParameter.getAdditionalParams());
        createVnfRequest.setExternalVirtualLinks(inputParameter.getExtVirtualLinks());
        LOGGER.info("CreateVnfRequest : {}", createVnfRequest);
        execution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, createVnfRequest);
        LOGGER.debug("Finished executing buildCreateVnfRequest ...");
    } catch (final Exception exception) {
        LOGGER.error("Unable to execute buildCreateVnfRequest", exception);
        exceptionUtil.buildAndThrowWorkflowException(execution, 1200, exception);
    }
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) CreateVnfRequest(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest) InputParameter(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter) NullInputParameter(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.NullInputParameter)

Aggregations

GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)117 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)61 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)51 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)40 Test (org.junit.Test)37 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)37 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)35 File (java.io.File)34 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)34 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)29 Service (org.onap.so.db.catalog.beans.Service)27 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)25 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)23 HashMap (java.util.HashMap)22 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)22 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)20 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)19 SDNCRequest (org.onap.so.client.sdnc.beans.SDNCRequest)19 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)16 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)16