Home > Blogs > VMware vApp Developer Blog > Monthly Archives: July 2009

Monthly Archives: July 2009

Self-Configuration and the OVF Environment

The OVF support in vSphere is not just about deployment and packaging. There is also a runtime part, namely the OVF environment. In this post, we will show a simple example on how the OVF environment can be used, by creating a VM template where you can customize its IP address.
Consider the case where you deploy a VM from an OVF package or VM Template. We often want it to be customized just a little bit. A typical customization is IP settings (IP address, netmask, gateway, DNS, etc.), but also application-level settings, such as the location of the SNMP servers, admin logins, etc. Wouldn't it be nice to have a flexible, extensible, open-ended mechanism for doing this? This is exactly what the OVF environment is for.
One way to think of the OVF environment is that the OVF environment is to a VM what the UNIX environment is to a UNIX process. So what does this mean? Well, the UNIX environment is a pretty simple mechanism that stores key/value pairs. These key/value pairs are typically used to tell a process or shell script about the particular environment it is being executed in. The UNIX environment has solved this problem nicely for processes, and the OVF team has been inspired by that feature and created the OVF properties and OVF environment and made it part of the Open Virtualization Format 1.0 specification.

OVF properties are typically configured by the deployer of a vApp, but can also be provided dynamically by vCenter. An example of a dynamic property is the vCenter server IP address. We will look into dynamic properties in a later post.
To illustrate how to use the OVF environment, let us create a self-configuring VM template that configures its IP settings at startup. This is done by using OVF properties to convey information from vCenter to the VM, and installing a boot script in the VM that uses the information to (self) configure the guest software.
Assuming that we have already installed the operating system into the VM, we need to perform the following steps: 

  • Define OVF properties on the VM.
  • Setup the OVF environment transport to carry the settings into the virtual machine.
  • Write some glue code to access and apply the information inside the VM.   

In the video below, we show how this is done using the vSphere client. In our example, we will create properties needed for IP configuration: IP, netmask, gateway, preferred DNS server, and alternate DNS server.
When vCenter powers on a VM in a vApp, or a VM with vApp settings enabled, it creates an XML document called the OVF environment. The OVF environment contains all properties and their values. It is made available to the guest, allowing the guest to apply the properties to its configuration. When the VM is powered on, the OVF environment can also be viewed in the vSphere Client.
The OVF environment can be transported to the guest in two ways:

  • As a CD-ROM containing the XML document. The CD-ROM is mounted on the guests CD-ROM drive.
  • Through VMware Tools. The variable guestinfo.ovfEnv contains the XML document.

In our example, the OVF environment will look like this:

<Environment oe:id=""
xmlns="http://schemas.dmtf.org/ovf/environment/1"
xmlns:oe="http://schemas.dmtf.org/ovf/environment/1"
xmlns:ve="http://www.vmware.com/schema/ovfenv"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<PlatformSection>
<Kind>VMware ESX</Kind>
<Version>4.0.0</Version>
<Vendor>VMware, Inc.</Vendor>
<Locale>en</Locale>
</PlatformSection>
<ve:EthernetAdapterSection>
<ve:Adapter ve:mac="00:50:56:a0:3f:71" ve:network="VM Network"/>
</ve:EthernetAdapterSection>
<PropertySection>
<Property oe:key="dns1" oe:value="10.20.60.1"/>
<Property oe:key="dns2" oe:value="10.20.60.2"/>
<Property oe:key="gateway" oe:value="10.20.63.253"/>
<Property oe:key="ip" oe:value="10.20.63.219"/>
<Property oe:key="netmask" oe:value="255.255.254.0"/>
</PropertySection>
</Environment>

The OVF environment must be read by some "glue" code in the guest – typically upon power-on. It is the responsibility of this code to configure the guest. In our example, we wrote a small Python script. It reads the property values from the XML file on the CD-ROM and configures the IP stack in the guest using netsh.exe: setupIp.py
This script is called from a Windows scheduled task that is executed upon system startup. For Linux, a similar script can be added to /etc/init.d (depending on the Linux distribution).
To access the OVF environment using VMware Tools instead of using the CD-ROM, we could execute the command:
Windows: "C:\Program Files\VMware\VMware Tools\VMwareService.exe" -cmd "info-get guestinfo.ovfEnv"

Linux: vmware-guestd –cmd 'info-get guestinfo.ovfEnv'


In contrast to the normal VC template customization, there is a bit of extra setup required by the author of the template when using the OVF environment. The author is responsible for installing (and possibly writing) the glue code in the guest. However, you get complete freedom in which parameters you can customize, OS independence, and the deployment step is faster and more light-weight.
In our example, we require the user to type in a fixed IP address and have detailed knowledge of various networking parameters. To improve this, we can use dynamic OVF properties to refer to vCenter's IP pools. We will look into this in a future blog post and also how you can share a self-customizing VM template using an OVF package.


VMware Studio 2.0 Beta Unleashed

VMware Studio 2.0 is in public Beta and it comes with exciting feature set. While 1.0 release was focused on ISVs building virtual
appliances, VMware Studio 2.0 has a broader scope. 

For developers, we introduce VMware Studio 2.0 Eclipse
Plugin to provide an integrated dev/test environment using VMs. If you are the
architect/lead developer and want to standardize development stack for your
team, just create a build profile defining the components of your dev
environment and distribute it or the resulting VM within your team. It is
definitely better than creating a wiki with guidelines to setup development
environments J 

If your application cannot be contained in a single virtual
machine, you need a vApp! Simply put, vApps provide container semantics over a
group of inter-related VMs. Take any n-tier application: CRM, ERP as an example.
Such applications cannot be contained in a single virtual machine, generating a
need to manage these virtual machines in the context of each other. By grouping
them as a vApp, these VMs can be packaged, distributed, deployed and managed as
one unit. vApp also provides a common OVF environment that is shared by
contained VMs. And how do I create vApps? Use VMware Studio 2.0! With Studio
2.0 you can build vApps, author the OVF environment, specify startup/shutdown
order of VMs and their resource requirements. You can distribute these VMs as a
single OVF or OVA package. Learn more about deploying vApps in VC from Rene's blog on vApps 

Another area to touch upon is support for Windows. VMware
Studio 2.0 enables building Windows 2003 and 2008 based VMs. This is our first
release with Windows support. If you are an IT admin creating an “appliance”
for internal distribution or developer standardizing windows based dev
environment, give this feature a spin. 

Support for virtual appliances continues from Studio 1.0. Like
physical appliances, virtual appliances can be treated as a black box. Think Linksys
router, the only interface available to the users being a web console. Bringing
the same concept into virtualization world, VMware Studio 1.0 embedded in-guest
management framework – VAMI that is web accessible, into resulting appliances.
It came with few in-guest services. With VMware Studio 2.0, VAMI is extensible.
ISVs can write their custom in-guest services that plugs into this framework.
The best way to create your own in-guest service is through “VMware Studio
Linux Management Service” Wizard that is part of Eclipse Plugin for Studio. Check
out Matt's Coffee talk webinar and demo for more details

Last but not the least, VMware Studio 2.0 enables fast
builds. You can provide existing Studio-based VM as input, thereby avoiding
building the VM from scratch each time. There is lot more to come in this area
in future. We have just scratched the surface, so stay tuned.

To summarize VMware Studio 2.0 Features:

  • Build multi-VM vApps with rich metadata
  • Build Windows 2003 and 2008 based VMs
  • Support for building single VM and multi-VM Virtual Appliances  
  • Support for Ubuntu, RHEL, SLES, CentOS, 32 and 64 bit Linux VMs 
  • Eclipse
    Plugin
  • Extensible
    in-guest management framework
  • Accept existing Studio-built-VM as Input to build process
  • Better
    OS dependency resolution
  • Supports
    VMware Server 2.0, ESX 3.5 and 4.0, VC 2.5 and 4.0, Workstation 6.5.1 as
    provisioning engines along with VMware Server 1.0.x from Studio 1.0 
  • CLI interface for automation alongwith intuitive web interface

If this sounds exciting, download VMware Studio 2.0 Beta virtual appliance and deploy it in your favorite environment – ESX, WS or VMware Server. Ah and and before leaving, I have to mention this. We have put VMware Studio to a
great use within VMware. VMware Studio is integrated it with our official build
system and source control system to generate nightly builds of virtual appliances
for various products, including VMware Studio 2.0! Talk about eating your own
dog food..

Command-line OVF Deployments

In the previous blog post, I showed how to deploy a multi-tiered OVF package using the Deploy OVF Template Wizard in the vSphere Client. The interactive workflow provided by the vSphere Client is hard to beat in terms of ease of use and simplicity. However, the graphical user interface also has it drawbacks. In particular, it can be fairly cumbersome to use if you have a large set of similar OVFs that needs to be deployed, or you want to automate a deployment. In those cases, a command-line utility is often preferred. Well, we have exactly the solution for that: OVF Tool 1.0.

OVF Tool provides a slew of different features, such as converting between OVF and .vmx formats and import/export of OVF 1.0 to vSphere 4.0, VirtualCenter 2.5/ESX 3.5 and earlier releases.

In the following I will show how to deploy the SugarCRM solution from the command-line and get exactly the same result as I got from the vSphere Client last week.

First, I probe the SugarCRM.ova to figure out what it contains and particular what parameters can be customized.

f:\>ovftool –hideEula http://aar-ovfrepo/ovf/SugarCRM.ova
Opening OVA source: http://aar-ovfrepo/ovf/SugarCRM.ova
OVF version:   1.0
Name:          SugarCRM
Version:       4.5.1e
Full Version:  4.5.1e-build 131
Vendor:        SugarCRM Inc
Product URL:   http://www.sugarcrm.com/crm/products/crm-products.html
Vendor URL:    http://www.sugarcrm.com/crm/

Annotation:  The sweet way to manage customer relationships.

End-user License Agreements:
  Present:     Yes (1)

Download Size:   764.49 MB

Deployment Sizes:
  Flat disks:     20.00 GB
  Sparse disks:    1.55 GB

Networks:
  Name:        Network
  Description: The network that the SugarCRM application will be available on

Virtual Hardware:
  Family:       vmx-04
  Disk Types:   SCSI-lsilogic

Properties:
  Key:         emailAdmin
  Category:    Application
  Label:       Administrator Email Address
  Type:        string
  Description: Enter email address for administrator. This is displayed on the help page.

  Key:         theme
  Category:    Application
  Label:       Theme
  Type:        string["Sugar", "RipCurl", "Retro", "Paradise", "Love",
               "Sunset"]
  Description: Select the default color/graphic scheme

  Key:         concurrentSessions
  Category:    Performance
  Label:       Concurrent Sessions
  Type:        int(10..1000)
  Description: The maximum allowed concurrent sessions.

  Key:         dbIp
  Category:    Network
  Label:       Database instance IP address
  Type:        ip:Network
  Description: IP address for the database instance (in dot-notation).

  Key:         webIp
  Category:    Network
  Label:       SugarCRM IP Address
  Type:        ip:Network
  Description: IP address on the SugarCRM application server. The service is made accessible at this IP address.

Deployment Options:
  Id:          small
  Label:       Evaluation
  Description: Use this configuration for evaluation purposes on
ly. The number
of CPUs required and amount of memory used is minimized, making it possible to run the system on a desktop system.

  Id:          medium
  Label:       Production
  Description: Standard settings for a typical product environment. This deployment option is suitable for a SMB production environment with less than 500 users.

  Id:          large
  Label:       Enterprise
  Description: Settings for large enterprise production environments. This deployment option is suitable for a large enterprise production environment with more than 500 users.

IP Allocation Policy:
  Schemes:     ovfenv dhcp
  Protocols:   IPv4

Completed successfully

By examining this output, I can gather the same information as was shown in the vSphere Client, such as product information, download sizes, end-user license agreements, deployment options, properties that can be customized, and supported IP policy schemes.

The next step is to deploy this to my vSphere 4.0 server. OVF Tool provides a handy pseudo-interactive mode for probing the vSphere inventory, so I do not have to open the vSphere client to look up the inventory organization or names of networks and datastores. To get started, I simply try and deploy it:

f:\>ovftool http://aar-ovfrepo/ovf/SugarCRM.ova vi://aar-dev-cluster-vc1
Opening OVA source: http://aar-ovfrepo/ovf/SugarCRM.ova
Please enter login information for target vi://aar-dev-cluster-vc1/
Username: VMWAREM\renes
Password: *********
Error: Found wrong kind of object (Folder)
Possible completions are:   
  aar-dev-datacenter/
  Jan's Test Datacenter/   

Ok, so the first completion is: vi://aar-dev-cluster-vc1/aar-dev-datacenter/. After a few more iterations, I get to this:

f:\>ovftool –acceptAllEulas http://aar-ovfrepo/ovf/SugarCRM.ova vi://VMWAREM%5Crenes@aar-dev-cluster-vc1/aar-dev-datacenter/host/Cluster/Resources/DemoPool
Opening OVA source: http://aar-ovfrepo/ovf/SugarCRM.ova
Please enter login information for target vi://aar-dev-cluster-vc1/
Username: VMWAREM\renes
Password: *********
Opening VI target: vi://VMWAREM\renes@aar-dev-cluster-vc1/aar-dev-datacenter/host/Cluster
Error: No target datastore specified
Datastores found on target:
  Cluster VMFS
  Storage1

It now provides completions for datastores. Simlilarly, OVF Tool will provide completions for networks (if there are multiple choices). The final command to deploy, customize, and power-on the SugarCRM OVF package is:

f:\>ovftool "–datastore=Cluster VMFS"
            "–network=VM Network"
            –acceptAllEulas
            -ipAllocationPolicy=transient
            –prop:emailAdmin=admin@vmware.com
            –prop:theme=Retro
            –powerOn
            http://aar-ovfrepo/ovf/SugarCRM.ova
            vi://VMWAREM%5Crenes@aar-dev-cluster-vc1/aar-dev-datacenter/host/Cluster/Resources/DemoPool
Opening OVA source: http://aar-ovfrepo/ovf/SugarCRM.ova
Please enter login information for target vi://aar-dev-cluster-vc1/
Username: VMWAREM\renes
Password: *********
Opening VI target: vi://VMWAREM\renes@aar-dev-cluster-vc1/aar-dev-datacenter/host/Cluster/Resources/DemoPool
Target: vi://aar-dev-cluster-vc1/aar-dev-datacenter/host/Cluster/Resources/DemoPool
Disk Transfer Completed
Powering on vApp: SugarCRM
Completed successfully

Voila! (Standard disclaimer: I inserted a few line breaks to make it more readable. How to escape spaces in parameters varies whether you are on Linux or Windows).

This was just a very quick preview of the features of OVF Tool. Consult the documentation for more examples, and download the tool today to try it out for yourself. Next time,
I will dive into the internal structure of the SugarCRM OVF package.