Search in sources :

Example 1 with RequestParameters

use of org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters in project so by onap.

the class AppcRunTasks method runAppcCommand.

public void runAppcCommand(BuildingBlockExecution execution, Action action) {
    logger.trace("Start runAppcCommand ");
    String appcCode = "1002";
    String appcMessage = "";
    try {
        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 vmIdList = execution.getVariable("vmIdList");
        String vserverIdList = execution.getVariable("vserverIdList");
        String identityUrl = execution.getVariable("identityUrl");
        ControllerSelectionReference controllerSelectionReference = catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, action.toString());
        String controllerType;
        if (controllerSelectionReference != null) {
            controllerType = controllerSelectionReference.getControllerName();
        } else {
            controllerType = CONTROLLER_TYPE_DEFAULT;
        }
        String vfModuleId = null;
        VfModule vfModule = null;
        try {
            vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        } catch (BBObjectNotFoundException e) {
        }
        if (vfModule != null) {
            vfModuleId = vfModule.getVfModuleId();
        }
        HashMap<String, String> payloadInfo = buildPayloadInfo(vnfName, aicIdentity, vnfHostIpAddress, vmIdList, vserverIdList, identityUrl, vfModuleId);
        Optional<String> payload = Optional.empty();
        RequestParameters requestParameters = gBBInput.getRequestContext().getRequestParameters();
        if (requestParameters != null) {
            String pay = requestParameters.getPayload();
            if (pay != null) {
                payload = Optional.of(pay);
            } else {
                String payloadFromUserParams = buildPayloadFromUserParams(gBBInput.getRequestContext().getUserParams());
                payload = Optional.of(payloadFromUserParams);
            }
        }
        logger.debug("Running APP-C action: {}", action.toString());
        logger.debug("VNFID: {}", vnfId);
        appCClient.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
        appcCode = appCClient.getErrorCode();
        appcMessage = appCClient.getErrorMessage();
        mapRollbackVariables(execution, action, appcCode);
    } catch (Exception e) {
        logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "Caught exception in runAppcCommand", "BPMN", ErrorCode.UnknownError.getValue(), "Error on request to APPC", e);
        appcCode = GENERIC_APPC_ERROR_CODE;
        appcMessage = e.getMessage();
    }
    logger.error("Error Message: {}", appcMessage);
    logger.error("ERROR CODE: {}", appcCode);
    logger.trace("End of runAppCommand ");
    if (appcCode != null && !"0".equals(appcCode)) {
        exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
    }
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters)

Example 2 with RequestParameters

use of org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters in project so by onap.

the class BuildingBlockTestDataSetup method buildRequestContext.

public RequestContext buildRequestContext() {
    RequestContext requestContext = new RequestContext();
    requestContext.setMsoRequestId(UUID.randomUUID().toString());
    requestContext.setProductFamilyId("testProductFamilyId");
    requestContext.setRequestorId("testRequestorId");
    requestContext.setUserParams(new HashMap<>());
    Map<String, Object> dataMap = new HashMap<>();
    dataMap.put("vpnId", "testVpnId");
    dataMap.put("vpnRegion", "testVpnRegion");
    dataMap.put("vpnRt", "testVpnRt");
    dataMap.put("vpnName", "vpnName");
    dataMap.put("vpnRegion", Arrays.asList(new String[] { "USA", "EMEA", "APAC" }));
    HashMap<String, Object> userParams = new HashMap<>();
    userParams.put("vpnData", dataMap);
    List<Map<String, Object>> userParamsList = new ArrayList<>();
    userParamsList.add(userParams);
    RequestParameters requestParameters = new RequestParameters();
    requestParameters.setUserParams(userParamsList);
    requestContext.setRequestParameters(requestParameters);
    return requestContext;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Map(java.util.Map) HashMap(java.util.HashMap) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters)

Example 3 with RequestParameters

use of org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters in project so by onap.

the class AbstractVnfCDSRequestProviderTest method createGeneralBuildingBlock.

protected GeneralBuildingBlock createGeneralBuildingBlock() {
    GeneralBuildingBlock generalBuildingBlock = new GeneralBuildingBlock();
    RequestContext requestContext = new RequestContext();
    RequestParameters requestParameters = new RequestParameters();
    requestParameters.setUserParams(createRequestUserParams());
    requestContext.setRequestParameters(requestParameters);
    requestContext.setMsoRequestId(MSO_REQUEST_ID);
    generalBuildingBlock.setRequestContext(requestContext);
    return generalBuildingBlock;
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters)

Example 4 with RequestParameters

use of org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters in project so by onap.

the class BBInputSetupMapperLayerTest method testMapRequestParameters.

@Test
public void testMapRequestParameters() throws IOException {
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
    RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
    assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
    assertEquals(actual.getSubscriptionServiceType(), requestDetails.getRequestParameters().getSubscriptionServiceType());
    assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
}
Also used : File(java.io.File) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters) Test(org.junit.Test)

Example 5 with RequestParameters

use of org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters in project so by onap.

the class AppcRunTasksIT method runAppcCommandTest.

@Test
public void runAppcCommandTest() throws Exception {
    Action action = Action.QuiesceTraffic;
    ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
    controllerSelectionReference.setControllerName("testName");
    controllerSelectionReference.setActionCategory(action.toString());
    controllerSelectionReference.setVnfType("testVnfType");
    doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.QuiesceTraffic.toString());
    execution.setVariable("aicIdentity", "testAicIdentity");
    String vnfId = genericVnf.getVnfId();
    genericVnf.setIpv4OamAddress("testOamIpAddress");
    String payload = "{\"testName\":\"testValue\",}";
    RequestParameters requestParameters = new RequestParameters();
    requestParameters.setPayload(payload);
    gBBInput.getRequestContext().setRequestParameters(requestParameters);
    String controllerType = "testName";
    HashMap<String, String> payloadInfo = new HashMap<String, String>();
    payloadInfo.put("vnfName", "testVnfName1");
    payloadInfo.put("aicIdentity", "testAicIdentity");
    payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
    payloadInfo.put("vserverIdList", null);
    payloadInfo.put("vfModuleId", null);
    payloadInfo.put("identityUrl", null);
    payloadInfo.put("vmIdList", null);
    doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
    appcRunTasks.runAppcCommand(execution, action);
    verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
}
Also used : Action(org.onap.appc.client.lcm.model.Action) ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference) HashMap(java.util.HashMap) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters) Test(org.junit.Test) BaseIntegrationTest(org.onap.so.BaseIntegrationTest)

Aggregations

RequestParameters (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters)25 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)18 Test (org.junit.Test)9 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)9 HashMap (java.util.HashMap)8 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)8 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)7 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)7 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)7 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)6 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)4 URI (java.net.URI)3 GenericResourceApiVfModuleOperationInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation)3 GenericResourceApiVfmoduleinformationVfModuleInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation)3 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)3 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)3 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)3 MapperException (org.onap.so.client.exception.MapperException)3