The OVF feature provides users with the capability to pass in any type of metadata information such as application start up parameters, network configuration, password management, etc. directly into the guestOS for flexible guest customization. In this post, i will show how to fetch the runtime properties of the OVF from guest OS.
This 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. OVF properties are typically configured by the deployer of a vApp The OVF runtime environment is only available while the VM is powered.
Assuming that we have a VM already installed the operating system
We need to
- Define OVF properties on the VM.
- Write some glue code to access and apply the information inside the VM.
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.
Steps to Configure vApp Properties
- Edit your VM and select the Options tab and enable the vApp Options
- Under the OVF Settings, specify the how you want to access the OVF environment by either VMware Tools or ISO Image transport
- If you are interested in adding some custom properties, Click on Advance and click properties
- Create a new Property Keys; Select the Label, Type and other optional fields
- Create your required number of properties (i created 2 properties here)
- Click on vApp Option Properties, Type the Values for the properties
- Click ok
Wait for some seconds; Let the vSphere reconfigure the VM
After the settings have been applied, go back into the OVF Settings for a powered on VM and you now should be able to click on the “View” button which will show you the OVF runtime environment for that particular VM.
For a vanilla VM, you should see three basic things
- The vCenter MoRef of the VM (vApp property is only available with vCenter and not on a standalone ESXi host)
- The hypervisor name and version
- The network (Portgroup/Distributed Portgroup) the VM is connected to
To retrieve this same information from within the guestOS
Make sure you installed VMware Tools, to install VMware Tools refer http://blog.asvignesh.in/install-vmware-tool-in-virtual-ubuntu-guest/
Run the following command
Windows: “C:Program FilesVMwareVMware ToolsVMwareService.exe” -cmd “info-get guestinfo.ovfEnv”
Linux: vmware-guestd –cmd ‘info-get guestinfo.ovfEnv’
Mount the CD-ROM in the guestOS and inside you will find the ovf-env.xml file which contains the OVF runtime environment information.
You can find the ISO attached to VM under edit VM
Create a directory to mount the CD-ROM by running the command:
sudo mkdir /mnt/cdrom
Mount the CD-ROM by running the command:
sudo mount /dev/cdrom /mnt/cdrom or sudo mount /dev/sr0 /mnt/cdrom
You can find the xml file under this directory