Home > Scripting creation of virtual machines in ESX shell
Book Excerpt:
EMAIL THIS

Scripting creation of virtual machines in ESX shell

13 Feb 2007 | Syngress Publishing

Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   

[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 ...


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Server Virtualization Hardware, Software and Services
Three setbacks when designing Hyper-V R2 High Availability
Citrix XenServer 5.5 hardware requirements
VSphere upgrade and performance study guide
Microsoft Hyper-V R2 features and comparison guide
VMware extends vSphere Enterprise Edition availability
Active Directory voted best Windows Server 2008 R2 feature
Upgrading to VMware vSphere 4
Upgrading virtual machines for vSphere implementation
Key concepts for server, storage and client virtualization
Top 10 server virtualization management and performance tips

Remote Desktop Software Services
Using Remote Desktop: Five quick tips
Blades servers and virtualization channel opportunities: Q&A with Barb Goldworm
Scripting Creation of Virtual Machines in Perl Scripts
Service providers expand into new market -- other service providers

Additional Resources
Understanding Microsoft's virtualization strategy
Planning your implementation of Hyper-V
Changing virtualization services in wake of VMware Server ESX 3i
Cloning Virtual Machines Utilizing ESX Shell Scripts
VMware vs. Virtual Server: Compare server virtualization products
VMware server: How to troubleshoot VMware ESX Server installations

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


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.





HomeNewsTopicsITKnowledge ExchangeTipsMultimediaWhite PapersBlogsEvents
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
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 technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2006 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts