Changeset 2266


Ignore:
Timestamp:
Mar 18, 2009, 10:04:36 PM (16 years ago)
Author:
price
Message:

pv-fixup: update for non-clustered operation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/pv-fixup/pv-fixup

    r2253 r2266  
    2929#  - pvmove all the LVs to the temporary PV
    3030
     31yamlkeys () {
     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
     38lvsleft () {
     39  lvs -o name,devices xenvg \
     40    | perl -lane "print \$F[0] if (\$F[1] =~ m|$DISK|)"
     41}
     42
     43vmstolvs () {
     44  perl -pe 's/^/d_/;s/$/_hda/'
     45}
     46
     47totalsize () {
     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
    3154movelv () {
    3255  echo pvmoving $1...
    33   lvchange -an $1
    3456  pvmove -i 10 -n $1 $2
    35   lvchange -ay $1
    3657}
    3758
     59ssh root@xvm remctl remote web listvms \
     60 | yamlkeys
     61 > runningvms
     62LVM_SYSTEM_DIR=/root/lvm lvsleft \
     63 | grep '^d_.*_hda$' \
     64 | grep -v -xf <(vmstolvs <runningvms) \
     65 > offvmlvs
     66for lv in $(offvmlvs); do
     67  LVM_SYSTEM_DIR=/root/lvm movelv $VG/$lv $DISK
     68done
    3869#FOREACH host:
    39 for lv in $(lvs -o lv_name --noheadings $VG); do
    40   movelv $VG/$lv $DISK
     70for lv in $(invirt-listvms | yamlkeys | vmstolvs); do
     71  LVM_SYSTEM_DIR=/root/lvm movelv $VG/$lv $DISK
    4172done
    4273#done
    4374
    44 # hopefully empty:
    45 lvs $VG -o lv_name,devices | grep $DISK
    46 # if not, do some more movelv
     75ssh root@xvm remctl remote web listvms \
     76 | perl -lne 'print if (s/^  cdrom: //)' \
     77 > usedcdroms
     78LVM_SYSTEM_DIR=/root/lvm lvsleft \
     79 | grep ^image_ \
     80 | grep -v -xf <(perl -pe "s|/dev/$VG/||" usedcdroms) \
     81 > offcdlvs
     82for lv in $(offcdlvs); do
     83  LVM_SYSTEM_DIR=/root/lvm movelv $VG/$lv $DISK
     84done
    4785
    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) ]
    5091
    5192
Note: See TracChangeset for help on using the changeset viewer.