#!/bin/bash
#
# Copyright (c) Citrix Systems 2008. All rights reserved.
#
#     ./test-pool-size n vm_name
#
# Host1 will become the master of the pool, with host2 ... hostN as slaves.
# Then, on each host, vm_per_host VMs are created, with names debian-etch-HOST_NAME-i (for i in 1..vm_per_host)

if [ $# -ne 2 ]; then 
   echo "Usage: $0 number_of_vm initial_vm_name"
   echo "Need :"
   echo "  * ./repeat, ./repeat-clone, ./repeat-start and ./repeat-destroy scripts to be in the same directory that ${0};"
   echo "  * a pool already set up with a shared NFS storage and a HVM VM called dsl;"
   echo "  * ${0} must be started on the master of this pool;"
   echo "${0} clones <number_of_vm>, then starts them all, then shutdown them all, then destroy them all."
   echo "If WAIT_FOR_IP is set to 1, the script waits for the IP adress of the VM to appear before starting the next VM."
   exit 1
fi 

N=${1}
VM=${2}

./repeat-clone ${N} ${VM} > clone-${VM}.dat
./repeat-start ${N} ${VM} > start-${VM}.dat
./repeat ${N} shutdown ${VM} --force  > shutdown-${VM}.dat
./repeat-destroy ${N} ${VM} > destroy-${VM}.dat