Search in sources :

Example 16 with GeneralBuildingBlock

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

the class VnfAdapterDeleteTasks method deleteVfModule.

public void deleteVfModule(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        DeleteVfModuleRequest deleteVfModuleRequest = vnfAdapterVfModuleResources.deleteVfModuleRequest(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, genericVnf, vfModule);
        execution.setVariable(VNFREST_REQUEST, deleteVfModuleRequest.toXmlString());
        execution.setVariable("deleteVfModuleRequest", "true");
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : 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) DeleteVfModuleRequest(org.onap.so.adapters.vnfrest.DeleteVfModuleRequest)

Example 17 with GeneralBuildingBlock

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

the class InputParameterRetrieverTask method getUserParamsInputParameter.

private InputParameter getUserParamsInputParameter(final BuildingBlockExecution execution) {
    final GeneralBuildingBlock generalBuildingBlock = execution.getGeneralBuildingBlock();
    if (generalBuildingBlock != null && generalBuildingBlock.getRequestContext() != null && generalBuildingBlock.getRequestContext().getRequestParameters() != null) {
        final List<Map<String, Object>> userParams = generalBuildingBlock.getRequestContext().getRequestParameters().getUserParams();
        if (userParams != null) {
            final Map<String, Object> params = new HashMap<>();
            userParams.stream().forEach(obj -> {
                params.putAll(obj);
            });
            LOGGER.info("User params found : {}", params);
            if (userParams != null && !userParams.isEmpty()) {
                return userParamInputParametersProvider.getInputParameter(params);
            }
        }
    }
    LOGGER.warn("No input parameters found in userparams ...");
    return NullInputParameter.NULL_INSTANCE;
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 18 with GeneralBuildingBlock

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

the class NetworkAdapterImpl method preProcessNetworkAdapter.

public void preProcessNetworkAdapter(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId());
        execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId());
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) JAXBException(javax.xml.bind.JAXBException)

Example 19 with GeneralBuildingBlock

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

the class VnfAdapterImpl method preProcessVnfAdapter.

public void preProcessVnfAdapter(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId());
        execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId());
        execution.setVariable(HEAT_STACK_ID, null);
        execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, null);
        execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, null);
        execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, null);
        execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, null);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) MarshallerException(org.onap.so.exceptions.MarshallerException)

Example 20 with GeneralBuildingBlock

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

the class AppcOrchestratorPreProcessor method buildAppcTaskRequest.

public void buildAppcTaskRequest(BuildingBlockExecution execution, String actionName) {
    try {
        Action action = Action.valueOf(actionName);
        ApplicationControllerTaskRequest appcTaskRequest = new ApplicationControllerTaskRequest();
        appcTaskRequest.setAction(action);
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        GenericVnf vnf = null;
        try {
            vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        } catch (BBObjectNotFoundException e) {
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "No valid VNF exists");
        }
        String vnfId = null;
        String vnfName = null;
        String vnfType = null;
        String vnfHostIpAddress = null;
        if (vnf != null) {
            vnfId = vnf.getVnfId();
            vnfName = vnf.getVnfName();
            vnfType = vnf.getVnfType();
            vnfHostIpAddress = vnf.getIpv4OamAddress();
        }
        String msoRequestId = gBBInput.getRequestContext().getMsoRequestId();
        String aicIdentity = execution.getVariable("aicIdentity");
        String identityUrl = execution.getVariable("identityUrl");
        appcTaskRequest.setIdentityUrl(identityUrl);
        String requestorId = gBBInput.getRequestContext().getRequestorId();
        appcTaskRequest.setRequestorId(requestorId);
        if (gBBInput.getRequestContext().getRequestParameters() != null) {
            String payload = gBBInput.getRequestContext().getRequestParameters().getPayload();
            if (payload == null) {
                payload = "";
            }
            String existingSoftwareVersion = JsonUtils.getJsonValue(payload, "existing_software_version");
            appcTaskRequest.setExistingSoftwareVersion(existingSoftwareVersion);
            String newSoftwareVersion = JsonUtils.getJsonValue(payload, "new_software_version");
            appcTaskRequest.setNewSoftwareVersion(newSoftwareVersion);
            String operationsTimeout = JsonUtils.getJsonValue(payload, "operations_timeout");
            appcTaskRequest.setOperationsTimeout(operationsTimeout);
            Map<String, String> configMap = new HashMap<>();
            ObjectMapper objectMapper = new ObjectMapper();
            String configParamsStr = JsonUtils.getJsonValue(payload, "configuration_parameters");
            if (configParamsStr != null) {
                configMap = objectMapper.readValue(configParamsStr, new TypeReference<HashMap<String, String>>() {
                });
            }
            appcTaskRequest.setConfigParams(configMap);
        }
        ControllerSelectionReference controllerSelectionReference = catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, action.toString());
        String controllerType = null;
        if (controllerSelectionReference != null) {
            controllerType = controllerSelectionReference.getControllerName();
        } else {
            controllerType = CONTROLLER_TYPE_DEFAULT;
        }
        appcTaskRequest.setControllerType(controllerType);
        execution.setVariable("vmIdList", null);
        execution.setVariable("vserverIdList", null);
        execution.setVariable("vmIndex", 0);
        execution.setVariable("vmIdListSize", 0);
        String vfModuleId = null;
        VfModule vfModule = null;
        try {
            vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        } catch (BBObjectNotFoundException e) {
        }
        if (vfModule != null) {
            vfModuleId = vfModule.getVfModuleId();
        }
        if (action.equals(Action.Snapshot)) {
            try {
                getVserversForAppc(execution, vnf);
            } catch (Exception e) {
                logger.warn("Unable to retrieve vservers for vnf: " + vnfId);
            }
        }
        ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf();
        applicationControllerVnf.setVnfHostIpAddress(vnfHostIpAddress);
        applicationControllerVnf.setVnfId(vnfId);
        applicationControllerVnf.setVnfName(vnfName);
        appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf);
        verifyApplicationControllerTaskRequest(execution, appcTaskRequest);
        execution.setVariable("appcOrchestratorRequest", appcTaskRequest);
        logger.debug("SET APPC ORCHESTRATOR REQUEST");
    } catch (Exception e) {
        logger.error("Error building ApplicationControllerTaskRequest Object", e.getMessage());
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
    }
}
Also used : Action(org.onap.appc.client.lcm.model.Action) ApplicationControllerTaskRequest(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) ValidationException(org.onap.so.exceptions.ValidationException) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) ApplicationControllerVnf(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf) ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference) TypeReference(com.fasterxml.jackson.core.type.TypeReference) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

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