I recently noticed a trend of questions from various users about extracting specific bits of information such as the version of ESXi that's running or the MoRef ID of the VM, all while within the guestOS. I had already written an article about this topic awhile back called How to extract host information from within a VM? but it seems like there is still a continued interest to easily obtain this information about the underlying vSphere infrastructure from within the guestOS.

I came across another method while researching a different topic which is to use the vApp property of a VM called the OVF runtime environment. This is a feature that has been around since the early days of vSphere 4.x, if not earlier which provides a mechanism to retrieve some of this information as well as custom properties. 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.

The OVF runtime environment is only available while the VM is powered and it can be accessed from either VMware Tools or from a special ISO that is mounted to the guestOS CD-ROM device. To enable the OVF runtime environment, you just need to perform these two simple steps:

1. Edit your VM and select the Options tab and enable the vApp Options:

2. 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 enabling this using the vSphere API, take a look at the vAppConfig property. You can enable OVF runtime environment on a running VM, but the changes will not go into effect until the VM has been completely powered off and then powered back on, a guestOS reboot will not suffice.

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 you have two options:

VMware Tools

Run the following command:

vmtoolsd --cmd "info-get guestinfo.ovfenv"

Below are two examples for both a Linux and Windows VM:

ISO Image

Mount the CD-ROM in the guestOS and inside you will find the ovf-env.xml file which contains the OVF runtime environment information.

As I mentioned earlier, you can also create custom key/value properties which can then be accessed by the guestOS VM. If you go to Advanced section and click on the Properties button, you will be able to add your own custom properties. Below is a screenshot of adding three customer properties called: application_owner, startup_option and system_owner just to give you an idea of the possibilities.

The OVF runtime environment does not just stop with vSphere, but it is also available to VMs running in vCloud Director. The only requirement is that vCloud Director VMs has the vApp options enabled at the vSphere layer as noted earlier. Below is a screenshot for a VM that has been imported into vCloud Director from vSphere and you will notice some additional "vCloud Director" specific properties.

Even though the OVF runtime environment makes it easier to retrieve some of these "underlying" infrastructure details, I am still interested in some of the use cases where you would need to know the hypervisor version or MoRef ID from within the guestOS. If you are currently requiring this or other bits of information, please leave a comment about your particular use case.

27 thoughts on “OVF Runtime Environment

  1. Knowing the MoRef ID might help in providing a “uniqueness” to the VM. Say, for example, I need to encrypt something on the VM using a bunch of data within the VM. I want that data to be something that can survive a vMotion. Today, if you use CPU info, its possible vMotion will cause a failure in unlocking the encrypted stuff. Using unique identifiers as part of the generation of the hash used to encrypt can get around that.

    • Thanks for the comment Mike. Though the MoRef may not always be unique, do you think users would rather use their own “internal” identifier and associate that with the VM during deployment which can then be accessed from within the VM?

  2. Ideally, I’d like to see the unique value or set of values be presented by vCenter to the VM. Something that an app within the VM can query via an API or some other method. If you have thoughts on this, then I’d like to set up a call with one of our guys who works on stuff like this.

    • Mike, this is definitely possible but the “unique” values would be something an end user would need to specify during or after deployment. OOTB, you can get MoRef but that may not always be unique, but you can add other key/value properties to the VM to help identify it (e.g. CMDB, asset tag, etc). Let me know if you want to chat about this further

  3. Hi,
    I’ve imported into vCloud a vAPP which is using the “ISO Image” method for access OVF settings.
    When I boot the VM, the ISO image isn’t “inserted into CD”.
    Any idea what I’m doing wrong?
    Thanks,
    M.

  4. This is a great article. I think people should start thinking about using technology like this because it could be good for the environment. This year I want to start using different technology and products that are better for the environment. Last year I decided to switch power suppliers in my home. After I learned about NA Power I decided to find a supplier that used green gas.

  5. William, can you advise on possible ways to modify values in the OVF runtime environment of a machine after it has been created? For example…

    My OVF environment originally had a property, . I want to change that to .

    Some quick Googling makes it appear that there are vCloud APIs which would allow one to do this? What if I have a vSphere/vCenter-only environment?

    Thanks.

  6. [comment engine didn’t like that I put actual XML code in here. retyping with generic key/value formatting]

    William, can you advise on possible ways to modify values in the OVF runtime environment of a machine after it has been created? For example“

    My OVF environment originally had a property, example=foo. I want to change that to example=bar.

    Some quick Googling makes it appear that there are vCloud APIs which would allow one to do this? What if I have a vSphere/vCenter-only environment?

    Thanks.

  7. Hi William,
    If i create OVF from vmware VM having custom properties set using this procedure, is there a way to define values of custom properties when we deploy OVF in HyperV /Citrix Xen?

    Thanks,

    • Sam,

      Sure, but I can’t speak for other Hypervisors on whether they’ve implemented such capabilities. It’s something you’ll have to either ask them or test it out yourself

        • The OVF runtime is just how VMware has implemented the ability to consume custom OVF properties which a subset are going to be specific to VMware based solutions. If I were to take a guess, you’ll probably be able to export/import a VM to OVF to another hypervisor assuming they’ve implemented the basics but if they have no concept of consuming OVF properties (just key/value pairs) or have not implemented it, then there’s a chance it probably may or may not work. Again, it’s something you’ll just have to try.

  8. William, i deployed a ovf file of n1kv in my VC however when i do a write erase and reload the VM, console/ova custom properties comes all the times,how to customize that section so that VM boots up to login console than asking each time the VM console inputs.

  9. I have created a VM using ovftool and populated a self created ip address value. do you know how to get windows to read this value and add the ip address to the guest os ? latest versions of esxi and windows

      • thanks. I have ran that but it doesn’t pull the ip address in. It can read the ovf env but not assigning it to the vm. How would windows know that the ip address given would be an ip address and not a dns address for example . Its simply created as an ip value

        • Well first off, make sure it’s actually properly set and secondly, the “setting” would have to be done through a custom script you have within the guestOS. There’s nothing magically that’ll configure the OS, these are just key/value pairs being passed in and something would need to know how to pickup the right variables such as DNS or IP Address based on the variables you’ve created.

          • yeah that’s the missing part. thanks. Any idea on what could be used to do this ? python script maybe ?

  10. Great blog, William! I have scoured the web looking for the answer to this question and I can’t seem to find it. I want to be able to automate the creation of VMware Appliances and I have all that working, but I can’t seem to programmatically inject the properties for networking into the OVF. I see how you’ve done it with the GUI and that all works, but this is not good for automation. VMware’s now end-of-life Studio was able to do this but I can’t find another CLI tool that does the same. Any advice? Thanks

  11. as far as i got any changes to the VM at runtime needs a power off/on to be reflected in the ovf environment. I have a use case that needs to change the port group name at runtime and it would be great if the ovf would report the new name and respective MAC address without any need to power off/on the VM.
    The strange thing is that in VM settings->vAPP option the ovf env file is updated without any power off/on.
    Any chance to get an update ovf files without power off/on?

Thanks for the comment!