put shell scripts to a seperate directory in XS use same scripts for both XS and XCP
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5a062e15 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5a062e15 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5a062e15 Branch: refs/heads/master Commit: 5a062e155ccb2ce19cb80ba87287d66b45cb33cd Parents: 30db5d6 Author: Anthony Xu <anthony...@citrix.com> Authored: Tue Dec 3 01:36:24 2013 -0800 Committer: Anthony Xu <anthony...@citrix.com> Committed: Tue Dec 3 02:05:34 2013 -0800 ---------------------------------------------------------------------- .../xen/resource/CitrixResourceBase.java | 9 + .../xenserver/copy_vhd_from_secondarystorage.sh | 2 +- .../xenserver/copy_vhd_to_secondarystorage.sh | 5 +- .../create_privatetemplate_from_snapshot.sh | 2 +- scripts/vm/hypervisor/xenserver/launch_hb.sh | 4 +- scripts/vm/hypervisor/xenserver/ovs-pvlan | 10 +- .../xenserver/setup_heartbeat_file.sh | 2 +- .../vm/hypervisor/xenserver/setupxenserver.sh | 2 +- scripts/vm/hypervisor/xenserver/swiftxen | 2 +- .../vm/hypervisor/xenserver/upgrade_snapshot.sh | 2 +- scripts/vm/hypervisor/xenserver/vmops | 35 +- scripts/vm/hypervisor/xenserver/vmopsSnapshot | 10 +- scripts/vm/hypervisor/xenserver/vmopspremium | 21 +- .../xcposs/copy_vhd_from_secondarystorage.sh | 188 --- .../xcposs/copy_vhd_to_secondarystorage.sh | 130 -- .../create_privatetemplate_from_snapshot.sh | 138 -- scripts/vm/hypervisor/xenserver/xcposs/patch | 68 +- scripts/vm/hypervisor/xenserver/xcposs/vmops | 1493 ------------------ .../hypervisor/xenserver/xcposs/vmopsSnapshot | 601 ------- .../vm/hypervisor/xenserver/xcposs/vmopspremium | 146 -- scripts/vm/hypervisor/xenserver/xcpserver/patch | 58 +- scripts/vm/hypervisor/xenserver/xenheartbeat.sh | 2 +- .../vm/hypervisor/xenserver/xenserver56/patch | 58 +- .../hypervisor/xenserver/xenserver56fp1/patch | 58 +- .../vm/hypervisor/xenserver/xenserver60/patch | 68 +- 25 files changed, 219 insertions(+), 2895 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index a8ab691..2a5913a 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -301,6 +301,9 @@ import com.cloud.vm.VirtualMachine.PowerState; import com.cloud.vm.VirtualMachine.State; import com.cloud.vm.snapshot.VMSnapshot; +import com.cloud.utils.ssh.SSHCmdHelper; + + /** * CitrixResourceBase encapsulates the calls to the XenServer Xapi process * to perform the required functionalities for CloudStack. @@ -5299,6 +5302,12 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe } com.trilead.ssh2.Session session = sshConnection.openSession(); + + String cmd = "mkdir -p /opt/cloud/bin"; + if (!SSHCmdHelper.sshExecuteCmd(sshConnection, cmd)) { + throw new CloudRuntimeException("Cannot create directory /opt/cloud/bin on XenServer hosts"); + } + SCPClient scp = new SCPClient(sshConnection); List<File> files = getPatchFiles(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/copy_vhd_from_secondarystorage.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/copy_vhd_from_secondarystorage.sh b/scripts/vm/hypervisor/xenserver/copy_vhd_from_secondarystorage.sh index 2443891..098015a 100755 --- a/scripts/vm/hypervisor/xenserver/copy_vhd_from_secondarystorage.sh +++ b/scripts/vm/hypervisor/xenserver/copy_vhd_from_secondarystorage.sh @@ -89,7 +89,7 @@ fi -VHDUTIL="/opt/xensource/bin/vhd-util" +VHDUTIL="/opt/cloud/bin/vhd-util" copyvhd() { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/copy_vhd_to_secondarystorage.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/copy_vhd_to_secondarystorage.sh b/scripts/vm/hypervisor/xenserver/copy_vhd_to_secondarystorage.sh index b315c07..36e8222 100755 --- a/scripts/vm/hypervisor/xenserver/copy_vhd_to_secondarystorage.sh +++ b/scripts/vm/hypervisor/xenserver/copy_vhd_to_secondarystorage.sh @@ -78,6 +78,7 @@ if [ $? -ne 0 ]; then fi vhdfile=$localmp/${vdiuuid}.vhd +VHDUTIL="vhd-util" if [ $type == "nfs" -o $type == "ext" ]; then dd if=/var/run/sr-mount/$sruuid/${vdiuuid}.vhd of=$vhdfile bs=2M @@ -94,7 +95,7 @@ elif [ $type == "lvmoiscsi" -o $type == "lvm" -o $type == "lvmohba" ]; then cleanup exit 0 fi - size=$(vhd-util query -s -n /dev/VG_XenStorage-$sruuid/VHD-$vdiuuid) + size=$($VHDUTIL query -s -n /dev/VG_XenStorage-$sruuid/VHD-$vdiuuid) if [ $? -ne 0 ]; then echo "10#can not get physical size of /dev/VG_XenStorage-$sruuid/VHD-$vdiuuid" cleanup @@ -112,7 +113,7 @@ elif [ $type == "lvmoiscsi" -o $type == "lvm" -o $type == "lvmohba" ]; then fi #in byte unit size=$((size<<21)) - vhd-util modify -s $size -n $vhdfile + $VHDUTIL modify -s $size -n $vhdfile if [ $? -ne 0 ]; then rm -f $vhdfile echo "11#failed to change $vhdfile physical size" http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/create_privatetemplate_from_snapshot.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/create_privatetemplate_from_snapshot.sh b/scripts/vm/hypervisor/xenserver/create_privatetemplate_from_snapshot.sh index 93b8705..d39fc6e 100755 --- a/scripts/vm/hypervisor/xenserver/create_privatetemplate_from_snapshot.sh +++ b/scripts/vm/hypervisor/xenserver/create_privatetemplate_from_snapshot.sh @@ -96,7 +96,7 @@ if [ $? -ne 0 ]; then exit 0 fi -VHDUTIL="/opt/xensource/bin/vhd-util" +VHDUTIL="/opt/cloud/bin/vhd-util" copyvhd() { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/launch_hb.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/launch_hb.sh b/scripts/vm/hypervisor/xenserver/launch_hb.sh index b8a36a0..289eb5f 100755 --- a/scripts/vm/hypervisor/xenserver/launch_hb.sh +++ b/scripts/vm/hypervisor/xenserver/launch_hb.sh @@ -33,7 +33,7 @@ if [ -z $2 ]; then exit 3 fi -if [ ! -f /opt/xensource/bin/xenheartbeat.sh ]; then +if [ ! -f /opt/cloud/bin/xenheartbeat.sh ]; then printf "Error: Unable to find xenheartbeat.sh to launch\n" exit 4 fi @@ -42,5 +42,5 @@ for psid in `ps -ef | grep xenheartbeat | grep -v grep | awk '{print $2}'`; do kill $psid done -nohup /opt/xensource/bin/xenheartbeat.sh $1 $2 >/dev/null 2>/dev/null & +nohup /opt/cloud/bin/xenheartbeat.sh $1 $2 >/dev/null 2>/dev/null & echo "======> DONE <======" http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/ovs-pvlan ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/ovs-pvlan b/scripts/vm/hypervisor/xenserver/ovs-pvlan index c821870..8579b55 100755 --- a/scripts/vm/hypervisor/xenserver/ovs-pvlan +++ b/scripts/vm/hypervisor/xenserver/ovs-pvlan @@ -32,11 +32,11 @@ from time import localtime as _localtime, asctime as _asctime xePath = "/opt/xensource/bin/xe" lib.setup_logging("/var/log/ovs-pvlan.log") -dhcpSetupPath = "/opt/xensource/bin/ovs-pvlan-dhcp-host.sh" -vmSetupPath = "/opt/xensource/bin/ovs-pvlan-vm.sh" -getDhcpIfacePath = "/opt/xensource/bin/ovs-get-dhcp-iface.sh" -pvlanCleanupPath = "/opt/xensource/bin/ovs-pvlan-cleanup.sh" -getBridgePath = "/opt/xensource/bin/ovs-get-bridge.sh" +dhcpSetupPath = "/opt/cloud/bin/ovs-pvlan-dhcp-host.sh" +vmSetupPath = "/opt/cloud/bin/ovs-pvlan-vm.sh" +getDhcpIfacePath = "/opt/cloud/bin/ovs-get-dhcp-iface.sh" +pvlanCleanupPath = "/opt/cloud/bin/ovs-pvlan-cleanup.sh" +getBridgePath = "/opt/cloud/bin/ovs-get-bridge.sh" def echo(fn): def wrapped(*v, **k): http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/setup_heartbeat_file.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/setup_heartbeat_file.sh b/scripts/vm/hypervisor/xenserver/setup_heartbeat_file.sh index fb178e0..125fc2b 100755 --- a/scripts/vm/hypervisor/xenserver/setup_heartbeat_file.sh +++ b/scripts/vm/hypervisor/xenserver/setup_heartbeat_file.sh @@ -58,7 +58,7 @@ if [ `xe pbd-list sr-uuid=$2 | grep -B 1 $1 | wc -l` -eq 0 ]; then exit 0 fi -hbfile=/opt/xensource/bin/heartbeat +hbfile=/opt/cloud/bin/heartbeat if [ "$3" = "true" ]; then http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/setupxenserver.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/setupxenserver.sh b/scripts/vm/hypervisor/xenserver/setupxenserver.sh index 311f273..14ba1c2 100755 --- a/scripts/vm/hypervisor/xenserver/setupxenserver.sh +++ b/scripts/vm/hypervisor/xenserver/setupxenserver.sh @@ -55,7 +55,7 @@ mv -n /etc/cron.daily/logrotate /etc/cron.hourly 2>&1 echo 1048576 >/proc/sys/fs/aio-max-nr # empty heartbeat -cat /dev/null > /opt/xensource/bin/heartbeat +cat /dev/null > /opt/cloud/bin/heartbeat # empty knownhost cat /dev/null > /root/.ssh/known_hosts http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/swiftxen ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/swiftxen b/scripts/vm/hypervisor/xenserver/swiftxen index 1be4107..46229e3 100644 --- a/scripts/vm/hypervisor/xenserver/swiftxen +++ b/scripts/vm/hypervisor/xenserver/swiftxen @@ -34,7 +34,7 @@ def echo(fn): return res return wrapped -SWIFT = "/opt/xensource/bin/swift" +SWIFT = "/opt/cloud/bin/swift" MAX_SEG_SIZE = 5 * 1024 * 1024 * 1024 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/upgrade_snapshot.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/upgrade_snapshot.sh b/scripts/vm/hypervisor/xenserver/upgrade_snapshot.sh index 6dcc2c45..4cb2e30 100755 --- a/scripts/vm/hypervisor/xenserver/upgrade_snapshot.sh +++ b/scripts/vm/hypervisor/xenserver/upgrade_snapshot.sh @@ -87,7 +87,7 @@ if [ $? -ne 0 ]; then exit 0 fi -VHDUTIL="/opt/xensource/bin/vhd-util" +VHDUTIL="/opt/cloud/bin/vhd-util" upgradeSnapshot() { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/vmops ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/vmops b/scripts/vm/hypervisor/xenserver/vmops index 3f11960..5383e0e 100755 --- a/scripts/vm/hypervisor/xenserver/vmops +++ b/scripts/vm/hypervisor/xenserver/vmops @@ -22,7 +22,10 @@ import os, sys, time import XenAPIPlugin -sys.path.extend(["/opt/xensource/sm/", "/usr/local/sbin/", "/sbin/"]) +if os.path.exists("/opt/xensource/sm"): + sys.path.extend(["/opt/xensource/sm/", "/usr/local/sbin/", "/sbin/"]) +if os.path.exists("/usr/lib/xcp/sm"): + sys.path.extend(["/usr/lib/xcp/sm/", "/usr/local/sbin/", "/sbin/"]) import base64 import hostvmstats import socket @@ -48,7 +51,7 @@ def add_to_VCPUs_params_live(session, args): value = args['value'] vmname = args['vmname'] try: - cmd = ["bash", "/opt/xensource/bin/add_to_vcpus_params_live.sh", vmname, key, value] + cmd = ["bash", "/opt/cloud/bin/add_to_vcpus_params_live.sh", vmname, key, value] txt = util.pread2(cmd) except: return 'false' @@ -67,7 +70,7 @@ def gethostvmstats(session, args): def setup_iscsi(session, args): uuid=args['uuid'] try: - cmd = ["bash", "/opt/xensource/bin/setup_iscsi.sh", uuid] + cmd = ["bash", "/opt/cloud/bin/setup_iscsi.sh", uuid] txt = util.pread2(cmd) except: txt = '' @@ -78,7 +81,7 @@ def setup_iscsi(session, args): def getgateway(session, args): mgmt_ip = args['mgmtIP'] try: - cmd = ["bash", "/opt/xensource/bin/network_info.sh", "-g", mgmt_ip] + cmd = ["bash", "/opt/cloud/bin/network_info.sh", "-g", mgmt_ip] txt = util.pread2(cmd) except: txt = '' @@ -89,7 +92,7 @@ def getgateway(session, args): def preparemigration(session, args): uuid = args['uuid'] try: - cmd = ["/opt/xensource/bin/make_migratable.sh", uuid] + cmd = ["/opt/cloud/bin/make_migratable.sh", uuid] util.pread2(cmd) txt = 'success' except: @@ -101,7 +104,7 @@ def preparemigration(session, args): @echo def setIptables(session, args): try: - cmd = ["/bin/bash", "/opt/xensource/bin/setupxenserver.sh"] + cmd = ["/bin/bash", "/opt/cloud/bin/setupxenserver.sh"] txt = util.pread2(cmd) txt = 'success' except: @@ -130,7 +133,7 @@ def pingdomr(session, args): def kill_copy_process(session, args): namelabel = args['namelabel'] try: - cmd = ["bash", "/opt/xensource/bin/kill_copy_process.sh", namelabel] + cmd = ["bash", "/opt/cloud/bin/kill_copy_process.sh", namelabel] txt = util.pread2(cmd) except: txt = 'false' @@ -144,7 +147,7 @@ def pingxenserver(session, args): def pingtest(session, args): sargs = args['args'] cmd = sargs.split(' ') - cmd.insert(0, "/opt/xensource/bin/pingtest.sh") + cmd.insert(0, "/opt/cloud/bin/pingtest.sh") cmd.insert(0, "/bin/bash") try: txt = util.pread2(cmd) @@ -159,7 +162,7 @@ def pingtest(session, args): def savePassword(session, args): sargs = args['args'] cmd = sargs.split(' ') - cmd.insert(0, "/opt/xensource/bin/save_password_to_domr.sh") + cmd.insert(0, "/opt/cloud/bin/save_password_to_domr.sh") cmd.insert(0, "/bin/bash") try: txt = util.pread2(cmd) @@ -174,7 +177,7 @@ def savePassword(session, args): def saveDhcpEntry(session, args): sargs = args['args'] cmd = sargs.split(' ') - cmd.insert(0, "/opt/xensource/bin/dhcp_entry.sh") + cmd.insert(0, "/opt/cloud/bin/dhcp_entry.sh") cmd.insert(0, "/bin/bash") try: txt = util.pread2(cmd) @@ -236,7 +239,7 @@ def setLinkLocalIP(session, args): def setFirewallRule(session, args): sargs = args['args'] cmd = sargs.split(' ') - cmd.insert(0, "/opt/xensource/bin/call_firewall.sh") + cmd.insert(0, "/opt/cloud/bin/call_firewall.sh") cmd.insert(0, "/bin/bash") try: txt = util.pread2(cmd) @@ -251,7 +254,7 @@ def setFirewallRule(session, args): def routerProxy(session, args): sargs = args['args'] cmd = sargs.split(' ') - cmd.insert(0, "/opt/xensource/bin/router_proxy.sh") + cmd.insert(0, "/opt/cloud/bin/router_proxy.sh") cmd.insert(0, "/bin/bash") try: txt = util.pread2(cmd) @@ -269,7 +272,7 @@ def routerProxy(session, args): def setLoadBalancerRule(session, args): sargs = args['args'] cmd = sargs.split(' ') - cmd.insert(0, "/opt/xensource/bin/call_loadbalancer.sh") + cmd.insert(0, "/opt/cloud/bin/call_loadbalancer.sh") cmd.insert(0, "/bin/bash") try: txt = util.pread2(cmd) @@ -296,7 +299,7 @@ def configdnsmasq(session, args): def createipAlias(session, args): args = args['args'] cmd = args.split(' ') - cmd.insert(0, "/opt/xensource/bin/createipAlias.sh") + cmd.insert(0, "/opt/cloud/bin/createipAlias.sh") cmd.insert(0, "bin/bash") try: txt=util.pread2(cmd) @@ -310,7 +313,7 @@ def createipAlias(session, args): def deleteipAlias(session, args): args = args['args'] cmd = args.split(' ') - cmd.insert(0, "/opt/xensource/bin/deleteipAlias.sh") + cmd.insert(0, "/opt/cloud/bin/deleteipAlias.sh") cmd.insert(0, "bin/bash") try: txt=util.pread2(cmd) @@ -1616,7 +1619,7 @@ def network_rules(session, args): def bumpUpPriority(session, args): sargs = args['args'] cmd = sargs.split(' ') - cmd.insert(0, "/opt/xensource/bin/bumpUpPriority.sh") + cmd.insert(0, "/opt/cloud/bin/bumpUpPriority.sh") cmd.insert(0, "/bin/bash") try: txt = util.pread2(cmd) http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/vmopsSnapshot ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/vmopsSnapshot b/scripts/vm/hypervisor/xenserver/vmopsSnapshot index f638de4..00ed93a 100755 --- a/scripts/vm/hypervisor/xenserver/vmopsSnapshot +++ b/scripts/vm/hypervisor/xenserver/vmopsSnapshot @@ -22,7 +22,11 @@ import os, sys, time import XenAPIPlugin -sys.path.append("/opt/xensource/sm/") +if os.path.exists("/opt/xensource/sm"): + sys.path.extend(["/opt/xensource/sm/", "/usr/local/sbin/", "/sbin/"]) +if os.path.exists("/usr/lib/xcp/sm"): + sys.path.extend(["/usr/lib/xcp/sm/", "/usr/local/sbin/", "/sbin/"]) + import SR, VDI, SRCommand, util, lvutil from util import CommandException import vhdutil @@ -35,7 +39,7 @@ import cleanup import stat import random -VHD_UTIL = '/opt/xensource/bin/vhd-util' +VHDUTIL = "vhd-util" VHD_PREFIX = 'VHD-' CLOUD_DIR = '/var/run/cloud_mount' @@ -263,7 +267,7 @@ def getParentOfSnapshot(snapshotUuid, primarySRPath, isISCSI): def setParent(parent, child): try: - cmd = [VHD_UTIL, "modify", "-p", parent, "-n", child] + cmd = [VHDUTIL, "modify", "-p", parent, "-n", child] txt = util.pread2(cmd) except: errMsg = "Unexpected error while trying to set parent of " + child + " to " + parent http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/vmopspremium ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/vmopspremium b/scripts/vm/hypervisor/xenserver/vmopspremium index 38ec2e8..d7d0c6f 100755 --- a/scripts/vm/hypervisor/xenserver/vmopspremium +++ b/scripts/vm/hypervisor/xenserver/vmopspremium @@ -22,7 +22,10 @@ import os, sys, time import XenAPIPlugin -sys.path.append("/opt/xensource/sm/") +if os.path.exists("/opt/xensource/sm"): + sys.path.extend(["/opt/xensource/sm/", "/usr/local/sbin/", "/sbin/"]) +if os.path.exists("/usr/lib/xcp/sm"): + sys.path.extend(["/usr/lib/xcp/sm/", "/usr/local/sbin/", "/sbin/"]) import util import socket @@ -52,7 +55,7 @@ def create_privatetemplate_from_snapshot(session, args): snapshotPath = args['snapshotPath'] tmpltLocalDir = args['tmpltLocalDir'] try: - cmd = ["bash", "/opt/xensource/bin/create_privatetemplate_from_snapshot.sh",snapshotPath, templatePath, tmpltLocalDir] + cmd = ["bash", "/opt/cloud/bin/create_privatetemplate_from_snapshot.sh",snapshotPath, templatePath, tmpltLocalDir] txt = util.pread2(cmd) except: txt = '10#failed' @@ -63,7 +66,7 @@ def upgrade_snapshot(session, args): templatePath = args['templatePath'] snapshotPath = args['snapshotPath'] try: - cmd = ["bash", "/opt/xensource/bin/upgrate_snapshot.sh",snapshotPath, templatePath] + cmd = ["bash", "/opt/cloud/bin/upgrate_snapshot.sh",snapshotPath, templatePath] txt = util.pread2(cmd) except: txt = '10#failed' @@ -75,7 +78,7 @@ def copy_vhd_to_secondarystorage(session, args): vdiuuid = args['vdiuuid'] sruuid = args['sruuid'] try: - cmd = ["bash", "/opt/xensource/bin/copy_vhd_to_secondarystorage.sh", mountpoint, vdiuuid, sruuid] + cmd = ["bash", "/opt/cloud/bin/copy_vhd_to_secondarystorage.sh", mountpoint, vdiuuid, sruuid] txt = util.pread2(cmd) except: txt = '10#failed' @@ -87,7 +90,7 @@ def copy_vhd_from_secondarystorage(session, args): sruuid = args['sruuid'] namelabel = args['namelabel'] try: - cmd = ["bash", "/opt/xensource/bin/copy_vhd_from_secondarystorage.sh", mountpoint, sruuid, namelabel] + cmd = ["bash", "/opt/cloud/bin/copy_vhd_from_secondarystorage.sh", mountpoint, sruuid, namelabel] txt = util.pread2(cmd) except: txt = '10#failed' @@ -98,7 +101,7 @@ def setup_heartbeat_sr(session, args): host = args['host'] sr = args['sr'] try: - cmd = ["bash", "/opt/xensource/bin/setup_heartbeat_sr.sh", host, sr] + cmd = ["bash", "/opt/cloud/bin/setup_heartbeat_sr.sh", host, sr] txt = util.pread2(cmd) except: txt = '' @@ -110,7 +113,7 @@ def setup_heartbeat_file(session, args): sr = args['sr'] add = args['add'] try: - cmd = ["bash", "/opt/xensource/bin/setup_heartbeat_file.sh", host, sr, add] + cmd = ["bash", "/opt/cloud/bin/setup_heartbeat_file.sh", host, sr, add] txt = util.pread2(cmd) except: txt = '' @@ -121,7 +124,7 @@ def check_heartbeat(session, args): host = args['host'] interval = args['interval'] try: - cmd = ["bash", "/opt/xensource/bin/check_heartbeat.sh", host, interval] + cmd = ["bash", "/opt/cloud/bin/check_heartbeat.sh", host, interval] txt = util.pread2(cmd) except: txt='' @@ -133,7 +136,7 @@ def heartbeat(session, args): host = args['host'] interval = args['interval'] try: - cmd = ["/bin/bash", "/opt/xensource/bin/launch_hb.sh", host, interval] + cmd = ["/bin/bash", "/opt/cloud/bin/launch_hb.sh", host, interval] txt = util.pread2(cmd) except: txt='fail' http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/xcposs/copy_vhd_from_secondarystorage.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/xcposs/copy_vhd_from_secondarystorage.sh b/scripts/vm/hypervisor/xenserver/xcposs/copy_vhd_from_secondarystorage.sh deleted file mode 100755 index a4e977b..0000000 --- a/scripts/vm/hypervisor/xenserver/xcposs/copy_vhd_from_secondarystorage.sh +++ /dev/null @@ -1,188 +0,0 @@ -#!/bin/bash -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -#set -x - -usage() { - printf "Usage: %s [vhd file in secondary storage] [uuid of the source sr] [name label] \n" $(basename $0) -} - -cleanup() -{ - if [ ! -z $localmp ]; then - umount -fl $localmp - if [ $? -eq 0 ]; then - rmdir $localmp - fi - fi -} - -if [ -z $1 ]; then - usage - echo "2#no mountpoint" - exit 0 -else - mountpoint=${1%/*} - vhdfilename=${1##*/} -fi - -if [ -z $2 ]; then - usage - echo "3#no uuid of the source sr" - exit 0 -else - sruuid=$2 -fi - -type=$(xe sr-param-get uuid=$sruuid param-name=type) -if [ $? -ne 0 ]; then - echo "4#sr $sruuid doesn't exist" - exit 0 -fi - -if [ -z $3 ]; then - usage - echo "3#no namelabel" - exit 0 -else - namelabel=$3 -fi - -localmp=/var/run/cloud_mount/$(uuidgen -r) - -mkdir -p $localmp -if [ $? -ne 0 ]; then - echo "5#can't make dir $localmp" - exit 0 -fi - -mount -o tcp,soft,ro,timeo=133,retrans=1 $mountpoint $localmp -if [ $? -ne 0 ]; then - echo "6#can't mount $mountpoint to $localmp" - exit 0 -fi - -vhdfile=$localmp/$vhdfilename -if [ ${vhdfile%.vhd} == ${vhdfile} ] ; then - vhdfile=$(ls $vhdfile/*.vhd) - if [ $? -ne 0 ]; then - echo "7#There is no vhd file under $mountpoint" - cleanup - exit 0 - fi -fi - - - -VHDUTIL="/usr/bin/vhd-util" - -copyvhd() -{ - local desvhd=$1 - local srcvhd=$2 - local vsize=$3 - local type=$4 - local parent=`$VHDUTIL query -p -n $srcvhd` - if [ $? -ne 0 ]; then - echo "30#failed to query $srcvhd" - cleanup - exit 0 - fi - if [ "${parent##*vhd has}" = " no parent" ]; then - dd if=$srcvhd of=$desvhd bs=2M - if [ $? -ne 0 ]; then - echo "31#failed to dd $srcvhd to $desvhd" - cleanup - exit 0 - fi - if [ $type != "nfs" -a $type != "ext" -a $type != "file" ]; then - dd if=$srcvhd of=$desvhd bs=512 seek=$(($(($vsize/512))-1)) count=1 - $VHDUTIL modify -s $vsize -n $desvhd - if [ $? -ne 0 ]; then - echo "32#failed to set new vhd physical size for vdi vdi $uuid" - cleanup - exit 0 - fi - fi - else - copyvhd $desvhd $parent $vsize $type - $VHDUTIL coalesce -p $desvhd -n $srcvhd - if [ $? -ne 0 ]; then - echo "32#failed to coalesce $desvhd to $srcvhd" - cleanup - exit 0 - fi - fi -} - -size=$($VHDUTIL query -v -n $vhdfile) -uuid=$(xe vdi-create sr-uuid=$sruuid virtual-size=${size}MiB type=user name-label=$namelabel) -if [ $? -ne 0 ]; then - echo "9#can not create vdi in sr $sruuid" - cleanup - exit 0 -fi - - -if [ $type == "nfs" -o $type == "ext" ]; then - desvhd=/run/sr-mount/$sruuid/$uuid.vhd - copyvhd $desvhd $vhdfile 0 $type - -elif [ $type == "lvmoiscsi" -o $type == "lvm" -o $type == "lvmohba" ]; then - lvsize=$(xe vdi-param-get uuid=$uuid param-name=physical-utilisation) - if [ $? -ne 0 ]; then - echo "12#failed to get physical size of vdi $uuid" - cleanup - exit 0 - fi - desvhd=/dev/VG_XenStorage-$sruuid/VHD-$uuid - lvchange -ay $desvhd - if [ $? -ne 0 ]; then - echo "10#lvm can not make VDI $uuid visible" - cleanup - exit 0 - fi - copyvhd $desvhd $vhdfile $lvsize $type -elif [ $type == "file" ]; then - pbd=`xe sr-param-list uuid=$sruuid |grep PBDs | awk '{print $3}'` - path=`xe pbd-param-list uuid=$pbd |grep device-config |awk '{print $4}'` - desvhd=$path/$uuid.vhd - copyvhd $desvhd $vhdfile 0 $type - -else - echo "15#doesn't support sr type $type" - cleanup - exit 0 -fi - -$VHDUTIL set -n $desvhd -f "hidden" -v "0" > /dev/null -if [ $? -ne 0 ]; then - echo "21#failed to set hidden to 0 $desvhd" - cleanup - exit 0 -fi -xe sr-scan uuid=$sruuid -if [ $? -ne 0 ]; then - echo "14#failed to scan sr $sruuid" - cleanup - exit 0 -fi - -echo "0#$uuid" -cleanup -exit 0 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/xcposs/copy_vhd_to_secondarystorage.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/xcposs/copy_vhd_to_secondarystorage.sh b/scripts/vm/hypervisor/xenserver/xcposs/copy_vhd_to_secondarystorage.sh deleted file mode 100755 index b315c07..0000000 --- a/scripts/vm/hypervisor/xenserver/xcposs/copy_vhd_to_secondarystorage.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/bash -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -#set -x - -usage() { - printf "Usage: %s [mountpoint in secondary storage] [uuid of the source vdi] [uuid of the source sr]\n" $(basename $0) -} - -cleanup() -{ - if [ ! -z $localmp ]; then - umount $localmp - if [ $? -eq 0 ]; then - rmdir $localmp - fi - fi -} - -if [ -z $1 ]; then - usage - echo "1#no mountpoint" - exit 0 -else - mountpoint=$1 -fi - -if [ -z $2 ]; then - usage - echo "2#no uuid of the source sr" - exit 0 -else - vdiuuid=$2 -fi - - -if [ -z $3 ]; then - usage - echo "3#no uuid of the source sr" - exit 0 -else - sruuid=$3 -fi - -type=$(xe sr-param-get uuid=$sruuid param-name=type) -if [ $? -ne 0 ]; then - echo "4#sr $sruuid doesn't exist" - exit 0 -fi - -localmp=/var/run/cloud_mount/$(uuidgen -r) - -mkdir -p $localmp -if [ $? -ne 0 ]; then - echo "5#can't make dir $localmp" - exit 0 -fi - -mount -o tcp,soft,timeo=133,retrans=1 $mountpoint $localmp -if [ $? -ne 0 ]; then - echo "6#can't mount $mountpoint to $localmp" - exit 0 -fi - -vhdfile=$localmp/${vdiuuid}.vhd - -if [ $type == "nfs" -o $type == "ext" ]; then - dd if=/var/run/sr-mount/$sruuid/${vdiuuid}.vhd of=$vhdfile bs=2M - if [ $? -ne 0 ]; then - rm -f $vhdfile - echo "8#failed to copy /var/run/sr-mount/$sruuid/${vdiuuid}.vhd to secondarystorage" - cleanup - exit 0 - fi -elif [ $type == "lvmoiscsi" -o $type == "lvm" -o $type == "lvmohba" ]; then - lvchange -ay /dev/VG_XenStorage-$sruuid/VHD-$vdiuuid - if [ $? -ne 0 ]; then - echo "9#lvm can not make VDI $vdiuuid visible" - cleanup - exit 0 - fi - size=$(vhd-util query -s -n /dev/VG_XenStorage-$sruuid/VHD-$vdiuuid) - if [ $? -ne 0 ]; then - echo "10#can not get physical size of /dev/VG_XenStorage-$sruuid/VHD-$vdiuuid" - cleanup - exit 0 - fi -#in 2M unit - size=$((size>>21)) - size=$((size+1)) - dd if=/dev/VG_XenStorage-$sruuid/VHD-$vdiuuid of=$vhdfile bs=2M count=$size - if [ $? -ne 0 ]; then - rm -f $vhdfile - echo "8#failed to copy /dev/VG_XenStorage-$sruuid/VHD-$vdiuuid to secondarystorage" - cleanup - exit 0 - fi -#in byte unit - size=$((size<<21)) - vhd-util modify -s $size -n $vhdfile - if [ $? -ne 0 ]; then - rm -f $vhdfile - echo "11#failed to change $vhdfile physical size" - cleanup - exit 0 - fi -else - echo "15#doesn't support sr type $type" - cleanup - exit 0 -fi - -echo "0#$vdiuuid" -cleanup -exit 0 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/xcposs/create_privatetemplate_from_snapshot.sh ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/xcposs/create_privatetemplate_from_snapshot.sh b/scripts/vm/hypervisor/xenserver/xcposs/create_privatetemplate_from_snapshot.sh deleted file mode 100755 index 4213efc..0000000 --- a/scripts/vm/hypervisor/xenserver/xcposs/create_privatetemplate_from_snapshot.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -#set -x - -usage() { - printf "Usage: %s [vhd file in secondary storage] [template directory in secondary storage] [template local dir] \n" $(basename $0) -} -options='tcp,soft,timeo=133,retrans=1' -cleanup() -{ - if [ ! -z $snapshotdir ]; then - umount $snapshotdir - if [ $? -eq 0 ]; then - rmdir $snapshotdir - fi - fi - if [ ! -z $templatedir ]; then - umount $templatedir - if [ $? -eq 0 ]; then - rmdir $templatedir - fi - fi -} - -if [ -z $1 ]; then - usage - echo "2#no vhd file path" - exit 0 -else - snapshoturl=${1%/*} - vhdfilename=${1##*/} -fi - -if [ -z $2 ]; then - usage - echo "3#no template path" - exit 0 -else - templateurl=$2 -fi - -if [ -z $3 ]; then - usage - echo "3#no template local dir" - exit 0 -else - tmpltLocalDir=$3 -fi - - -snapshotdir=/run/cloud_mount/$(uuidgen -r) -mkdir -p $snapshotdir -if [ $? -ne 0 ]; then - echo "4#cann't make dir $snapshotdir" - exit 0 -fi - -mount -o $options $snapshoturl $snapshotdir -if [ $? -ne 0 ]; then - rmdir $snapshotdir - echo "5#can not mount $snapshoturl to $snapshotdir" - exit 0 -fi - -templatedir=/run/cloud_mount/$tmpltLocalDir -mkdir -p $templatedir -if [ $? -ne 0 ]; then - templatedir="" - cleanup - echo "6#cann't make dir $templatedir" - exit 0 -fi - -mount -o $options $templateurl $templatedir -if [ $? -ne 0 ]; then - rmdir $templatedir - templatedir="" - cleanup - echo "7#can not mount $templateurl to $templatedir" - exit 0 -fi - -VHDUTIL="vhd-util" - -copyvhd() -{ - local desvhd=$1 - local srcvhd=$2 - local parent= - parent=`$VHDUTIL query -p -n $srcvhd` - if [ $? -ne 0 ]; then - echo "30#failed to query $srcvhd" - cleanup - exit 0 - fi - if [[ "${parent}" =~ " no parent" ]]; then - dd if=$srcvhd of=$desvhd bs=2M - if [ $? -ne 0 ]; then - echo "31#failed to dd $srcvhd to $desvhd" - cleanup - exit 0 - fi - else - copyvhd $desvhd $parent - $VHDUTIL coalesce -p $desvhd -n $srcvhd - if [ $? -ne 0 ]; then - echo "32#failed to coalesce $desvhd to $srcvhd" - cleanup - exit 0 - fi - fi -} - -templateuuid=$(uuidgen -r) -desvhd=$templatedir/$templateuuid.vhd -srcvhd=$snapshotdir/$vhdfilename -copyvhd $desvhd $srcvhd -virtualSize=`$VHDUTIL query -v -n $desvhd` -physicalSize=`ls -l $desvhd | awk '{print $5}'` -cleanup -echo "0#$templateuuid#$physicalSize#$virtualSize" -exit 0 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a062e15/scripts/vm/hypervisor/xenserver/xcposs/patch ---------------------------------------------------------------------- diff --git a/scripts/vm/hypervisor/xenserver/xcposs/patch b/scripts/vm/hypervisor/xenserver/xcposs/patch index 6e1002e..aa551de 100644 --- a/scripts/vm/hypervisor/xenserver/xcposs/patch +++ b/scripts/vm/hypervisor/xenserver/xcposs/patch @@ -27,42 +27,42 @@ # If [source path] starts with '~', then it is path relative to management server home directory. # If [source path] does not start with '/' or '~', then it is relative path to the location of the patch file. NFSSR.py=/usr/lib/xcp/sm -vmops=.,0755,/usr/lib/xcp/plugins +vmops=..,0755,/usr/lib/xcp/plugins ovsgre=..,0755,/usr/lib/xcp/plugins ovstunnel=..,0755,/usr/lib/xcp/plugins -vmopsSnapshot=.,0755,/usr/lib/xcp/plugins +vmopsSnapshot=..,0755,/usr/lib/xcp/plugins hostvmstats.py=..,0755,/usr/lib/xcp/sm systemvm.iso=../../../../../vms,0644,/usr/share/xcp/packages/iso/ id_rsa.cloud=../../../systemvm,0600,/root/.ssh -network_info.sh=..,0755,/usr/lib/xcp/bin -setupxenserver.sh=..,0755,/usr/lib/xcp/bin -make_migratable.sh=..,0755,/usr/lib/xcp/bin -setup_iscsi.sh=..,0755,/usr/lib/xcp/bin -pingtest.sh=../../..,0755,/usr/lib/xcp/bin -dhcp_entry.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin -ipassoc.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin -save_password_to_domr.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin -networkUsage.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin -call_firewall.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin -call_loadbalancer.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin -l2tp_vpn.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin -cloud-setup-bonding.sh=..,0755,/usr/lib/xcp/bin -copy_vhd_to_secondarystorage.sh=.,0755,/usr/lib/xcp/bin -copy_vhd_from_secondarystorage.sh=.,0755,/usr/lib/xcp/bin -setup_heartbeat_sr.sh=..,0755,/usr/lib/xcp/bin -setup_heartbeat_file.sh=..,0755,/usr/lib/xcp/bin -check_heartbeat.sh=..,0755,/usr/lib/xcp/bin -xenheartbeat.sh=..,0755,/usr/lib/xcp/bin -launch_hb.sh=..,0755,/usr/lib/xcp/bin -vhd-util=..,0755,/usr/lib/xcp/bin -vmopspremium=.,0755,/usr/lib/xcp/plugins -create_privatetemplate_from_snapshot.sh=.,0755,/usr/lib/xcp/bin -upgrade_snapshot.sh=..,0755,/usr/lib/xcp/bin -cloud-clean-vlan.sh=..,0755,/usr/lib/xcp/bin -cloud-prepare-upgrade.sh=..,0755,/usr/lib/xcp/bin -getRouterStatus.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin -bumpUpPriority.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin -getDomRVersion.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin -router_proxy.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin -createipAlias.sh=..,0755,/usr/lib/xcp/bin -deleteipAlias.sh=..,0755,/usr/lib/xcp/bin +network_info.sh=..,0755,/opt/cloud/bin +setupxenserver.sh=..,0755,/opt/cloud/bin +make_migratable.sh=..,0755,/opt/cloud/bin +setup_iscsi.sh=..,0755,/opt/cloud/bin +pingtest.sh=../../..,0755,/opt/cloud/bin +dhcp_entry.sh=../../../../network/domr/,0755,/opt/cloud/bin +ipassoc.sh=../../../../network/domr/,0755,/opt/cloud/bin +save_password_to_domr.sh=../../../../network/domr/,0755,/opt/cloud/bin +networkUsage.sh=../../../../network/domr/,0755,/opt/cloud/bin +call_firewall.sh=../../../../network/domr/,0755,/opt/cloud/bin +call_loadbalancer.sh=../../../../network/domr/,0755,/opt/cloud/bin +l2tp_vpn.sh=../../../../network/domr/,0755,/opt/cloud/bin +cloud-setup-bonding.sh=..,0755,/opt/cloud/bin +copy_vhd_to_secondarystorage.sh=..,0755,/opt/cloud/bin +copy_vhd_from_secondarystorage.sh=..,0755,/opt/cloud/bin +setup_heartbeat_sr.sh=..,0755,/opt/cloud/bin +setup_heartbeat_file.sh=..,0755,/opt/cloud/bin +check_heartbeat.sh=..,0755,/opt/cloud/bin +xenheartbeat.sh=..,0755,/opt/cloud/bin +launch_hb.sh=..,0755,/opt/cloud/bin +vhd-util=..,0755,/opt/cloud/bin +vmopspremium=..,0755,/usr/lib/xcp/plugins +create_privatetemplate_from_snapshot.sh=..,0755,/opt/cloud/bin +upgrade_snapshot.sh=..,0755,/opt/cloud/bin +cloud-clean-vlan.sh=..,0755,/opt/cloud/bin +cloud-prepare-upgrade.sh=..,0755,/opt/cloud/bin +getRouterStatus.sh=../../../../network/domr/,0755,/opt/cloud/bin +bumpUpPriority.sh=../../../../network/domr/,0755,/opt/cloud/bin +getDomRVersion.sh=../../../../network/domr/,0755,/opt/cloud/bin +router_proxy.sh=../../../../network/domr/,0755,/opt/cloud/bin +createipAlias.sh=..,0755,/opt/cloud/bin +deleteipAlias.sh=..,0755,/opt/cloud/bin