Skip to content

Commit 619f014

Browse files
author
Jayapal
committed
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.
1 parent 1f72548 commit 619f014

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,17 @@ public ExecutionResult executeInVR(String routerIP, String script, String args)
571571
@Override
572572
public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) {
573573
Connection conn = getConnection();
574-
String rc = callHostPlugin(conn, "vmops", "createFileInDomr", "domrip", routerIp, "filepath", path + filename, "filecontents", content);
575-
s_logger.debug ("VR Config file " + filename + " got created in VR with ip " + routerIp + " with content \n" + content);
576-
// Fail case would be start with "fail#"
574+
String hostPath = "/tmp/";
575+
576+
s_logger.debug("Copying VR with ip " + routerIp +" config file into host "+ _host.ip );
577+
try {
578+
SshHelper.scpTo(_host.ip, 22, _username, null, _password.peek(), hostPath, content.getBytes(), filename, null);
579+
} catch (Exception e) {
580+
s_logger.warn("scp VR config file into host " + _host.ip + " failed with exception " + e.getMessage().toString());
581+
}
582+
583+
String rc = callHostPlugin(conn, "vmops", "createFileInDomr", "domrip", routerIp, "srcfilepath", hostPath + filename, "dstfilepath", path);
584+
s_logger.debug ("VR Config file " + filename + " got created in VR, ip " + routerIp + " with content \n" + content);
577585
return new ExecutionResult(rc.startsWith("succ#"), rc.substring(5));
578586
}
579587

scripts/vm/hypervisor/xenserver/vmops

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,20 +204,17 @@ def createFile(session, args):
204204

205205
@echo
206206
def createFileInDomr(session, args):
207-
file_path = args['filepath']
208-
file_contents = args['filecontents']
207+
src_filepath = args['srcfilepath']
208+
dst_path = args['dstfilepath']
209209
domrip = args['domrip']
210+
txt=""
210211
try:
211-
tmpfile = util.pread2(['mktemp']).strip()
212-
f = open(tmpfile, "w")
213-
f.write(file_contents)
214-
f.close()
215-
target = "root@" + domrip + ":" + file_path
216-
txt = util.pread2(['scp','-P','3922','-q','-o','StrictHostKeyChecking=no','-i','/root/.ssh/id_rsa.cloud',tmpfile, target])
217-
util.pread2(['rm',tmpfile])
212+
target = "root@" + domrip + ":" + dst_path
213+
txt = util.pread2(['scp','-P','3922','-q','-o','StrictHostKeyChecking=no','-i','/root/.ssh/id_rsa.cloud',src_filepath, target])
214+
util.pread2(['rm',src_filepath])
218215
txt = 'succ#' + txt
219216
except:
220-
logging.debug("failed to create file " + file_path + " in VR, contain: " + file_contents)
217+
logging.debug("failed to copy file " + src_filepath + " from host to VR with ip " + domrip)
221218
txt = 'fail#' + txt
222219
return txt
223220

@@ -1486,8 +1483,8 @@ if __name__ == "__main__":
14861483
"destroy_network_rules_for_vm":destroy_network_rules_for_vm,
14871484
"default_network_rules_systemvm":default_network_rules_systemvm,
14881485
"network_rules_vmSecondaryIp":network_rules_vmSecondaryIp,
1489-
"get_rule_logs_for_vms":get_rule_logs_for_vms,
1490-
"add_to_VCPUs_params_live":add_to_VCPUs_params_live,
1486+
"get_rule_logs_for_vms":get_rule_logs_for_vms,
1487+
"add_to_VCPUs_params_live":add_to_VCPUs_params_live,
14911488
"setLinkLocalIP":setLinkLocalIP,
14921489
"cleanup_rules":cleanup_rules,
14931490
"createFileInDomr":createFileInDomr,

0 commit comments

Comments
 (0)