CLOUDSTACK-6314: Use SSH commands for Xen VR execution

Instead of XAPI, which would make XenServer unnecessary busy.
This commit is contained in:
Sheng Yang 2014-04-04 14:57:52 -07:00
parent c312078aac
commit f29e4e21eb
2 changed files with 9 additions and 19 deletions

View File

@ -170,6 +170,7 @@ import com.cloud.utils.Ternary;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
import com.cloud.utils.ssh.SSHCmdHelper;
import com.cloud.utils.ssh.SshHelper;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.PowerState;
@ -558,10 +559,14 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
@Override
public ExecutionResult executeInVR(String routerIP, String script, String args, int timeout) {
Connection conn = getConnection();
String rc = callHostPluginAsync(conn, "vmops", "routerProxy", timeout, "args", script + " " + routerIP + " " + args);
// Fail case would be start with "fail#"
return new ExecutionResult(rc.startsWith("succ#"), rc.substring(5));
Pair<Boolean, String> result;
try {
result = SshHelper.sshExecute(_host.ip, 22, _username, null, _password.peek(), "/opt/cloud/bin/router_proxy.sh " + script + " " + routerIP + " " + args,
60000, 60000, timeout * 1000);
} catch (Exception e) {
return new ExecutionResult(false, e.getMessage());
}
return new ExecutionResult(result.first(), result.second());
}
@Override

View File

@ -197,20 +197,6 @@ def setLinkLocalIP(session, args):
txt = 'success'
return txt
@echo
def routerProxy(session, args):
sargs = args['args']
cmd = sargs.split(' ')
cmd.insert(0, "/opt/cloud/bin/router_proxy.sh")
cmd.insert(0, "/bin/bash")
try:
txt = util.pread2(cmd)
txt = 'succ#' + txt
except:
logging.debug("routerProxy command " + sargs + " failed " )
txt = 'fail#' + txt
return txt
@echo
def createFile(session, args):
file_path = args['filepath']
@ -1495,7 +1481,6 @@ if __name__ == "__main__":
XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi,
"getgateway": getgateway, "preparemigration": preparemigration,
"setIptables": setIptables, "pingdomr": pingdomr, "pingxenserver": pingxenserver,
"routerProxy": routerProxy,
"createFile": createFile, "deleteFile": deleteFile,
"network_rules":network_rules,
"can_bridge_firewall":can_bridge_firewall, "default_network_rules":default_network_rules,