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 <rohit.yadav@shapeblue.com>
This commit is contained in:
Jayapal 2015-02-23 13:51:20 +05:30 committed by Rohit Yadav
parent 9562175ca7
commit dd6bcde65b
2 changed files with 20 additions and 15 deletions

View File

@ -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));
}

View File

@ -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,