From: Adam Glasgall <glasgall@mit.edu>
Date: Mon, 2 Jun 2014 23:48:47 +0000 (-0400)
Subject: initial commit of scripts
X-Git-Url: http://xvm.mit.edu/gitweb/invirt/scripts/mass-pvmove-vms.git/commitdiff_plain/refs/heads/master?hp=c32af53f3e749c0ae9a735d65d79ec110a167351

initial commit of scripts
---

diff --git a/do-move.sh b/do-move.sh
new file mode 100755
index 0000000..04c1920
--- /dev/null
+++ b/do-move.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+set -e
+set -x
+
+machine=$1
+ip=`getent hosts $machine.xvm.mit.edu | cut -f1 -d' '`
+disk=/dev/xenvg/d_${machine}_hda
+xm save d_$machine $machine.state
+if dmsetup info xenvg-pvmove0 >/dev/null 2>&1; then
+    dmsetup remove xenvg-pvmove0
+fi
+lvchange -an $disk
+lvchange -aey $disk
+time pvmove -v -d -n $disk /dev/mapper/22* /dev/mapper/3600*
+lvchange -aen $disk
+lvchange -ay $disk
+xm restore $machine.state
+arpspoof -i $(invirt-getconf xen.iface) -t 18.181.0.1 $ip &
+sleep 10
+kill -9 `pidof arpspoof`
+rm $machine.state
diff --git a/move-it.sh b/move-it.sh
new file mode 100755
index 0000000..6dbbb2a
--- /dev/null
+++ b/move-it.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -e
+set -x
+#filename=$1
+#exec 3<$filename
+tempfile=`mktemp`
+exec 3<"$1"
+ssh -k root@xh8.mit.edu 'pvdisplay -m /dev/mapper/22*' > $tempfile
+while read -u 3 machine; do 
+    echo $machine
+    disk=/dev/xenvg/d_${machine}_hda
+    if grep -q $disk $tempfile; then
+	host=`ssh -k root@xvm.mit.edu remctl xvm-remote control $machine listhost`
+	if [ -n $host ]; then	    
+ 	    scp do-move.sh root@$host:/tmp/
+ 	    ssh root@$host chmod +x /tmp/do-move.sh
+	    ssh root@$host /tmp/do-move.sh $machine
+	    sleep 10
+	fi
+    fi
+done
+