Search in sources :

Example 1 with AllLinesParser

use of com.cloud.utils.script.OutputInterpreter.AllLinesParser in project cloudstack by apache.

the class LibvirtComputingResource method executeInVR.

@Override
public ExecutionResult executeInVR(final String routerIp, final String script, final String args, final Duration timeout) {
    final Script command = new Script(_routerProxyPath, timeout, s_logger);
    final AllLinesParser parser = new AllLinesParser();
    command.add(script);
    command.add(routerIp);
    if (args != null) {
        command.add(args);
    }
    String details = command.execute(parser);
    if (details == null) {
        details = parser.getLines();
    }
    return new ExecutionResult(command.getExitValue() == 0, details);
}
Also used : Script(com.cloud.utils.script.Script) AllLinesParser(com.cloud.utils.script.OutputInterpreter.AllLinesParser) ExecutionResult(com.cloud.utils.ExecutionResult)

Example 2 with AllLinesParser

use of com.cloud.utils.script.OutputInterpreter.AllLinesParser in project CloudStack-archive by CloudStack-extras.

the class KVMHABase method destroyVMs.

protected void destroyVMs(String mountPath) {
    /* if there are VMs using disks under this mount path, destroy them */
    Script cmd = new Script("/bin/bash", _timeout);
    cmd.add("-c");
    cmd.add("ps axu|grep qemu|grep " + mountPath + "* |awk '{print $2}'");
    AllLinesParser parser = new OutputInterpreter.AllLinesParser();
    String result = cmd.execute(parser);
    if (result != null) {
        return;
    }
    String[] pids = parser.getLines().split("\n");
    for (String pid : pids) {
        Script.runSimpleBashScript("kill -9 " + pid);
    }
}
Also used : Script(com.cloud.utils.script.Script) AllLinesParser(com.cloud.utils.script.OutputInterpreter.AllLinesParser)

Example 3 with AllLinesParser

use of com.cloud.utils.script.OutputInterpreter.AllLinesParser in project cloudstack by apache.

the class KVMHABase method destroyVMs.

protected void destroyVMs(String mountPath) {
    /* if there are VMs using disks under this mount path, destroy them */
    Script cmd = new Script("/bin/bash", _timeout);
    cmd.add("-c");
    cmd.add("ps axu|grep qemu|grep " + mountPath + "* |awk '{print $2}'");
    AllLinesParser parser = new OutputInterpreter.AllLinesParser();
    String result = cmd.execute(parser);
    if (result != null) {
        return;
    }
    String[] pids = parser.getLines().split("\n");
    for (String pid : pids) {
        Script.runSimpleBashScript("kill -9 " + pid);
    }
}
Also used : Script(com.cloud.utils.script.Script) AllLinesParser(com.cloud.utils.script.OutputInterpreter.AllLinesParser)

Aggregations

AllLinesParser (com.cloud.utils.script.OutputInterpreter.AllLinesParser)3 Script (com.cloud.utils.script.Script)3 ExecutionResult (com.cloud.utils.ExecutionResult)1