#!/bin/bash
# Maintainer: Martin Weise <martin.weise@tuwien.ac.at>
# Short:      Removes a vm based on their name as it appears on the virtualization host with $ virsh list
# Synopsis:   ./bin/remove-owner id
function usage () {
  echo "USAGE: $0 id"
}

if [ $# -ne 1 ]; then
  usage
  exit 1
fi

echo -e "REMOVE [Start] *****************************************************************"
ansible-playbook ./remove-owner.yml -e id=$1

status=$?
if [ $status -eq 0 ]; then
  echo -e "REMOVE [Done] ******************************************************************"
  echo -e "\e[92mok: [localhost]\e[39m\n"
  exit 0
else
  echo -e "REMOVE [Done] ******************************************************************"
  echo -e "\e[91mfailed: playbook returned non-zero exit code\e[39m"
  exit 1
fi
