Repository: cloudstack Updated Branches: refs/heads/4.5 9562175ca -> 1f97f9404
CLOUDSTACK-8298: Update copying large size VR config file in xenserver When there is large size VR configuration (aggregate commands) copying data to VR using vmops plugin was failed because of the ARG_MAX size limitation. The configuration data size is around 300KB. Updated this to create file in host by scp with file contents. This will create file in host. Then copy the file from the host to VR using hte vmops createFileInDomr method. In host file get created in /tmp/ with name VR-<UUID>.cfg, once it copied to VR this file will be removed. (cherry picked from commit 619f0142555d2245e3fa90036f825525191b31bd) Signed-off-by: Rohit Yadav <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/dd6bcde6 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/dd6bcde6 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/dd6bcde6 Branch: refs/heads/4.5 Commit: dd6bcde65b3aea47faa5884d22846070b00cf6bd Parents: 9562175 Author: Jayapal <[email protected]> Authored: Mon Feb 23 13:51:20 2015 +0530 Committer: Rohit Yadav <[email protected]> Committed: Wed Mar 4 16:56:07 2015 +0530 ---------------------------------------------------------------------- .../xenserver/resource/CitrixResourceBase.java | 14 ++++++++++--- scripts/vm/hypervisor/xenserver/vmops | 21 +++++++++----------- 2 files changed, 20 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dd6bcde6/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java index f200178..f24b214 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java @@ -571,9 +571,17 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe @Override public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) { Connection conn = getConnection(); - String rc = callHostPlugin(conn, "vmops", "createFileInDomr", "domrip", routerIp, "filepath", path + filename, "filecontents", content); - s_logger.debug ("VR Config file " + filename + " got created in VR with ip " + routerIp + " with content \n" + content); - // Fail case would be start with "fail#" + String hostPath = "/tmp/"; + + s_logger.debug("Copying VR with ip " + routerIp +" config file into host "+ _host.ip ); + try { + SshHelper.scpTo(_host.ip, 22, _username, null, _password.peek(), hostPath, content.getBytes(), filename, null); + } catch (Exception e) { + s_logger.warn("scp VR config file into host " + _host.ip + " failed with exception " + e.getMessage().toString()); + } + + String rc = callHostPlugin(conn, "vmops", "createFileInDomr", "domrip", routerIp, "srcfilepath", hostPath + filename, "dstfilepath", path); + s_logger.debug ("VR Config file " + filename + " got created in VR, ip " + routerIp + " with content \n" + content); return new ExecutionResult(rc.startsWith("succ#"), rc.substring(5)); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dd6bcde6/scripts/vm/hypervisor/xenserver/vmops ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/vmops b/scripts/vm/hypervisor/xenserver/vmops index 59ede97..8abddff 100755 --- a/scripts/vm/hypervisor/xenserver/vmops +++ b/scripts/vm/hypervisor/xenserver/vmops @@ -215,20 +215,17 @@ def createFile(session, args): @echo def createFileInDomr(session, args): - file_path = args['filepath'] - file_contents = args['filecontents'] + src_filepath = args['srcfilepath'] + dst_path = args['dstfilepath'] domrip = args['domrip'] + txt="" try: - tmpfile = util.pread2(['mktemp']).strip() - f = open(tmpfile, "w") - f.write(file_contents) - f.close() - target = "root@" + domrip + ":" + file_path - txt = util.pread2(['scp','-P','3922','-q','-o','StrictHostKeyChecking=no','-i','/root/.ssh/id_rsa.cloud',tmpfile, target]) - util.pread2(['rm',tmpfile]) + target = "root@" + domrip + ":" + dst_path + txt = util.pread2(['scp','-P','3922','-q','-o','StrictHostKeyChecking=no','-i','/root/.ssh/id_rsa.cloud',src_filepath, target]) + util.pread2(['rm',src_filepath]) txt = 'succ#' + txt except: - logging.debug("failed to create file " + file_path + " in VR, contain: " + file_contents) + logging.debug("failed to copy file " + src_filepath + " from host to VR with ip " + domrip) txt = 'fail#' + txt return txt @@ -1497,8 +1494,8 @@ if __name__ == "__main__": "destroy_network_rules_for_vm":destroy_network_rules_for_vm, "default_network_rules_systemvm":default_network_rules_systemvm, "network_rules_vmSecondaryIp":network_rules_vmSecondaryIp, - "get_rule_logs_for_vms":get_rule_logs_for_vms, - "add_to_VCPUs_params_live":add_to_VCPUs_params_live, + "get_rule_logs_for_vms":get_rule_logs_for_vms, + "add_to_VCPUs_params_live":add_to_VCPUs_params_live, "setLinkLocalIP":setLinkLocalIP, "cleanup_rules":cleanup_rules, "createFileInDomr":createFileInDomr,
