Using the Skytap Virtual Machine Metadata Service

On August 6, 2013, Skytap announced the availability of a Skytap metadata service that allows access to Skytap-specific virtual machine (VM) metadata from within a running VM. This allows you to leverage information about a running VM from a command line, application or script running within the VM itself. Additionally, this metadata service also introduces a “user data” facility that allows a user to pass custom data to the VM, which can be consumed and acted upon by your application or scripts within the VM.

The ability to easily access VM metadata from within the running Skytap VM enables, for example, sophisticated self-provisioning scenarios where provisioning data for an application or for the VM itself could be embedded in the “User Data” metadata associated with a VM and then be acted upon by a script or application running on the VM. Many other uses of the Skytap VM Metadata Service are also possible.

To access the VM metadata from within a running VM, you simply issue an http GET request to //gw/Skytap. For example, here is such a request from a Firefox browser running within a Skytap VM:

Because the Skytap VM Metadata Service is an open REST protocol, applications running in the VM can consume this metadata in any language capable of REST interactions; e.g., C#, Java, Ruby, Python, etc.

For example, below we issue a “curl” command to deliver the HTTP REST request as might be done from a shell command line or shell script:

curl -X GET “http://gw/skytap” -H “Accept: application/xml” -L –location-trusted

By default, the metadata service will return data in JSON format. To illustrate that you can also return data in XML format, in this example I’ve included an “Accept: application/xml” header that directs the metadata service to return information to me in XML format.

Below is a screenshot showing the result of this command:

To make this useful, I will reissue the command and direct the XML output to a file named vm-info.xml:

The vm-info.xml file now contains the information returned from the Skytap metadata service. We can now use a script to parse that data and do useful things with it. I’ve previously added some custom user data to this VM in the User Data tab of the Skytap VM Settings panel:

Here is a simple Ruby script that parses the VM data, including my custom user data and print some of it out:

Below is a screenshot of the result of running this script:

Of course you could streamline this process by issuing the VM Metatdata Service REST request from within the Ruby script and the intermediate file would not be required.

Note that we can access the standard VM metadata that is associated with all Skytap VMs, in this case the VM ID, the VM Name, and the VM Runstate, but we can also access the custom user data that I added to the VM previously.

Summary

The above scenario illustrates how you can now use the Skytap VM Metadata service from within a running VM to access information about the VM. The scenario also illustrates how to save this data, then use a script to parse it to retrieve both standard metadata that is associated with all Skytap VMs and the custom user data you might want to use within a running VM.

Feel free to get in touch if you would like additional information. Skytap support is always available to help you if you have any issues with the Skytap VM Metadata Service.

Join our email list for news, product updates, and more.