Search in sources :

Example 6 with CommandOutput

use of com.iwave.ext.command.CommandOutput in project coprhd-controller by CoprHD.

the class ListIQNsCommandTest method setup.

@BeforeClass
public static synchronized void setup() {
    CommandOutput commandOutput = new CommandOutput(output, null, 0);
    iqnCommand = createMockBuilder(ListIQNsCommand.class).withConstructor().addMockedMethod("getOutput").createMock();
    EasyMock.expect(iqnCommand.getOutput()).andReturn(commandOutput).anyTimes();
    EasyMock.replay(iqnCommand);
}
Also used : CommandOutput(com.iwave.ext.command.CommandOutput) BeforeClass(org.junit.BeforeClass)

Example 7 with CommandOutput

use of com.iwave.ext.command.CommandOutput in project coprhd-controller by CoprHD.

the class ListMountpointsCommandTest method setup.

@BeforeClass
public static synchronized void setup() {
    CommandOutput commandOutput = new CommandOutput(OUTPUT, null, 0);
    command = createMockBuilder(ListMountPointsCommand.class).withConstructor().addMockedMethod("getOutput").createMock();
    EasyMock.expect(command.getOutput()).andReturn(commandOutput).anyTimes();
    EasyMock.replay(command);
}
Also used : CommandOutput(com.iwave.ext.command.CommandOutput) BeforeClass(org.junit.BeforeClass)

Example 8 with CommandOutput

use of com.iwave.ext.command.CommandOutput in project coprhd-controller by CoprHD.

the class WindowsSystemWinRM method executeCommand.

public CommandOutput executeCommand(String commandLine) throws WinRMException {
    WinRS winrs = new WinRS(target);
    debug("Running: %s", commandLine);
    CommandOutput output = winrs.executeCommandLine(commandLine);
    if (output.getExitValue() != 0) {
        debug("Exit Value: %d", output.getExitValue());
    }
    if (StringUtils.isNotBlank(output.getStdout())) {
        debug("STDOUT: \n%s", output.getStdout());
    }
    if (StringUtils.isNotBlank(output.getStderr())) {
        debug("STDERR: \n%s", output.getStderr());
    }
    return output;
}
Also used : WinRS(com.iwave.ext.windows.winrm.winrs.WinRS) CommandOutput(com.iwave.ext.command.CommandOutput)

Example 9 with CommandOutput

use of com.iwave.ext.command.CommandOutput in project coprhd-controller by CoprHD.

the class WindowsSystemWinRM method diskPart.

public String diskPart(List<String> commands) throws WinRMException {
    StrBuilder sb = new StrBuilder();
    sb.append("(");
    for (int i = 0; i < commands.size(); i++) {
        sb.appendSeparator(" && ", i);
        sb.append("echo ").append(commands.get(i));
    }
    sb.append(" && echo EXIT) | (CHCP 437 & DISKPART)");
    CommandOutput output = executeCommand(sb.toString());
    String error = WindowsUtils.getDiskPartError(output);
    if (StringUtils.isNotBlank(error)) {
        error("DiskPart Error: %s", error);
        throw new WinRMException(String.format("DiskPart Error: %s", error));
    }
    return output.getStdout();
}
Also used : WinRMException(com.iwave.ext.windows.winrm.WinRMException) CommandOutput(com.iwave.ext.command.CommandOutput) StrBuilder(org.apache.commons.lang.text.StrBuilder)

Example 10 with CommandOutput

use of com.iwave.ext.command.CommandOutput in project coprhd-controller by CoprHD.

the class WinRS method execute.

public CommandOutput execute(String command, String... arguments) throws WinRMException {
    String shellId = createShell();
    try {
        String commandId = submitCommand(shellId, command, arguments);
        CommandOutput output = receiveOutput(shellId, commandId);
        if (LOG.isDebugEnabled()) {
            LOG.debug("EXIT CODE: " + output.getExitValue());
            LOG.debug("STDOUT: " + output.getStdout());
            LOG.debug("STDERR: " + output.getStderr());
        }
        return output;
    } finally {
        deleteShell(shellId);
    }
}
Also used : CommandOutput(com.iwave.ext.command.CommandOutput)

Aggregations

CommandOutput (com.iwave.ext.command.CommandOutput)24 BeforeClass (org.junit.BeforeClass)9 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 CommandException (com.iwave.ext.command.CommandException)2 JSchException (com.jcraft.jsch.JSchException)2 IOException (java.io.IOException)2 StrBuilder (org.apache.commons.lang.text.StrBuilder)2 CustomServicesDBRemoteAnsiblePrimitive (com.emc.storageos.db.client.model.uimodels.CustomServicesDBRemoteAnsiblePrimitive)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 Command (com.iwave.ext.command.Command)1 CheckForFileSystemCompatibilityCommand (com.iwave.ext.linux.command.CheckForFileSystemCompatibilityCommand)1 MountCommand (com.iwave.ext.linux.command.MountCommand)1 MultipathCommand (com.iwave.ext.linux.command.MultipathCommand)1 UnmountCommand (com.iwave.ext.linux.command.UnmountCommand)1 WinRMException (com.iwave.ext.windows.winrm.WinRMException)1 WinRS (com.iwave.ext.windows.winrm.winrs.WinRS)1 ChannelExec (com.jcraft.jsch.ChannelExec)1