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 6d777e4f5ff..a4aa4b6ae56 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)); } diff --git a/scripts/vm/hypervisor/xenserver/vmops b/scripts/vm/hypervisor/xenserver/vmops index 62a60bb0657..a73084a6af8 100755 --- a/scripts/vm/hypervisor/xenserver/vmops +++ b/scripts/vm/hypervisor/xenserver/vmops @@ -204,20 +204,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 @@ -1486,8 +1483,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,