Search in sources :

Example 1 with ApplicationControllerVnf

use of org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf 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)

Example 2 with ApplicationControllerVnf

use of org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf in project so by onap.

the class ApplicationControllerTaskImplITTest method setup.

@Before
public void setup() {
    request = new ApplicationControllerTaskRequest();
    request.setRequestorId("testRequestorId");
    request.setBookName("testBookName");
    request.setControllerType("testControllerType");
    request.setFileParameters("testFileParams");
    request.setIdentityUrl("testIdentityUrl");
    request.setNewSoftwareVersion("2.0");
    request.setExistingSoftwareVersion("1.0");
    request.setOperationsTimeout("30");
    ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf();
    applicationControllerVnf.setVnfHostIpAddress("100.100");
    applicationControllerVnf.setVnfId("testVnfId");
    applicationControllerVnf.setVnfName("testVnfName");
    request.setApplicationControllerVnf(applicationControllerVnf);
    listener = new ApplicationControllerCallback(null, externalTaskService, appCSupport);
}
Also used : ApplicationControllerVnf(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf) ApplicationControllerTaskRequest(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest) ApplicationControllerCallback(org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback) Before(org.junit.Before)

Example 3 with ApplicationControllerVnf

use of org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf in project so by onap.

the class AppcOrchestratorPreProcessor method addVmInfoToAppcTaskRequest.

public void addVmInfoToAppcTaskRequest(BuildingBlockExecution execution) {
    try {
        ApplicationControllerTaskRequest appcTaskRequest = (ApplicationControllerTaskRequest) execution.getVariable("appcOrchestratorRequest");
        ArrayList<String> vmIdList = execution.getVariable("vmIdList");
        ArrayList<String> vserverIdList = execution.getVariable("vserverIdList");
        Integer vmIndex = (Integer) execution.getVariable("vmIndex");
        if (vmIdList != null && !vmIdList.isEmpty() && vserverIdList != null && !vserverIdList.isEmpty()) {
            execution.setVariable("vmIdListSize", vmIdList.size());
            if (vmIndex < vmIdList.size()) {
                ApplicationControllerVm applicationControllerVm = new ApplicationControllerVm();
                applicationControllerVm.setVmId(vmIdList.get(vmIndex));
                applicationControllerVm.setVserverId(vserverIdList.get(vmIndex));
                if (appcTaskRequest.getApplicationControllerVnf() == null) {
                    ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf();
                    appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf);
                }
                appcTaskRequest.getApplicationControllerVnf().setApplicationControllerVm(applicationControllerVm);
                execution.setVariable("appcOrchestratorRequest", appcTaskRequest);
                vmIndex++;
                execution.setVariable("vmIndex", vmIndex);
            }
        }
    } catch (Exception e) {
        logger.error("Error adding VM info to ApplicationControllerTaskRequest Object", e);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
    }
}
Also used : ApplicationControllerVm(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm) ApplicationControllerVnf(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf) ApplicationControllerTaskRequest(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) ValidationException(org.onap.so.exceptions.ValidationException)

Example 4 with ApplicationControllerVnf

use of org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf in project so by onap.

the class AppcOrchestratorPreProcessorTest method addVmInfoToAppcTaskRequestTest.

@Test
public void addVmInfoToAppcTaskRequestTest() {
    ApplicationControllerTaskRequest appcTaskRequest = new ApplicationControllerTaskRequest();
    ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf();
    appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf);
    execution.setVariable("appcOrchestratorRequest", appcTaskRequest);
    ArrayList<String> vmIdList = new ArrayList<String>();
    vmIdList.add("http://VSERVER-link.com");
    vmIdList.add("http://VSERVER-link.com");
    vmIdList.add("http://VSERVER-link.com");
    execution.setVariable("vmIdList", vmIdList);
    ArrayList<String> vserverIdList = new ArrayList<String>();
    vserverIdList.add("1b3f44e5-d96d-4aac-bd9a-310e8cfb0af5");
    vserverIdList.add("14551849-1e70-45cd-bc5d-a256d49548a2");
    vserverIdList.add("48bd7f11-408f-417c-b834-b41c1b98f7d7");
    execution.setVariable("vserverIdList", vserverIdList);
    execution.setVariable("vmIndex", 1);
    appcOrchestratorPreProcessor.addVmInfoToAppcTaskRequest(execution);
    Integer nextVmIndex = execution.getVariable("vmIndex");
    assertThat(nextVmIndex == 2);
    Integer vmIdListSize = execution.getVariable("vmIdListSize");
    assertThat(vmIdListSize == 3);
    appcTaskRequest = execution.getVariable("appcOrchestratorRequest");
    assertEquals(appcTaskRequest.getApplicationControllerVnf().getApplicationControllerVm().getVserverId(), "14551849-1e70-45cd-bc5d-a256d49548a2");
    assertEquals(appcTaskRequest.getApplicationControllerVnf().getApplicationControllerVm().getVmId(), "http://VSERVER-link.com");
}
Also used : ApplicationControllerVnf(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf) ApplicationControllerTaskRequest(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with ApplicationControllerVnf

use of org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf in project so by onap.

the class ApplicationControllerTaskImplTest method setup.

@Before
public void setup() {
    request = new ApplicationControllerTaskRequest();
    request.setBookName("testBookName");
    request.setControllerType("testControllerType");
    request.setFileParameters("testFileParams");
    request.setIdentityUrl("testIdentityUrl");
    request.setNewSoftwareVersion("2.0");
    request.setExistingSoftwareVersion("1.0");
    request.setOperationsTimeout("30");
    request.setRequestorId("testRequestorId");
    Map<String, String> reqConfigParams = new HashMap<>();
    reqConfigParams.put("name1", "value1");
    reqConfigParams.put("name2", "value2");
    request.setConfigParams(reqConfigParams);
    ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf();
    applicationControllerVnf.setVnfHostIpAddress("100.100");
    applicationControllerVnf.setVnfId("testVnfId");
    applicationControllerVnf.setVnfName("testVnfName");
    request.setApplicationControllerVnf(applicationControllerVnf);
    listener = new ApplicationControllerCallback(null, null, null);
}
Also used : ApplicationControllerVnf(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf) ApplicationControllerTaskRequest(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest) HashMap(java.util.HashMap) ApplicationControllerCallback(org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback) Before(org.junit.Before)

Aggregations

ApplicationControllerTaskRequest (org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest)5 ApplicationControllerVnf (org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf)5 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 ApplicationControllerCallback (org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback)2 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)2 ValidationException (org.onap.so.exceptions.ValidationException)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Action (org.onap.appc.client.lcm.model.Action)1 ApplicationControllerVm (org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm)1 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)1 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)1 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)1 ControllerSelectionReference (org.onap.so.db.catalog.beans.ControllerSelectionReference)1