mirror of
https://github.com/lephisto/crossover.git
synced 2025-12-06 04:09:20 +01:00
Compare commits
5 Commits
feature-mo
...
5b7fd4986b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b7fd4986b | ||
|
|
41abd0429a | ||
|
|
890567ad05 | ||
|
|
f5441f4c0b | ||
|
|
fb5b3a6d09 |
39
crossover
39
crossover
@@ -433,6 +433,11 @@ function mirror() {
|
||||
map_vmids_to_host
|
||||
map_vmids_to_dsthost "$opt_destination"
|
||||
|
||||
if [ $(check_pool_exist "$opt_pool") -eq 0 ]; then
|
||||
log error "Preflight check: Destination RBD-Pool $opt_pool does not exist."
|
||||
end_process 255
|
||||
fi
|
||||
|
||||
for vm_id in $svmids; do
|
||||
(( vmcount++ ))
|
||||
local file_config; file_config=$(get_config_file)
|
||||
@@ -473,18 +478,22 @@ function mirror() {
|
||||
map_vmids_to_dsthost "$opt_destination"
|
||||
fi
|
||||
|
||||
#--move so we need to shutdown?
|
||||
#--move so we need to shutdown and remove from ha group?
|
||||
if [ $opt_migrate -eq 1 ]; then
|
||||
log info "VM $vm_id - Shutting down VM on ${pvnode[$vm_id]}"
|
||||
do_run "ssh root@"${pvnode[$vm_id]}" qm shutdown "$vm_id >/dev/null
|
||||
log info "VM $vm_id - Migration requested, shutting down VM on ${pvnode[$vm_id]}"
|
||||
if [ "$(get_ha_status "$vm_id")" == "started" ]; then
|
||||
log info "VM $vm_id - remove from HA"
|
||||
do_run "ha-manager remove $vm_id"
|
||||
fi
|
||||
do_run "ssh root@${pvnode[$vm_id]} qm shutdown $vm_id >/dev/null"
|
||||
fi
|
||||
|
||||
#Lock on source + destination
|
||||
if [ $opt_lock -eq 1 ]; then
|
||||
do_run "ssh root@"${pvnode[$vm_id]}" qm set "$vm_id" --lock backup" >/dev/null
|
||||
log info "VM $vm_id - locked $vm_id [rc:$?]"
|
||||
log info "VM $vm_id - locked $vm_id [rc:$?] on source"
|
||||
do_run "ssh root@"${dstpvnode[$dvmid]}" qm set "$dvmid" --lock backup" >/dev/null
|
||||
log info "VM $dvmid - locked $dvmid [rc:$?]"
|
||||
log info "VM $dvmid - locked $dvmid [rc:$?] on destination"
|
||||
fi
|
||||
#Freeze fs only if no migration running
|
||||
if [ $opt_migrate -eq 0 ]; then
|
||||
@@ -742,7 +751,7 @@ function rewriteconfig(){
|
||||
else
|
||||
sedcmd='sed -e /^$/,$d'
|
||||
fi
|
||||
cat "$oldconfig" | sed -r -e "s/^(virtio|ide|scsi|sata|mp)([0-9]+):\s([a-zA-Z0-9]+):(.*)-([0-9]+)-disk-([0-9]+).*,(.*)$/\1\2: $newpool:\4-$newvmid-disk-\6-\3,\7/g" | $sedcmd | sed -e '/^$/,$d' | grep -v "^parent:\s.*$" | ssh "$dst" "cat - >$newconfig"
|
||||
cat "$oldconfig" | sed -r -e "s/^(virtio|ide|scsi|sata|mp)([0-9]+):\s([a-zA-Z0-9]+):(.*)-([0-9]+)-disk-([0-9]+).*,(.*)$/\1\2: $newpool:\4-$newvmid-disk-\6-\3,\7/g" | $sedcmd | sed -e '/^$/,$d' | sed -e '/ide[0-9]:.*-cloudinit,media=cdrom.*/d' | grep -v "^parent:\s.*$" | ssh "$dst" "cat - >$newconfig"
|
||||
}
|
||||
|
||||
function checkvmid(){
|
||||
@@ -806,6 +815,24 @@ function get_image_spec(){
|
||||
echo "$image_spec"
|
||||
}
|
||||
|
||||
function get_ha_status() {
|
||||
local havmid="$1"
|
||||
ha_status=$(ha-manager status| grep vm:"$havmid" | cut -d " " -f 4| sed 's/.$//')
|
||||
echo "$ha_status"
|
||||
}
|
||||
|
||||
function check_pool_exist() {
|
||||
local poolname="$1"
|
||||
local -i exists=255
|
||||
pool_status=$(ssh $opt_destination pvesm status|grep rbd|cut -d " " -f 1|grep $poolname)
|
||||
if [ "$pool_status" == "$poolname" ]; then
|
||||
exists=1
|
||||
else
|
||||
exists=0
|
||||
fi
|
||||
echo $exists
|
||||
}
|
||||
|
||||
function main(){
|
||||
[ $# = 0 ] && usage;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user