Perl VIX API
The VIX API allows users to write scripts and programs to automate virtual machine operations. The API is high-level, easy to use, and practical for both scripters and application programmers.
If you didnt receive a copy of installatin files for VIX API in your VMware Server packet, you can download it here
Installation
Here are the instructions to install VIX API on your computer:
Note: these instructions are meant to be run as a root or super user (su), they will not work correctly otherwise.
Download the installer package ot use the one provided from your client package. You can also download it using this command:
wget http://www.vmware.com/products/beta/ws/VMware-vix-1.1.2-59824.i386.tar.gz
Decompress and unpack the tar file using your graphical tar program into your desired directory or by using this command:
tar zxf VMware-vix-1.1.2-59824.i386.tar.gz
Go to the unzipped drictory, for example:
cd ../vmware-vix-distrib/
Run the installation script:
./vmware-install.pl
Follow the instructions provided by the installer to set up your VIX API.
Common uses for the VIX API
Common tasks performed by the VIX API include:
- Connecting to a Host
To work with a virtual machine you must first connect with a host where the VM is stored. If you are running VMware Server, which these instructions are for by default, you can connect to the host either locally or remotely. You can either log into local host if you are the default user for it, or connect to a host as a specified user coding your user name and password into the script.
- Registering and Unregistering Virtual Machines
VMware Server requires the virtual machine to be registered in the in the host's inventory to use it. The inventory is a list of virtual machines available for running on the VMware Server. If you remove a virtual from the inventory it will no longer be available for running any operations and has to be re-registered. The benefit of keeping a machine unregistered is that it cannot be modified or corrupt and can be used to make identical clones. Registering or unregistering a machine does not require a handle to the virtual machine, but it does require a path to the machine's configuration file (ex. SampleMachine?.vmx). Client must also provide a handle to the host machine where the virtual machine is to be registered or unregistered.
- Getting a Handle to a Virtual Machine
Most virtual machines require a handle to identify the virtual machine.
- Starting or Resuming a Virtual Machine
Simple functions used for powering off or resuming a virtual machine from a paused state
- Installing VMware Tools in a Virtual Machine
VMware Tools is a package of tools and drivers that enhances the performance and functionality of your guest operating system. It is very useful and makes the use of your mutual machine a lot simpler and increases capabilities. For a example a lot of VIX API scripts require the VMware Tools to be installed, especially running functions that affect the guest operationg system. You can either use the console itself or automate the VMware Tools installation using VIX API. The installation is done via mounting the tools package on the CD-ROM of your virtual machine. Obviously it requires for your operating system to be already installed, and if your Auto-Run feature is anabled in the operating systems it starts automatically. You then follow the instructions to navigate through your tools installation on your virtual machine. The package is either installed using an RPM file which is the simpler way, but considering that option might not be available on your virtual machine you have two options. There is an RPM file on the virtual cd, and also a compressed file containging installation files and a manual on how to install your vmware tools. If you can't do an RPM installation follow those directions and install the VMware Tools.
- Virtual Machine Guest Operations
Guest Operations are operations that are performed inside of your guest machine. They require VMware Tools to be installed, and would not run otherwise. You have a lot of capabilites like running stopping running programs in guest, searching for files, copying files frong guest to host, create or delete dirctories or list contents, etc.
- Powering Off or Suspending a Virtual Machine
You can either power off or suspend using these functions, suspend is similar to putting your laptop to sleep meaning the virtual machine stops running and when you resume it, it picks up and runs processes right where it was left when suspended.
- Importing a Legacy Virtual Machine
This refers to fucntions used for importing a Legacy Virtual Machine, meaning one created by an older version of a VMware Server. Due to constant changes and useful additions to capabilities of the VMware Server, the imported virtual machine may not have same capabilites. Running Legacy Virtual Machines is not recommended because they may not support new virtual hardware that has been added since previous version and are at risk of failing and getting corrupt. It is advised to upgrade older Virtual Machines instead of using newer software to run them.
