#
#Uses Vagrant and VirtualBox
#
-#Destroys Vagrant VM running in /tmp/bgs_vagrant
+#Destroys Vagrant VM running in $vm_dir/foreman_vm
#Shuts down all nodes found in Khaleesi settings
#Removes hypervisor kernel modules (VirtualBox)
blue=`tput setaf 4`
red=`tput setaf 1`
green=`tput setaf 2`
+
+vm_dir=/var/opt/opnfv
##END VARS
##FUNCTIONS
done
-##install ipmitool
+# Install ipmitool
+# Major version is pinned to force some consistency for Arno
if ! yum list installed | grep -i ipmitool; then
- if ! yum -y install ipmitool; then
+ if ! yum -y install ipmitool-1*; then
echo "${red}Unable to install ipmitool!${reset}"
exit 1
fi
skip_vagrant=1
fi
+###legacy VM location check
+###remove me later
+if [ -d /tmp/bgs_vagrant ]; then
+ cd /tmp/bgs_vagrant
+ vagrant destroy -f
+ rm -rf /tmp/bgs_vagrant
+fi
+
###destroy vagrant
if [ $skip_vagrant -eq 0 ]; then
- cd /tmp/bgs_vagrant
- if vagrant destroy -f; then
- echo "${blue}Successfully destroyed Foreman VM ${reset}"
- else
- echo "${red}Unable to destroy Foreman VM ${reset}"
- echo "${blue}Checking if vagrant was already destroyed and no process is active...${reset}"
- if ps axf | grep vagrant; then
- echo "${red}Vagrant VM still exists...exiting ${reset}"
- exit 1
+ if [ -d $vm_dir/foreman_vm ]; then
+ cd $vm_dir/foreman_vm
+ if vagrant destroy -f; then
+ echo "${blue}Successfully destroyed Foreman VM ${reset}"
else
- echo "${blue}Vagrant process doesn't exist. Moving on... ${reset}"
+ echo "${red}Unable to destroy Foreman VM ${reset}"
+ echo "${blue}Checking if vagrant was already destroyed and no process is active...${reset}"
+ if ps axf | grep vagrant; then
+ echo "${red}Vagrant VM still exists...exiting ${reset}"
+ exit 1
+ else
+ echo "${blue}Vagrant process doesn't exist. Moving on... ${reset}"
+ fi
fi
fi
echo "${blue}Skipping Vagrant destroy + Vbox Removal as VirtualBox package is already removed ${reset}"
fi
+###remove working vm directory
+rm -rf $vm_dir
###remove kernel modules
echo "${blue}Removing kernel modules ${reset}"