 |
 |
Home > Scripting creation of virtual machines in ESX shell |
 |
 |
 |
Scripting creation of virtual machines in ESX shell |
 |
| 13 Feb 2007 | Syngress Publishing |
 |


|
[IMAGE]Scripting Creation of Virtual Machines in ESX Shell
The script in Code Listing 4.6 will create a virtual machine that has the
following characteristics:
- A VM called ScriptedVM in a directory named ScriptedVM on
storage1
- A VM that will be assigned 256MB of memory
- A VM that will have a 4GB SCSI hard drive (lsilogic controller)
- A VM configured for a Windows 2003 standard operating system
- A floppy drive assigned, not connected at startup
- A CD-ROM attached to the ESX server's CD-ROM drive, not connected
at startup
- An Ethernet adapter connected to the VM Network, enabled at startup
The exec commands in the script are system-level commands in Linux to
set up the writing to, and saving of, the script file. It redirects the console
screen's output to the script file.The use of the echo commands in the script
sends the commands to the screen which are redirected to the file for
writing.The file is then closed and the virtual configuration file,VMX, is
saved.The permissions are changed on the configuration file so any user on
ESX can access the virtual machine.Then the script creates the virtual disk
and registers the VM with the ESX server.
Use the following process to set up your script on the ESX server:
- Log in locally or connect to your ESX server remotely.
- Log in with an ID that has root privileges (see Figure 4.9).
Figure 4.9 Gaining Root Level Access on ESX Server
[IMAGE]
- Change to the location or create a location of where you would like
to store your scripts (see Figure 4.10).
Figure 4.10 Script Storage Location
[IMAGE]
- Type VI newvm.script and press Enter.
- Press I for insert and type in the script as shown in Code Listing 4.6
(see Figure 4.11).
Figure 4.11Using VI to Create Shell Script
[IMAGE]
- Press Esc and then press and hold Shift while pressing ZZ to exit
and save.
- You should now have a file called newvm.script listed. Before you
run the script, you must set permissions on it.To do this, type
chmod 755 newvm.script (see Figure 4.12).
Figure 4.12 Setting Permissions on Script File
[IMAGE]
- Run the script by typing ./newvm.script (see Figure 4.13).
Figure 4.13 The Execution of Shell Script
[IMAGE]
The virtual ...
To continue reading for free, register below or login
To read more you must become a member of SearchSystemsChannel.com
');
// -->

machine has now been created and registered with ESX.The
next steps are for you to power it on and install the guest operating system.
Creating scripts in ESX shell will save you time and effort in creating new
virtual machines in your environment.
Use the following table of contents to navigate to chapter excerpts, or click here to view Chapter 4 in its entirety.
[IMAGE]
[IMAGE]Building a VM
[IMAGE] Home: Introduction
[IMAGE] Part 1:Creation of virtual machines utilizing command line-tools
[IMAGE] Part 2: Scripting Creation of virtual machines in ESX shell
[IMAGE] Part 3: Scripting Creation of Virtual Machines in Perl Scripts
[IMAGE] Part 4: Cloning virtual machines utilizing ESX Shell scripts
[IMAGE] Part 5: Cloning virtual machines utilizing VmPerl Scripts
ABOUT THE BOOK:
Scripting VMware Power Tools shows readers scripting techniques using both ESX and Linux commands to automate administrative tasks of ESX Server. It covers VMware ESX Server native tools and discusses in detail the different scripting APIs and how they can be used to provide some very useful, practical, and time-saving tools to manage a virtual infrastructure. From virtual server provisioning to backups, and everything in between, this book is a one-stop shop for virtual tools!Purchase the book from Syngress Publishing
ABOUT THE AUTHOR:
Lead author Al Muller is a consultant for Callisma, a wholly owned subsidiary of AT&T. He has been in the IT field since 1995, getting his start as a database administrator in the Navy. In 2002 he began using VMware's GSX Server and within a year was involved in his first virtualization project. Since then, he has been an eager proponent of virtualization technology and has worked on a number of different server consolidation and virtualization projects.

|
 |
|
 |
 |
 |
| TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of . |
|
| |
All Rights Reserved, , TechTarget |
|
|
|
|
|