AHV is very powerful from a scripting interface the so called acli. The flowing section is providing some basic scripts/commands that can be used in the acli interface.

With this blog you will be able to perform:

  • Creating a VM using a script
  • Cloning a VM using a script
  • Manipulation of VMs via a script

. List all VM’s on a cluster:

acli vm.list

. List VM’s which are in powered ON state:

acli vm.list power_state=on

. List VM’s which are in powered OFF state:

acli vm.list power_state=off

. To power off all the VM’s running the cluster/node:

for vm_name in `acli vm.list power_state=on | grep -v ^'VM
name' | awk '{print $1}'`; do acli vm.force_off $vm_name; done

. To power on all VM’s running on the cluster/node:

for vm_name in `acli vm.list power_state=off | grep -v ^'VM
name' | awk '{print $1}'`; do acli vm.on $vm_name; done

. Create/Deploy multiple VM’s using command line:

for n in {1..5}; do acli vm.create MyVM$n memory=1024M
num_vcpus=1; done

. To clone a VM:

acli vm.clone ADClone clone_from_vm=AD

PRISM should show

Advertisement