Search in sources :

Example 61 with VfModule

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

the class CnfAdapterDeleteTasks method deleteInstance.

/**
 * This method is used for deleting the instance with Multicloud K8s Plugin.
 *
 * @param execution
 * @return
 */
public void deleteInstance(BuildingBlockExecution execution) {
    try {
        logger.debug("Running delete instance - Helm");
        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        String heatStackId = vfModule.getHeatStackId();
        execution.setVariable("heatStackId", heatStackId);
        cnfAdapterClient.deleteVfModule(heatStackId);
    } catch (Exception ex) {
        logger.error("Exception occurred", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)

Example 62 with VfModule

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

the class CnfHealthCheckTasks method prepareCnfAdaperRequest.

public void prepareCnfAdaperRequest(BuildingBlockExecution execution) {
    GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
    ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
    GenericVnf genericVnf = serviceInstance.getVnfs().get(0);
    List<VfModule> listOfVfModules = genericVnf.getVfModules();
    List<String> listOfHeatStackIds = listOfVfModules.stream().map(x -> x.getHeatStackId()).collect(Collectors.toList());
    LOGGER.debug("listOfHeatStackIds from prepareCnfAdaperRequest: {}", listOfHeatStackIds);
    // Prepare values to pass in execution variable for CNF Adapter async Handling
    String requestId = execution.getVariable("mso-request-id");
    execution.setVariable("messageType", CNF_ADAPTER_MESSAGE_TYPE);
    execution.setVariable("correlator", requestId);
    execution.setVariable("timeout", "PT30M");
    // Replace with environment values
    String callBackUrl = "http://so-bpmn-infra.onap:8081/mso/WorkflowMessage/" + CNF_ADAPTER_MESSAGE_TYPE + "/" + requestId;
    HealthcheckInstanceRequest request = new HealthcheckInstanceRequest();
    try {
        request = createStatusCheckRequest(listOfHeatStackIds, callBackUrl);
    } catch (JsonProcessingException e) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 6822, e);
    }
    LOGGER.debug("request: {}", request);
    String requestPayload = "";
    try {
        requestPayload = mapper.writeValueAsString(request);
    } catch (JsonProcessingException e) {
        LOGGER.error("Error in JSON");
    }
    execution.setVariable("cnfRequestPayload", requestPayload);
    ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
    BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
    String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow(() -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table "));
    // Replace values with environment values
    String uri = "http://so-cnf-adapter:8090";
    String apiPath = "";
    if (STATUS_CHECK_SCOPE.equals(action)) {
        apiPath = uri + "/api/cnf-adapter/v1/statuscheck/";
    } else if (HEALTH_CHECK_SCOPE.equals(action)) {
        apiPath = uri + "/api/cnf-adapter/v1/healthcheck/";
    }
    LOGGER.debug("apiPath: {}", apiPath);
    execution.setVariable("apiPath", apiPath);
}
Also used : ONAPComponents(org.onap.logging.filter.base.ONAPComponents) HealthcheckInstanceResponse(org.onap.so.client.adapter.cnf.entities.HealthcheckInstanceResponse) StatusCheckInstanceResponse(org.onap.so.client.adapter.cnf.entities.StatusCheckInstanceResponse) HealthcheckInstanceRequest(org.onap.so.client.adapter.cnf.entities.HealthcheckInstanceRequest) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) StatusCheckResponse(org.onap.so.client.adapter.cnf.entities.StatusCheckResponse) ArrayList(java.util.ArrayList) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) Logger(org.slf4j.Logger) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) HealthcheckResponse(org.onap.so.client.adapter.cnf.entities.HealthcheckResponse) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Collectors(java.util.stream.Collectors) HealthcheckInstance(org.onap.so.client.adapter.cnf.entities.HealthcheckInstance) List(java.util.List) Component(org.springframework.stereotype.Component) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Optional(java.util.Optional) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.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) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) HealthcheckInstanceRequest(org.onap.so.client.adapter.cnf.entities.HealthcheckInstanceRequest) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 63 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule 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 64 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule 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 65 with VfModule

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

the class AuditTasks method createAuditInventory.

private AuditInventory createAuditInventory(BuildingBlockExecution execution) throws BBObjectNotFoundException {
    AuditInventory auditInventory = new AuditInventory();
    GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
    VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
    GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
    CloudRegion cloudRegion = gBBInput.getCloudRegion();
    auditInventory.setMsoRequestId(gBBInput.getRequestContext().getMsoRequestId());
    auditInventory.setCloudOwner(cloudRegion.getCloudOwner());
    auditInventory.setCloudRegion(cloudRegion.getLcpCloudRegionId());
    auditInventory.setTenantId(cloudRegion.getTenantId());
    auditInventory.setVfModuleId(vfModule.getVfModuleId());
    auditInventory.setHeatStackName(vfModule.getVfModuleName());
    auditInventory.setGenericVnfId(genericVnf.getVnfId());
    return auditInventory;
}
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) AuditInventory(org.onap.so.audit.beans.AuditInventory) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)

Aggregations

VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)97 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)74 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)53 Test (org.junit.Test)46 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)45 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)37 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)35 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)30 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)27 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)27 HashMap (java.util.HashMap)22 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)20 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)18 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)14 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)14 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)13 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)12 Service (org.onap.so.db.catalog.beans.Service)12 Map (java.util.Map)11 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)11