Scripting VMware Power Tools: Automating Virtual Infrastructure Administration

VMware provides many useful command-line tools for the creation and cloning of virtual machines. In this chapter, you will gain a working understanding of these tools and how to leverage them to automate virtual machine creation. At the end of this chapter, you will be able to script the creation and cloning of virtual machines to automate your virtual machine setup.
VMware ESX Server has tools available for command-line creation and cloning of virtual machines. These tools are available via the service console and require that you access the service console with root-level privileges.
| Tip | Remote access to ESX Server by default is disabled for the root account. Create an additional account on your ESX server. Log in with this new account and use the su root command. This command will allow you to assume root level privileges. |
Three main steps are involved to create a virtual machine utilizing the command-line tools.
Creation of a virtual machine configuration file
Creation of a virtual machine disk file
Registering the virtual machine with ESX Server
We accomplish the preceding tasks by utilizing the following tools:
text editor such as VI
vmkfstools
vmware-cmd
Virtual machine configurations are stored as files with a .vmx extension. The VMX file is just a text file with specific fields that define the virtual machine s configuration. A very short vmx file only needs 14 lines to support a virtual...