Changeset 2266
- Timestamp:
- Mar 18, 2009, 10:04:36 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/pv-fixup/pv-fixup
r2253 r2266 29 29 # - pvmove all the LVs to the temporary PV 30 30 31 yamlkeys () { 32 python -c 'if 1: 33 import yaml, sys 34 mm = yaml.load(sys.stdin.read()) 35 for m in sorted(mm.iterkeys()): print m' 36 } 37 38 lvsleft () { 39 lvs -o name,devices xenvg \ 40 | perl -lane "print \$F[0] if (\$F[1] =~ m|$DISK|)" 41 } 42 43 vmstolvs () { 44 perl -pe 's/^/d_/;s/$/_hda/' 45 } 46 47 totalsize () { 48 # handy for estimating time; output in GiB; pipe in a list of LVs 49 perl -pe 's.^.xenvg/.' \ 50 | xargs lvs -o size --units=g \ 51 | perl -lne '$total += $_; END { print $total; }' 52 } 53 31 54 movelv () { 32 55 echo pvmoving $1... 33 lvchange -an $134 56 pvmove -i 10 -n $1 $2 35 lvchange -ay $136 57 } 37 58 59 ssh root@xvm remctl remote web listvms \ 60 | yamlkeys 61 > runningvms 62 LVM_SYSTEM_DIR=/root/lvm lvsleft \ 63 | grep '^d_.*_hda$' \ 64 | grep -v -xf <(vmstolvs <runningvms) \ 65 > offvmlvs 66 for lv in $(offvmlvs); do 67 LVM_SYSTEM_DIR=/root/lvm movelv $VG/$lv $DISK 68 done 38 69 #FOREACH host: 39 for lv in $( lvs -o lv_name --noheadings $VG); do40 movelv $VG/$lv $DISK70 for lv in $(invirt-listvms | yamlkeys | vmstolvs); do 71 LVM_SYSTEM_DIR=/root/lvm movelv $VG/$lv $DISK 41 72 done 42 73 #done 43 74 44 # hopefully empty: 45 lvs $VG -o lv_name,devices | grep $DISK 46 # if not, do some more movelv 75 ssh root@xvm remctl remote web listvms \ 76 | perl -lne 'print if (s/^ cdrom: //)' \ 77 > usedcdroms 78 LVM_SYSTEM_DIR=/root/lvm lvsleft \ 79 | grep ^image_ \ 80 | grep -v -xf <(perl -pe "s|/dev/$VG/||" usedcdroms) \ 81 > offcdlvs 82 for lv in $(offcdlvs); do 83 LVM_SYSTEM_DIR=/root/lvm movelv $VG/$lv $DISK 84 done 47 85 48 # This is possible if some LVs were used on more than one host during 49 # migration. 86 # deal with $(cat usedcdroms) 87 # deal with s_* LVs 88 # deal with any remaining $(lvsleft) 89 90 [ -z $(lvsleft) ] 50 91 51 92
Note: See TracChangeset
for help on using the changeset viewer.