use of com.iwave.ext.command.CommandOutput in project coprhd-controller by CoprHD.
the class ListRDisksCommandTest method setup.
@BeforeClass
public static synchronized void setup() {
CommandOutput commandOutput = new CommandOutput(OUTPUT, null, 0);
command = createMockBuilder(ListRDisksCommand.class).withConstructor().addMockedMethod("getOutput").createMock();
EasyMock.expect(command.getOutput()).andReturn(commandOutput).anyTimes();
EasyMock.replay(command);
}
use of com.iwave.ext.command.CommandOutput in project coprhd-controller by CoprHD.
the class MultipathCommand method processError.
@Override
protected void processError() throws CommandException {
CommandOutput output = getOutput();
if (isNotLoaded(output)) {
throw new MultipathException("multipath kernel driver is not loaded", output);
}
if (isNotInstalled(output)) {
throw new MultipathException("multipath is not installed", output);
}
super.processError();
}
use of com.iwave.ext.command.CommandOutput in project coprhd-controller by CoprHD.
the class LinuxMountUtils method mountPath.
public void mountPath(String path) throws InternalException {
MountCommand command = new MountCommand(STD_TIMEOUT);
command.setPath(path);
command.addArgument("; if [ $? -eq 124 ] ; then >&2 echo TIMEOUT ; else >&2 echo SUCCESSFUL ; fi");
_log.info("mount command:" + command.getResolvedCommandLine());
cli.executeCommand(command);
CommandOutput output = command.getOutput();
if (output.getStderr().contains("TIMEOUT")) {
ComputeSystemControllerException exception = ComputeSystemControllerException.exceptions.commandTimedOut(host.getHostName());
throw exception;
} else {
String errMessage = output.getStderr().replace("SUCCESSFUL", "").replace("\n", "");
if (!errMessage.isEmpty()) {
ComputeSystemControllerException exception = ComputeSystemControllerException.exceptions.unableToMount(host.getHostName(), new Exception(errMessage));
throw exception;
}
}
}
use of com.iwave.ext.command.CommandOutput in project coprhd-controller by CoprHD.
the class CustomServicesRemoteAnsibleExecution method executeTask.
@Override
public CustomServicesTaskResult executeTask() throws Exception {
ExecutionUtils.currentContext().logInfo("customServicesScriptExecution.statusInfo", step.getId(), step.getFriendlyName());
final CommandOutput result;
try {
final CustomServicesDBRemoteAnsiblePrimitive primitive = dbClient.queryObject(CustomServicesDBRemoteAnsiblePrimitive.class, step.getOperation());
if (null == primitive) {
logger.error("Error retrieving the ansible primitive from DB. {} not found in DB", step.getOperation());
ExecutionUtils.currentContext().logError("customServicesOperationExecution.logStatus", step.getId(), step.getFriendlyName(), "\"Error retrieving the Remote Ansible primitive from DB.");
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed(step.getOperation() + " not found in DB");
}
result = executeRemoteCmd(AnsibleHelper.makeExtraArg(input, step), primitive);
} catch (final Exception e) {
ExecutionUtils.currentContext().logError("customServicesOperationExecution.logStatus", step.getId(), step.getFriendlyName(), "Custom Service Task Failed" + e);
logger.error("Exception:", e);
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Custom Service Task Failed" + e);
}
ExecutionUtils.currentContext().logInfo("customServicesScriptExecution.doneInfo", step.getId(), step.getFriendlyName());
if (result == null) {
ExecutionUtils.currentContext().logError("customServicesOperationExecution.logStatus", step.getId(), step.getFriendlyName(), "Remote Ansible execution Failed");
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Remote Ansible execution Failed");
}
logger.info("CustomScript Execution result:output{} error{} exitValue:{}", result.getStdout(), result.getStderr(), result.getExitValue());
final String parsedOut = AnsibleHelper.parseOut(result.getStdout());
if (!StringUtils.isEmpty(parsedOut)) {
ExecutionUtils.currentContext().logInfo("customServicesScriptExecution.doneInfo", step.getId(), step.getFriendlyName());
return new CustomServicesScriptTaskResult(parsedOut, result.getStdout(), result.getStderr(), result.getExitValue());
}
return new CustomServicesScriptTaskResult(result.getStdout(), result.getStdout(), result.getStderr(), result.getExitValue());
}
Aggregations