Search in sources :

Example 21 with Status

use of org.onap.appc.client.lcm.model.Status in project so by onap.

the class ApplicationControllerSupport method buildStatusFromAppcException.

public Status buildStatusFromAppcException(AppcClientException exception) {
    Status exceptionStatus = new Status();
    exceptionStatus.setCode(200);
    exceptionStatus.setMessage("Exception on APPC request: " + exception.getMessage());
    return exceptionStatus;
}
Also used : Status(org.onap.appc.client.lcm.model.Status)

Example 22 with Status

use of org.onap.appc.client.lcm.model.Status in project so by onap.

the class ApplicationControllerTask method executeExternalTask.

protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
    mdcSetup.setupMDC(externalTask);
    ApplicationControllerTaskRequest request = externalTask.getVariable("appcOrchestratorRequest");
    String msoRequestId = externalTask.getVariable("mso-request-id");
    logger.debug("Starting External Task for RequestId: {} ", msoRequestId);
    Status status = null;
    ApplicationControllerCallback listener = new ApplicationControllerCallback(externalTask, externalTaskService, applicationControllerSupport);
    try {
        status = applicationControllerTaskImpl.execute(msoRequestId, request, listener);
        if (status != null && status.getCode() != 0 && !applicationControllerSupport.getCategoryOf(status).equals(StatusCategory.NORMAL)) {
            logger.error("The External Task Id: {} Failed locally with status {}", externalTask.getId(), status.getMessage());
            externalTaskService.handleBpmnError(externalTask, "MSOWorkflowException", status.getMessage());
        }
    } catch (Exception e) {
        logger.error("The External Task Id: {} Failed while calling appc with exception", externalTask.getId(), e.getMessage());
        externalTaskService.handleBpmnError(externalTask, "MSOWorkflowException", e.getMessage());
    }
}
Also used : Status(org.onap.appc.client.lcm.model.Status) ApplicationControllerTaskRequest(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest) ApplicationControllerCallback(org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback)

Example 23 with Status

use of org.onap.appc.client.lcm.model.Status in project so by onap.

the class ApplicationControllerTaskImpl method execute.

public Status execute(String msoRequestId, ApplicationControllerTaskRequest request, ApplicationControllerCallback listener) throws JsonProcessingException, ApplicationControllerOrchestratorException {
    Status status = null;
    GraphInventoryCommonObjectMapperProvider mapper = new GraphInventoryCommonObjectMapperProvider();
    Optional<String> payload = Optional.empty();
    String vmId = null;
    Optional<String> vserverId = Optional.empty();
    Parameters parameters = new Parameters();
    ConfigurationParameters configParams = new ConfigurationParameters();
    RequestParameters requestParams = new RequestParameters();
    switch(request.getAction()) {
        case HealthCheck:
            requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress());
            parameters.setRequestParameters(requestParams);
            payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
            break;
        case ResumeTraffic:
            configParams.setVnfName(request.getApplicationControllerVnf().getVnfName());
            parameters.setConfigurationParameters(configParams);
            payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
            break;
        case Start:
        case Stop:
            Identity identity = new Identity();
            identity.setIdentityUrl(request.getIdentityUrl());
            payload = Optional.of((mapper.getMapper().writeValueAsString(identity)));
            break;
        case Unlock:
        case Lock:
            break;
        case QuiesceTraffic:
            parameters.setOperationsTimeout(request.getOperationsTimeout());
            payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
            break;
        case DistributeTraffic:
            configParams.setBookName(request.getBookName());
            configParams.setNodeList(request.getNodeList());
            configParams.setFileParameterContent(request.getFileParameters());
            configParams.setVnfName(request.getApplicationControllerVnf().getVnfName());
            parameters.setConfigurationParameters(configParams);
            payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
            break;
        case DistributeTrafficCheck:
            configParams.setBookName(request.getBookName());
            configParams.setNodeList(request.getNodeList());
            configParams.setFileParameterContent(request.getFileParameters());
            configParams.setVnfName(request.getApplicationControllerVnf().getVnfName());
            parameters.setConfigurationParameters(configParams);
            payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
            break;
        case ConfigModify:
            requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress());
            configParams.setAdditionalProperties(request.getConfigParams());
            parameters.setRequestParameters(requestParams);
            parameters.setConfigurationParameters(configParams);
            payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
            break;
        case ConfigScaleOut:
            break;
        case UpgradePreCheck:
        case UpgradePostCheck:
        case UpgradeSoftware:
        case UpgradeBackup:
            parameters.setExistingSoftwareVersion(request.getExistingSoftwareVersion());
            parameters.setNewSoftwareVersion(request.getNewSoftwareVersion());
            payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
            break;
        case ActionStatus:
            break;
        case Snapshot:
            ApplicationControllerVm applicationControllerVm = request.getApplicationControllerVnf().getApplicationControllerVm();
            if (applicationControllerVm != null) {
                vmId = request.getApplicationControllerVnf().getApplicationControllerVm().getVmId();
                parameters.setVmId(vmId);
                payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
                vserverId = Optional.of(request.getApplicationControllerVnf().getApplicationControllerVm().getVserverId());
            }
            break;
        default:
            // errorMessage = "Unable to idenify Action request for AppCClient";
            break;
    }
    status = appcClient.vnfCommand(request.getAction(), msoRequestId, request.getApplicationControllerVnf().getVnfId(), vserverId, payload, request.getControllerType(), listener, request.getRequestorId());
    return status;
}
Also used : Status(org.onap.appc.client.lcm.model.Status) ApplicationControllerVm(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm) Parameters(org.onap.so.adapters.appc.orchestrator.client.beans.Parameters) RequestParameters(org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters) ConfigurationParameters(org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters) GraphInventoryCommonObjectMapperProvider(org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider) ConfigurationParameters(org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters) Identity(org.onap.so.adapters.appc.orchestrator.client.beans.Identity) RequestParameters(org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters)

Example 24 with Status

use of org.onap.appc.client.lcm.model.Status in project so by onap.

the class ApplicationControllerTaskTest method executeExternalTask_appc_success_Test.

@Test
public void executeExternalTask_appc_success_Test() throws Exception {
    Status status = new Status();
    doReturn(status).when(applicationControllerTaskImpl).execute(any(String.class), any(ApplicationControllerTaskRequest.class), any(ApplicationControllerCallback.class));
    appcTaskService.executeExternalTask(mockExternalTask, mockExternalTaskService);
    Mockito.verify(applicationControllerTaskImpl).execute(any(String.class), any(ApplicationControllerTaskRequest.class), any(ApplicationControllerCallback.class));
}
Also used : Status(org.onap.appc.client.lcm.model.Status) ApplicationControllerTaskRequest(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest) ApplicationControllerCallback(org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback) Test(org.junit.Test)

Example 25 with Status

use of org.onap.appc.client.lcm.model.Status in project so by onap.

the class ApplicationControllerAction method getSnapshotActionAppcStatus.

private Status getSnapshotActionAppcStatus(String msoRequestId, String vnfId, String controllerType, String identityUrl, String vmIds, String vserverIds) throws IOException, ApplicationControllerOrchestratorException {
    Status appcStatus = null;
    String vmId = "";
    String vserverId = "";
    ObjectMapper mapper = new ObjectMapper();
    List<String> vmIdJsonList = mapper.readValue(vmIds, new TypeReference<List<String>>() {
    });
    List<String> vserverIdJsonList = mapper.readValue(vserverIds, new TypeReference<List<String>>() {
    });
    int i = 0;
    while (i < vmIdJsonList.size()) {
        vmId = vmIdJsonList.get(i);
        vserverId = vserverIdJsonList.get(i);
        Optional<String> vserverIdString = Optional.of(vserverId);
        appcStatus = snapshotAction(msoRequestId, vnfId, vmId, vserverIdString, identityUrl, controllerType);
        i++;
    }
    return appcStatus;
}
Also used : Status(org.onap.appc.client.lcm.model.Status) List(java.util.List) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

Status (org.onap.appc.client.lcm.model.Status)42 Test (org.junit.Test)27 HashMap (java.util.HashMap)14 Action (org.onap.appc.client.lcm.model.Action)10 BaseTest (org.onap.so.BaseTest)10 ConfigurationParameters (org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters)8 Parameters (org.onap.so.adapters.appc.orchestrator.client.beans.Parameters)8 RequestParameters (org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters)8 JSONObject (org.json.JSONObject)4 ArrayList (java.util.ArrayList)3 ResumeTrafficOutput (org.onap.appc.client.lcm.model.ResumeTrafficOutput)3 AppcClientException (org.onap.appc.client.lcm.exceptions.AppcClientException)2 ActionIdentifiers (org.onap.appc.client.lcm.model.ActionIdentifiers)2 Payload (org.onap.appc.client.lcm.model.Payload)2 ApplicationControllerCallback (org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback)2 Identity (org.onap.so.adapters.appc.orchestrator.client.beans.Identity)2 ApplicationControllerTaskRequest (org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1