Search in sources :

Example 1 with RequestParameters

use of org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters 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 2 with RequestParameters

use of org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters in project so by onap.

the class ApplicationControllerTaskImplTest method testExcute_configModify.

@Test
public void testExcute_configModify() throws JsonProcessingException, ApplicationControllerOrchestratorException {
    request.setAction(Action.ConfigModify);
    Parameters parameters = new Parameters();
    RequestParameters requestParams = new RequestParameters();
    requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress());
    parameters.setRequestParameters(requestParams);
    ConfigurationParameters configParams = new ConfigurationParameters();
    Map<String, String> configParamMap = new HashMap<>();
    configParamMap.put("name1", "value1");
    configParamMap.put("name2", "value2");
    configParams.setAdditionalProperties(configParamMap);
    parameters.setConfigurationParameters(configParams);
    Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
    Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", listener, "testRequestorId")).thenReturn(new Status());
    Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
    Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", listener, "testRequestorId");
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Parameters(org.onap.so.adapters.appc.orchestrator.client.beans.Parameters) ConfigurationParameters(org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters) RequestParameters(org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters) HashMap(java.util.HashMap) ConfigurationParameters(org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters) RequestParameters(org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters) Test(org.junit.Test)

Example 3 with RequestParameters

use of org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters in project so by onap.

the class ApplicationControllerTaskImplTest method testExcute_healthCheck.

@Test
public void testExcute_healthCheck() throws JsonProcessingException, ApplicationControllerOrchestratorException {
    request.setAction(Action.HealthCheck);
    Parameters parameters = new Parameters();
    RequestParameters requestParams = new RequestParameters();
    requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress());
    parameters.setRequestParameters(requestParams);
    Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
    Mockito.when(applicationControllerClient.vnfCommand(Action.HealthCheck, "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", listener, "testRequestorId")).thenReturn(new Status());
    Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
    Mockito.verify(applicationControllerClient).vnfCommand(Action.HealthCheck, "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", listener, "testRequestorId");
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Parameters(org.onap.so.adapters.appc.orchestrator.client.beans.Parameters) ConfigurationParameters(org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters) RequestParameters(org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters) RequestParameters(org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters) Test(org.junit.Test)

Aggregations

Status (org.onap.appc.client.lcm.model.Status)3 ConfigurationParameters (org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters)3 Parameters (org.onap.so.adapters.appc.orchestrator.client.beans.Parameters)3 RequestParameters (org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters)3 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 GraphInventoryCommonObjectMapperProvider (org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider)1 Identity (org.onap.so.adapters.appc.orchestrator.client.beans.Identity)1 ApplicationControllerVm (org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm)1