Add vm-migrate script
This commit is contained in:
parent
4dc0b423b2
commit
33c452464f
|
@ -5,6 +5,7 @@ This repository contain scripts for managing KVM hypervisors used with DRBD and
|
|||
It contains the following scripts.
|
||||
|
||||
- add-vm: create DBRD volumes and virtual machines.
|
||||
- vm-migrate: migrate a DRBD based virtual machine
|
||||
- kvmstats: gives informations about defined virtual machines.
|
||||
|
||||
## Install
|
||||
|
|
24
vm-migrate
Executable file
24
vm-migrate
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
error() {
|
||||
msg="${1:-$(cat /dev/stdin)}"
|
||||
echo "ERROR : ${msg}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
vmname="${1:-}"
|
||||
[ -n "${vmname}" ] || error "You must provide <vmname> !"
|
||||
virsh list --name | grep -qE "^${vmname}$" || error "${vmname} is not a running VM !"
|
||||
|
||||
[ -f "/etc/evolinux/add-vm.cnf" ] && . /etc/evolinux/add-vm.cnf
|
||||
slaveKVMIP="${slaveKVMIP:-}"
|
||||
|
||||
ssh "${slaveKVMIP}" virsh exit || error "Cannot connect to libvirt on ${slaveKVMIP} !"
|
||||
|
||||
ssh "${slaveKVMIP}" drbdadm primary "${vmname}"
|
||||
virsh migrate --live --unsafe --verbose "${vmname}" "qemu+ssh://${slaveKVMIP}/system" "tcp://${slaveKVMIP}/"
|
||||
virsh dumpxml "${vmname}" | ssh "${slaveKVMIP}" virsh define /dev/stdin
|
||||
virsh undefine "${vmname}"
|
||||
drbdadm secondary "${vmname}"
|
Loading…
Reference in a new issue