From 654ef79b89bd1bf07bc2552161890e0a0c47557d Mon Sep 17 00:00:00 2001 From: Pedro Dias Date: Mon, 26 Oct 2015 18:07:24 +0000 Subject: [PATCH] clvm OFF --- share/pkgs/CentOS/opennebula.sudoers | 2 +- share/pkgs/Debian7/opennebula.sudoers | 2 +- share/pkgs/Debian8/opennebula.sudoers | 2 +- share/pkgs/Ubuntu/opennebula.sudoers | 2 +- share/pkgs/openSUSE/opennebula.sudoers | 2 +- share/sudoers/sudo_commands.rb | 2 +- src/mad/sh/scripts_common.sh | 1 + src/tm_mad/fs_lvm/postmigrate | 6 +++++- src/tm_mad/fs_lvm/premigrate | 6 +++++- src/tm_mad/shared/postmigrate | 16 +++++++++++++++- src/tm_mad/shared/premigrate | 16 +++++++++++++++- 11 files changed, 47 insertions(+), 10 deletions(-) diff --git a/share/pkgs/CentOS/opennebula.sudoers b/share/pkgs/CentOS/opennebula.sudoers index 8d0ba48304..0037b4207c 100644 --- a/share/pkgs/CentOS/opennebula.sudoers +++ b/share/pkgs/CentOS/opennebula.sudoers @@ -3,7 +3,7 @@ Defaults:oneadmin secure_path = /sbin:/bin:/usr/sbin:/usr/bin Cmnd_Alias ONE_MISC = /bin/dd, /sbin/mkfs, /bin/sync Cmnd_Alias ONE_NET = /usr/sbin/brctl, /sbin/ebtables, /sbin/iptables, /sbin/ip, /usr/sbin/ipset -Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay +Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay, /sbin/lvchange Cmnd_Alias ONE_ISCSI = /sbin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm diff --git a/share/pkgs/Debian7/opennebula.sudoers b/share/pkgs/Debian7/opennebula.sudoers index 4f75c3eec7..f528f187f1 100644 --- a/share/pkgs/Debian7/opennebula.sudoers +++ b/share/pkgs/Debian7/opennebula.sudoers @@ -3,7 +3,7 @@ Defaults:oneadmin secure_path = /sbin:/bin:/usr/sbin:/usr/bin Cmnd_Alias ONE_MISC = /bin/dd, /sbin/mkfs, /bin/sync Cmnd_Alias ONE_NET = /sbin/brctl, /sbin/ebtables, /sbin/iptables, /sbin/ip, /usr/sbin/ipset -Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay +Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay, /sbin/lvchange Cmnd_Alias ONE_ISCSI = /usr/bin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm diff --git a/share/pkgs/Debian8/opennebula.sudoers b/share/pkgs/Debian8/opennebula.sudoers index e3fefb1138..1207d3f095 100644 --- a/share/pkgs/Debian8/opennebula.sudoers +++ b/share/pkgs/Debian8/opennebula.sudoers @@ -3,7 +3,7 @@ Defaults:oneadmin secure_path = /sbin:/bin:/usr/sbin:/usr/bin Cmnd_Alias ONE_MISC = /bin/dd, /sbin/mkfs, /bin/sync Cmnd_Alias ONE_NET = /sbin/brctl, /sbin/ebtables, /sbin/iptables, /sbin/ip, /sbin/ipset -Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay +Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay, /sbin/lvchange Cmnd_Alias ONE_ISCSI = /usr/bin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm diff --git a/share/pkgs/Ubuntu/opennebula.sudoers b/share/pkgs/Ubuntu/opennebula.sudoers index e3fefb1138..1207d3f095 100644 --- a/share/pkgs/Ubuntu/opennebula.sudoers +++ b/share/pkgs/Ubuntu/opennebula.sudoers @@ -3,7 +3,7 @@ Defaults:oneadmin secure_path = /sbin:/bin:/usr/sbin:/usr/bin Cmnd_Alias ONE_MISC = /bin/dd, /sbin/mkfs, /bin/sync Cmnd_Alias ONE_NET = /sbin/brctl, /sbin/ebtables, /sbin/iptables, /sbin/ip, /sbin/ipset -Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay +Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay, /sbin/lvchange Cmnd_Alias ONE_ISCSI = /usr/bin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm diff --git a/share/pkgs/openSUSE/opennebula.sudoers b/share/pkgs/openSUSE/opennebula.sudoers index 9fc1ed8dda..95c44ad68f 100644 --- a/share/pkgs/openSUSE/opennebula.sudoers +++ b/share/pkgs/openSUSE/opennebula.sudoers @@ -3,7 +3,7 @@ Defaults:oneadmin secure_path = /sbin:/bin:/usr/sbin:/usr/bin Cmnd_Alias ONE_MISC = /usr/bin/dd, /sbin/mkfs, /usr/bin/sync Cmnd_Alias ONE_NET = /sbin/brctl, /usr/sbin/ebtables, /usr/sbin/iptables, /sbin/ip -Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay +Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay, /sbin/lvchange Cmnd_Alias ONE_ISCSI = /sbin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm diff --git a/share/sudoers/sudo_commands.rb b/share/sudoers/sudo_commands.rb index 49e6137118..1f9a02db28 100644 --- a/share/sudoers/sudo_commands.rb +++ b/share/sudoers/sudo_commands.rb @@ -23,7 +23,7 @@ KEYS = [:MISC , :NET , :LVM , :ISCSI , :OVS , :XEN] CMDS = { :MISC => %w(dd mkfs sync), :NET => %w(brctl ebtables iptables ip ipset), - :LVM => %w(lvcreate lvremove lvrename lvs vgdisplay), + :LVM => %w(lvcreate lvremove lvrename lvs vgdisplay lvchange), :ISCSI => %w(iscsiadm tgt-admin tgtadm), :OVS => %w(ovs-ofctl ovs-vsctl), :XEN => %w(xentop xl xm) diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 5c0d1a85b7..009337c92f 100644 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -31,6 +31,7 @@ ISCSIADM=iscsiadm LVCREATE=lvcreate LVREMOVE=lvremove LVRENAME=lvrename +LVCHANGE=lvchange LVS=lvs LN=ln MD5SUM=md5sum diff --git a/src/tm_mad/fs_lvm/postmigrate b/src/tm_mad/fs_lvm/postmigrate index d580dd8260..b802d8c675 120000 --- a/src/tm_mad/fs_lvm/postmigrate +++ b/src/tm_mad/fs_lvm/postmigrate @@ -1 +1,5 @@ -../common/postmigrate \ No newline at end of file +source /var/lib/one/remotes/scripts_common.sh + +ssh_exec_and_log $1 "sudo sync; sudo lvs; sudo lvchange -an $3" "Error running fs_lvm postmigrate" + +exit 0 \ No newline at end of file diff --git a/src/tm_mad/fs_lvm/premigrate b/src/tm_mad/fs_lvm/premigrate index 0e108a8a26..e42d3ce704 120000 --- a/src/tm_mad/fs_lvm/premigrate +++ b/src/tm_mad/fs_lvm/premigrate @@ -1 +1,5 @@ -../common/premigrate \ No newline at end of file +source /var/lib/one/remotes/scripts_common.sh + +ssh_exec_and_log $2 "sudo sync; sudo lvs; sudo lvchange -ay $3" "Error running fs_lvm premigrate" + +exit 1 \ No newline at end of file diff --git a/src/tm_mad/shared/postmigrate b/src/tm_mad/shared/postmigrate index d580dd8260..228fa50dac 120000 --- a/src/tm_mad/shared/postmigrate +++ b/src/tm_mad/shared/postmigrate @@ -1 +1,15 @@ -../common/postmigrate \ No newline at end of file +DRIVER_PATH=$(dirname $0) + +DISK_COUNT=$(onevm show $4 -x|grep DISK_ID| wc -l) +TMS=$(onevm show $4 -x|sed -rn 's/[[:space:]]*<\!\[CDATA\[([^]]*).*/\1/p') + +XPATH="${DRIVER_PATH}/../../datastore/xpath.rb -b $7" + +for i in `seq 1 $DISK_COUNT`; do + TM=`echo $TMS|cut -d" " -f$i` + DISK_ID=`echo $i-1 |bc` + DEV=`ssh $1 "readlink $3/disk.$DISK_ID"` + ${DRIVER_PATH}/../$TMS/postmigrate "$1" "$2" "$DEV" +done + +exit 0 \ No newline at end of file diff --git a/src/tm_mad/shared/premigrate b/src/tm_mad/shared/premigrate index 0e108a8a26..8e4c7add89 120000 --- a/src/tm_mad/shared/premigrate +++ b/src/tm_mad/shared/premigrate @@ -1 +1,15 @@ -../common/premigrate \ No newline at end of file +DRIVER_PATH=$(dirname $0) + +DISK_COUNT=$(onevm show $4 -x|grep DISK_ID| wc -l) +TMS=$(onevm show $4 -x|sed -rn 's/[[:space:]]*<\!\[CDATA\[([^]]*).*/\1/p') + +XPATH="${DRIVER_PATH}/../../datastore/xpath.rb -b $7" + +for i in `seq 1 $DISK_COUNT`; do + TM=`echo $TMS|cut -d" " -f$i` + DISK_ID=`echo $i-1 |bc` + DEV=`ssh $1 "readlink $3/disk.$DISK_ID"` + ${DRIVER_PATH}/../$TMS/premigrate "$1" "$2" "$DEV" +done + +exit 0 \ No newline at end of file