Created
February 5, 2018 16:14
-
-
Save hoonetorg/9ca13558251984fbfa56da4ddece96d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VM=$1 | |
DESTHOST=$2 | |
[ -z "$VM" ] && exit 1 | |
[ -z "$DESTHOST" ] && exit 1 | |
(virsh list --name |grep -w "$VM") || exit 1 | |
echo "$VM is running here" | |
DRBDMANAGERESs="`virsh domblklist $VM |grep /dev/drbd/by-res/|perl -pe 's;^.*/dev/drbd/by-res/(.*)/[0-9]+\s*$;$1 ;g'`" | |
for DRBDMANAGERES in $DRBDMANAGERESs; do | |
drbdmanage net-options --allow-two-primaries yes --resource $DRBDMANAGERES || exit 1 | |
echo "allow two primaries is set for disk $DRBDMANAGERES" | |
done | |
echo "allow two primaries is set for disks: $DRBDMANAGERESs" | |
virsh migrate $VM qemu+ssh://$DESTHOST/system --live --p2p --undefinesource --verbose --compressed --auto-converge | |
for DRBDMANAGERES in $DRBDMANAGERESs; do | |
drbdmanage net-options --unset-allow-two-primaries --resource $DRBDMANAGERES || exit 1 | |
echo "allow two primaries is unset for disk $DRBDMANAGERES" | |
done | |
echo "allow two primaries is unset for disks: $DRBDMANAGERESs" | |
echo "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment