use of org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm 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;
}
use of org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm 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);
}
}
Aggregations