diff --git a/scripts/vm/hypervisor/xenserver/cloud-clean-vlan.sh b/scripts/vm/hypervisor/xenserver/cloud-clean-vlan.sh new file mode 100755 index 00000000000..b58cc2b7fa0 --- /dev/null +++ b/scripts/vm/hypervisor/xenserver/cloud-clean-vlan.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Version @VERSION@ + +#set -x + + +for vlan in $(xe vlan-list | grep ^uuid | awk '{print $NF}'); do xe vlan-destroy uuid=$vlan 2&>/dev/null; done +for networkname in $(xe network-list | grep "name-label ( RW): VLAN" | awk '{print $NF}'); do network=$(xe network-list name-label=$networkname --minimal); xe network-destroy uuid=$network 2&>/dev/null; done diff --git a/scripts/vm/hypervisor/xenserver/cloud-prepare-upgrade.sh b/scripts/vm/hypervisor/xenserver/cloud-prepare-upgrade.sh new file mode 100755 index 00000000000..e9ebf815231 --- /dev/null +++ b/scripts/vm/hypervisor/xenserver/cloud-prepare-upgrade.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# Version @VERSION@ + +#set -x + +# propagate VLANs to other host +for networkname in $(xe network-list | grep "name-label ( RW): VLAN" | awk '{print $NF}'); +do + network=$(xe network-list name-label=$networkname --minimal) + tagpif=$(xe pif-list network-uuid=$network --minimal | cut -d, -f 1) + device=$(xe pif-param-get uuid=$tagpif param-name=device) + vlan=$(xe pif-param-get uuid=$tagpif param-name=VLAN) + for host in $(xe host-list | grep ^uuid | awk '{print $NF}') + do + tagpif=$(xe pif-list network-uuid=$network host-uuid=$host --minimal) + if [ -z $tagpif ]; then + pif=$(xe pif-list host-uuid=$host device=$device --minimal) + xe vlan-create network-uuid=$network pif-uuid=$pif vlan=$vlan + fi + done +done + + +# fake PV for PV VM + +fake_pv_driver() { + local vm=$1 + res=$(xe vm-param-get uuid=$vm param-name=PV-drivers-version) + if [ ! "$res" = "" ]; then + return 1 + fi + res=$(xe vm-param-get uuid=$vm param-name=HVM-boot-policy) + if [ ! -z $res ]; then + echo "Warning VM $vm is HVM, but PV driver is not installed, you may need to stop it manually" + return 0 + fi + make_migratable.sh $vm +} + + +vms=$(xe vm-list is-control-domain=false| grep ^uuid | awk '{print $NF}') +for vm in $vms +do + state=$(xe vm-param-get uuid=$vm param-name=power-state) + if [ $state = "running" ]; then + fake_pv_driver $vm + elif [ $state = "halted" ]; then + echo "VM $vm is in $state" + else + echo "Warning : Don't know how to handle VM $vm, it is in $state state" + fi +done + diff --git a/scripts/vm/hypervisor/xenserver/xenserver56/patch b/scripts/vm/hypervisor/xenserver/xenserver56/patch index 5b98f689676..8a3fe90f8ac 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56/patch @@ -43,4 +43,6 @@ InterfaceReconfigure.py=.,0755,/opt/xensource/bin fsimage.so=..,0755,/usr/lib/fs/ext2fs-lib create_privatetemplate_from_snapshot.sh=..,0755,/opt/xensource/bin upgrade_snapshot.sh=..,0755,/opt/xensource/bin +cloud-clean-vlan.sh=..,0755,/opt/xensource/bin +cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin diff --git a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch index 76d28151476..887ff6a77e7 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch @@ -43,3 +43,5 @@ vhd-util=..,0755,/opt/xensource/bin vmopspremium=..,0755,/etc/xapi.d/plugins create_privatetemplate_from_snapshot.sh=..,0755,/opt/xensource/bin upgrade_snapshot.sh=..,0755,/opt/xensource/bin +cloud-clean-vlan.sh=..,0755,/opt/xensource/bin +cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin