function cleanup_uefi {
# Clean up Ubuntu boot entry if cfg01, kvm nodes online from previous deploy
local cmd_str="ssh ${SSH_OPTS} ${SSH_SALT}"
+ local grain_virtual=$(salt -C 'I@nova:compute and *01*' grains.get virtual --out txt | cut -d ' ' -f2)
ping -c 1 -w 1 "${SALT_MASTER}" || return 0
[ ! "$(hostname)" = 'cfg01' ] || cmd_str='eval'
# NOTE: Targeting nodes by hostname is fragile and should be refactored to
efibootmgr | grep -oP '(?<=Boot)[0-9]+(?=.*ubuntu)' | \
xargs -I{} efibootmgr --delete-bootnum --bootnum {}; \
rm -rf /boot/efi/*\"" || true
- ${cmd_str} "sudo salt -C 'kvm* or cmp*' cmd.run 'shutdown now'" || true
+
+ if [ "${grain_virtual}" == physical ]; then
+ ${cmd_str} "sudo salt -C 'kvm* or cmp*' cmd.run 'shutdown now'" || true
+ fi
}
function get_nova_compute_pillar_data {
function __cleanup_vms {
# clean up existing nodes
for node in $(${VIRSH} list --name | grep -P '\w{3}\d{2}'); do
- ${VIRSH} destroy "${node}"
+ ${VIRSH} destroy "${node}" 2>/dev/null || true
done
for node in $(${VIRSH} list --name --all | grep -P '\w{3}\d{2}'); do
${VIRSH} domblklist "${node}" | awk '/^.da/ {print $2}' | \