2019-10-18 05:51:28 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
dir=/var/lib/direktil/
|
|
|
|
PATH=$PATH:$dir
|
|
|
|
cd $dir
|
|
|
|
|
|
|
|
if [ ! -f govc.env ]; then
|
|
|
|
echo ERROR: govc.env file not found in dir $dir ; exit 1
|
|
|
|
fi
|
|
|
|
source govc.env
|
|
|
|
|
|
|
|
if [ $# != 2 ]; then
|
|
|
|
echo "Usage: $0 <VM_NAME> <NOVIT_HOST>" ; exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z $NOVIT_VM_FOLDER || -z $NOVIT_ISO_FOLDER ]]; then
|
|
|
|
echo "ERROR: All GOVC env vars (including NOVIT_VM_FOLDER and NOVIT_ISO_FOLDER) must be provided" ; exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
VM=$1
|
|
|
|
HOST=$2
|
|
|
|
|
2019-10-18 07:00:04 +00:00
|
|
|
govc vm.power -off "$NOVIT_VM_FOLDER/$VM" || true
|
2019-10-18 05:51:28 +00:00
|
|
|
sleep 5
|
2019-10-18 07:00:04 +00:00
|
|
|
curl localhost:7606/hosts/$HOST/boot.iso | govc datastore.upload - "$NOVIT_ISO_FOLDER/$VM.iso"
|
2019-10-18 05:51:28 +00:00
|
|
|
sleep 5
|
2019-10-18 07:00:04 +00:00
|
|
|
govc vm.power -on "$NOVIT_VM_FOLDER/$VM"
|