tools/deployment/libvirt/destroy_standard_controller.sh
Dean Troyer bd4b59dde2 Clean up the libvirt install bits
* Split the network setup/teardown bits into their own scripts
  so you can shoot yourself in the foot with intention
  rather then unexpectedly.
* Cowardly refuse to configure a network if the first interface name exists
* Change the default bridge name to stxbr
* Make the network variables all configurable via the environment
* Don't make assumptions about where ISOIMAGE is located
* Include a basic doc that outlines the differences from existing
  installation steps. (Needs more!)

Change-Id: Ic46c03a09da97765b9f6bfe07e089efa38738993
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2018-08-30 10:40:57 -05:00

39 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
BRIDGE_INTERFACE=${BRIDGE_INTERFACE:-stxbr}
CONTROLLER=${CONTROLLER:-controller}
COMPUTE=${COMPUTE:-compute}
DOMAIN_DIRECTORY=vms
for i in {0..1}; do
CONTROLLER_NODE=${CONTROLLER}-${i}
DOMAIN_FILE=$DOMAIN_DIRECTORY/$CONTROLLER_NODE.xml
if virsh list --all --name | grep ${CONTROLLER_NODE}; then
STATUS=$(virsh list --all | grep ${CONTROLLER_NODE} | awk '{ print $3}')
if ([ "$STATUS" == "running" ])
then
sudo virsh destroy ${CONTROLLER_NODE}
fi
sudo virsh undefine ${CONTROLLER_NODE}
sudo rm -rf /var/lib/libvirt/images/${CONTROLLER_NODE}-0.img
sudo rm -rf /var/lib/libvirt/images/${CONTROLLER_NODE}-1.img
[ -e ${DOMAIN_FILE} ] && rm ${DOMAIN_FILE}
fi
done
for i in {0..1}; do
COMPUTE_NODE=${COMPUTE}-${i}
DOMAIN_FILE=$DOMAIN_DIRECTORY/$COMPUTE_NODE.xml
if virsh list --all --name | grep ${COMPUTE_NODE}; then
STATUS=$(virsh list --all | grep ${COMPUTE_NODE} | awk '{ print $3}')
if ([ "$STATUS" == "running" ])
then
sudo virsh destroy ${COMPUTE_NODE}
fi
sudo virsh undefine ${COMPUTE_NODE}
sudo rm -rf /var/lib/libvirt/images/${COMPUTE_NODE}-0.img
sudo rm -rf /var/lib/libvirt/images/${COMPUTE_NODE}-1.img
[ -e ${DOMAIN_FILE} ] && rm ${DOMAIN_FILE}
fi
done