ironic/devstack/tools/ironic/scripts/cleanup-node.sh
Ilya Etingof 01b0be9db2 Improve VirtualBMC use in Devstack
This patch brings two somewhat related changes:

1. Older versions of VirtualBMC worked without any server keeping
   state on the filesystem. The contemporary version is build around
   client-server model. To preserve backward compatibility, the
   `vbmc` client would invoke `vbmcd` behind the scenes if the daemon
   is not running.

   This change inhibits this automatic `vbmcd` start behaviour because
   devstack invokes `vbmcd` explicitly through systemd.

2. This patch makes Devstack messing with VirtualBMC only if it is
   determined that IPMI deployment is required. Otherwise (e.g.
   Redfish deployment is planned) Devstack will not attempt to
   start/stop IPMI emulation.

Change-Id: Id9a2ed71a997fb13523a77563d6e941904675f97
2019-04-09 14:06:20 +02:00

32 lines
936 B
Bash
Executable File

#!/usr/bin/env bash
# **cleanup-nodes**
# Cleans up baremetal poseur nodes and volumes created during ironic setup
# Assumes calling user has proper libvirt group membership and access.
set -exu
# Make tracing more educational
export PS4='+ ${BASH_SOURCE:-}:${FUNCNAME[0]:-}:L${LINENO:-}: '
LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"}
LIBVIRT_CONNECT_URI=${LIBVIRT_CONNECT_URI:-"qemu:///system"}
NAME=$1
export VIRSH_DEFAULT_CONNECT_URI=$LIBVIRT_CONNECT_URI
VOL_NAME="$NAME.qcow2"
virsh list | grep -q $NAME && virsh destroy $NAME
virsh list --inactive | grep -q $NAME && virsh undefine $NAME --nvram
if virsh pool-list | grep -q $LIBVIRT_STORAGE_POOL ; then
virsh vol-list $LIBVIRT_STORAGE_POOL | grep -q $VOL_NAME &&
virsh vol-delete $VOL_NAME --pool $LIBVIRT_STORAGE_POOL
fi
sudo brctl delif br-$NAME ovs-$NAME || true
sudo ip link set dev br-$NAME down || true
sudo brctl delbr br-$NAME || true