A very nice tool that an administrator can download is a virtual appliance called the vMA which is Linux based (SUSE Linux Enterprise Server 11, SP1), it has several components, including the vCLI and vSphere SDK for Perl. The requirements for the vMA aren’t too crazy, must have 1 vCPU, at least 600 MB of memory, 3GB disk minimum and needs to be deployed on one of these platforms:
– vSphere ESX 4.0 U2 or newer
– vSphere ESXi 4.1 or newer
– vCenter 4.0 U2 or newer
This appliance gets deployed like any other; first we download it from VMware’s website. Once we have the *.ova or *.ovf file then go to File > Deploy OVF Template in the vSphere Client and finish the wizard.
The vMA will allow us to manage our hosts via command line as well as run scripts. Our vMA commands sent directly to our host are send via vSphere SDK for Perl API, and if we are sending commands to a host but through vCenter then it will be sent to vCenter via vSphere SDK for Perl and then from vCenter to the host using vCenter’s private protocol.
Using our vifp interface, we can add, show, or remove target servers. A target server is what we are trying to connect to here. If we want to go ahead and set that target as the default for this session then we will type to vifptarget command. We can choose to establish multiples servers as target servers. We will just need to use the – -server option to go ahead and specify which one we are going to be running our commands against. So, for example:
To add a server as a target:
To list target servers:
To set a server as the target for the vMA session:
To remove a target server:
Another set of useful commands are the vmware-cmd ones. I can use “vmware-cmd <vmx path> getstate to determine what the VM’s power state is.
If I want to power on a VM then the command will be ”vmware-cmd <vmx path> start. “
Alternatively to power it off, use ”vmware-cmd <vmx path> stop soft“
Something else I can do is use the ”esxcli vm process list“ to list all virtual machine processes.
This can be useful when determining the world ID or UUID of the virtual machine, this also shows the path to the VM’s .vmx file.