The Power of OVF Properties

The Open Virtualization Format (OVF) is very powerful and something I would encourage everyone interested in creating virtual appliances to really read up on. Through OVF properties you can configure a variety of virtual machine settings including:

  • Networking
  • Resources
  • Password
  • and really anything!

I would like to provide some examples of how to create some of these specifications.


NOTE: The examples provided below are only subsets of an actual OVF XML file. My examples are coming from the Log Insight OVF XML file. For a complete example check out the Log Insight 2.0 OVF file. Also, note that all examples are from a VMware Studio built OVF.

Networking

First, you need to specify the network interfaces:

<NetworkSection>
   <Info>List of logical networks used in the package</Info>
   <Network ovf:name="Network 1">
      <Description>The "Network 1" network</Description>
   </Network>
</NetworkSection>

Next, you need to specify what parameters can / need to be set for networking:

<VirtualSystem ovf:id="VMware_vCenter_Log_Insight">
   <ProductSection ovf:class="vami" ovf:instance="VMware_vCenter_Log_Insight" ovf:required="false">
   <Info>VAMI Properties</Info>
   <Category>Networking Properties</Category>
   <Property ovf:key="hostname" ovf:type="string" ovf:userConfigurable="true" ovf:value="" ovf:qualifiers="MinLen(0),MaxLen(65535)">
      <Label>Hostname</Label>
      <Description>The hostname or the fully qualified domain name for this VM. Leave blank if DHCP is desired.</Description>
   </Property>
   <Property ovf:key="ip0" ovf:userConfigurable="true" ovf:type="string">
      <Label>Network 1 IP Address</Label>
      <Description>The IP address for this interface. Leave blank if DHCP is desired.</Description>
   </Property>
   <Property ovf:key="netmask0" ovf:userConfigurable="true" ovf:type="string">
      <Label>Network 1 Netmask</Label>
      <Description>The netmask or prefix for this interface. Leave blank if DHCP is desired.</Description>
   </Property>
   <Property ovf:key="gateway" ovf:userConfigurable="true" ovf:type="string">
      <Label>Default Gateway</Label>
      <Description>The default gateway address for this VM. Leave blank if DHCP is desired.</Description>
   </Property>
   <Property ovf:key="DNS" ovf:userConfigurable="true" ovf:type="string">
      <Label>DNS</Label>
      <Description>The domain name servers for this VM (comma separated). Leave blank if DHCP is desired. WARNING: Do not specify more than two DNS entries or no DNS entries will be configured!</Description>
   </Property>
</ProductSection>

Finally, you need to define the virtual hardware to be used for networking:

   <VirtualHardwareSection ovf:transport="com.vmware.guestInfo" ovf:required="false">
      <Info>Virtual Hardware Requirements</Info>
      <Item>
         <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
         <rasd:Connection>Network 1</rasd:Connection>
         <rasd:ElementName>Ethernet adapter on "Network 1"</rasd:ElementName>
         <rasd:InstanceID>3</rasd:InstanceID>
         <rasd:ResourceSubType>vmxnet3</rasd:ResourceSubType>
         <rasd:ResourceType>10</rasd:ResourceType>
      </Item>
   </VirtualHardwareSection>
</VirtualSystem>

Resources

First, you need to specify deployment options:

<DeploymentOptionSection>
   <Info>The list of deployment options</Info>
   <Configuration ovf:id="xsmall">
      <Label ovf:msgid="config.xsmall.label">Extra Small</Label>
      <Description ovf:msgid="config.xsmall.description"> IMPORTANT: This configuration is intended for proof-of-concept or test environments and should not be used in a production environment.
This configuration supports up to 20 ESXi hosts (~200 events/second or ~3GB/day) and requires the following:
* 2 CPUs (minimum 2.0GHz)
* 4GB RAM
* 132GB of storage (100GB for event storage) - thick provisioned, eager zeroed highly recommended
* VM hardware version 7 or greater (vSphere 4.0 or greater)
      </Description>
   </Configuration>
   <Configuration ovf:id="small" ovf:default="true">
      <Label ovf:msgid="config.small.label">Small</Label>
      <Description ovf:msgid="config.small.description">This configuration supports up to 100 ESXi hosts (~1000 events/second or ~15GB/day) and requires the following:
* 4 CPU (minimum 2.0GHz)
* 8GB RAM
* 132GB of storage (100GB for event storage) - thick provisioned, eager zeroed highly recommended
* VM hardware version 7 or greater (vSphere 4.0 or greater)
      </Description>
   </Configuration>
</DeploymentOptionSection>

Then you need to specify sizing per deployment options:

<VirtualSystem ovf:id="VMware_vCenter_Log_Insight">
   <VirtualHardwareSection ovf:transport="com.vmware.guestInfo" ovf:required="false">
      <Info>Virtual Hardware Requirements</Info>
      <System>
         <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
         <vssd:InstanceID>0</vssd:InstanceID>
         <vssd:VirtualSystemType>vmx-07 vmx-08 vmx-09</vssd:VirtualSystemType>
      </System>
      <Item ovf:configuration="xsmall">
         <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
         <rasd:Description>Number of virtual CPUs</rasd:Description>
         <rasd:ElementName>2 virtual CPUs</rasd:ElementName>
         <rasd:InstanceID>1</rasd:InstanceID>
         <rasd:ResourceType>3</rasd:ResourceType>
         <rasd:VirtualQuantity>2</rasd:VirtualQuantity>
      </Item>
      <Item ovf:configuration="small">
         <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
         <rasd:Description>Number of virtual CPUs</rasd:Description>
         <rasd:ElementName>4 virtual CPUs</rasd:ElementName>
         <rasd:InstanceID>1</rasd:InstanceID>
         <rasd:ResourceType>3</rasd:ResourceType>
         <rasd:VirtualQuantity>4</rasd:VirtualQuantity>
      </Item>
      <Item ovf:configuration="xsmall">
         <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
         <rasd:Description>Memory Size</rasd:Description>
         <rasd:ElementName>4096 MB of memory</rasd:ElementName>
         <rasd:InstanceID>2</rasd:InstanceID>
         <rasd:ResourceType>4</rasd:ResourceType>
         <rasd:VirtualQuantity>4096</rasd:VirtualQuantity>
      </Item>
      <Item ovf:configuration="small">
         <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
         <rasd:Description>Memory Size</rasd:Description>
         <rasd:ElementName>8192 MB of memory</rasd:ElementName>
         <rasd:InstanceID>2</rasd:InstanceID>
         <rasd:ResourceType>4</rasd:ResourceType>
         <rasd:VirtualQuantity>8192</rasd:VirtualQuantity>
      </Item>
      <Item>
         <rasd:AddressOnParent>0</rasd:AddressOnParent>
         <rasd:ElementName>Harddisk 1</rasd:ElementName>
         <rasd:HostResource>ovf:/disk/system</rasd:HostResource>
         <rasd:InstanceID>5</rasd:InstanceID>
         <rasd:Parent>4</rasd:Parent>
         <rasd:ResourceType>17</rasd:ResourceType>
      </Item>
      <Item>
         <rasd:AddressOnParent>1</rasd:AddressOnParent>
         <rasd:ElementName>Harddisk 2</rasd:ElementName>
         <rasd:HostResource>ovf:/disk/data_120GB</rasd:HostResource>
         <rasd:InstanceID>6</rasd:InstanceID>
         <rasd:Parent>4</rasd:Parent>
         <rasd:ResourceType>17</rasd:ResourceType>
      </Item>
   </VirtualHardwareSection>
</VirtualSystem>

Password

It turns out you can define whatever properties you want in the OVF XML file and pass them to the VM. A great use case of this functionality is to set the root password on the VM. To do this, you could define the password as follows:

<VirtualSystem ovf:id="VMware_vCenter_Log_Insight">
   <ProductSection ovf:class="vm" ovf:required="false">
      <Info>VM specific properties</Info>
      <Property ovf:key="vmname" ovf:type="string" ovf:value="VMware_vCenter_Log_Insight"/>
      <Category>Other Properties</Category>
      <Property ovf:key="rootpw" ovf:password="true" ovf:type="string" ovf:userConfigurable="true" ovf:value="" ovf:qualifiers="MinLen(0),MaxLen(65535)">
         <Label>Root Password</Label>
         <Description>By default the root password is blank and SSH is disabled. A root password can be set during deployment time if desired. For security reasons, it is recommended to use a password that is a minimum of eight characters and contains a minimum of one upper, one lower, one digit, and one special character.</Description>
      </Property>
   </ProductSection>
</VirtualSystem>

The great part about this is that the OVF specifications allows for passwords and hides this on the screen. Some limitations to this approach are that the password is saved in plain-text within the VM and you cannot enforce password complexity, but still pretty cool if you ask me.
With the password set, you can access the property by running ovfenv within the VM. To get just the password you could run: ovfenv -k vm.rootpw. How cool is that?!?
NOTE: ovfenv requires VMware Studio (thanks Andrew!)

Advanced Settings

One thing that is VMware specific and not part of the OVF specification is the ability to add VMware specific markup. This markup is not officially documented, but a Google search pulls up a variety of examples. A great example of the VMware markup is the vmw:ExtraConfig markup, which allows you to pass advanced settings to a VM. This can be used to set things such as the keyboard delay of the console:

   </Item>
   <vmw:ExtraConfig ovf:required="False" vmw:key="keyboard.typematicmindelay" vmw:value="2000000"></vmw:Config>
</VirtualHardwareSection>

NOTE: With the above setting, you will need to select a checkbox during VM deployment to confirm you want a non-standard option to be passed.

Want more?

For more cool things you can do with OVF check out all the awesome posts William Lam has:

UPDATE1: Added more posts from William about OVF properties.
UPDATE2: Added information about VMware Studio and ovfenv based on feedback from Andrew Sharpe.

© 2014 – 2021, Steve Flanders. All rights reserved.

4 comments on “The Power of OVF Properties

Atif says:

Can you please tell me that how i can create OVA/OVF template which have deployment option feature so that user can create the VM by selecting the option from deployment options available for HarDisk Size and number of CPU

Use VMware Studio (free) as it provides this functionality.

Jeff Silberman says:

Editing the OVF (XML) file directly is not the right way to do this at all.
The correct approach is via the ‘ovftool’ command line, such as :
‘ovftool –allowExtraConfig \
–extraConfig:keyboard.typematicMinDelay=”2000000″ …

Hey Jeff — thanks for the comment! Using ovftool to specify the advanced parameter is great if you are comfortable with ovftool and only deploy with ovftool. Log Insight is made available to customers who deploy via all sorts of methods including the vSphere client. Instead of offloading the responsibility to the user to provide the parameter through a limited set of tools today, why not build it into the XML file so all users can have it without having to worry about adding it and without having to use specific tools? One of the big advantages of Log Insight is that it make the entire process quick and easy. This means handling as much for the user as possible.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top