|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -x |
| 4 | + |
| 5 | +function wait_toolstack_ready { |
| 6 | + while ! ls /var/run/xapi_init_complete.cookie; do |
| 7 | + sleep 2 |
| 8 | + done |
| 9 | +} |
| 10 | + |
| 11 | +function version_ge() { |
| 12 | + test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; |
| 13 | +} |
| 14 | + |
| 15 | + |
| 16 | +ELY_VER=2.2.0 |
| 17 | +host_uuid=$(xe host-list --minimal) |
| 18 | +xcp_ver=$(xe host-param-get param-name=software-version param-key=platform_version uuid=$host_uuid) |
| 19 | + |
| 20 | +if version_ge $xcp_ver $ELY_VER; then |
| 21 | + # Find openstack-xenapi-plugins suppack update uuid |
| 22 | + update_uuids=$(xe update-list name-label=openstack-xenapi-plugins --minimal) |
| 23 | + if [ -z "$update_uuids" ]; then |
| 24 | + exit 0 |
| 25 | + fi |
| 26 | + |
| 27 | + # Find the correct package and uninstall them |
| 28 | + yum list installed openstack-neutron-xen-plugins.noarch && yum remove openstack-neutron-xen-plugins.noarch -y |
| 29 | + yum list installed openstack-xen-plugins.noarch && yum remove openstack-xen-plugins.noarch -y |
| 30 | + yum list installed conntrack-tools.x86_64 && yum remove conntrack-tools.x86_64 -y |
| 31 | + |
| 32 | + # remove updates |
| 33 | + update_uuids=${update_uuids//,/ } |
| 34 | + for uuid in $update_uuids |
| 35 | + do |
| 36 | + if [ -n "$uuid" ]; then |
| 37 | + # Remove uuid related folder/file and restart toolstack |
| 38 | + rm -rf /var/update/applied/$uuid |
| 39 | + rm -f /var/run/xapi_init_complete.cookie |
| 40 | + xe-toolstack-restart |
| 41 | + wait_toolstack_ready |
| 42 | + |
| 43 | + # Destroy the unapplied update and restart toolstack |
| 44 | + xe update-destroy uuid=$uuid |
| 45 | + rm -f /var/run/xapi_init_complete.cookie |
| 46 | + xe-toolstack-restart |
| 47 | + wait_toolstack_ready |
| 48 | + fi |
| 49 | + done |
| 50 | +else |
| 51 | + # Find the correct package and uninstall them |
| 52 | + yum list installed openstack-neutron-xen-plugins.noarch && yum remove openstack-neutron-xen-plugins.noarch -y |
| 53 | + yum list installed openstack-xen-plugins.noarch && yum remove openstack-xen-plugins.noarch -y |
| 54 | + yum list installed conntrack-tools.x86_64 && yum remove conntrack-tools.x86_64 -y |
| 55 | +fi |
| 56 | + |
0 commit comments