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;
}
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());
}
}
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;
}
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));
}
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;
}
Aggregations