Category Archives: API

Virtual Machines meet Virtual Reality at VMworld US 2017

Normally when I create blogs and use the word “virtual” it of course refers to the awesome virtualization technology invented by VMware, this post however is a little different but still just as awesome!

The virtual word that I speak of in this post refers not just to virtual machines but also to virtual reality.  Having purchased a HTC Vive earlier this year and being totally inthralled by virtual reality (VR), I started to wonder what an enterprise world would look like if we all had VR headsets, how would we control todays applications in a VR world?

I don’t want to give away too much information just now as the excitement will be at VMworld and on stage, lets just say that managing your virtual infrastructure has never been so much fun, here is a teaser for now:

Want to win a HTC Vive and Alienware laptop?

This year at VMworld I will be presenting an awesome demo on stage with the following members of the VMware executive leadership team and VPs:

  • Raghu RaghuramChief Operating Officer – Products & Cloud Services
  • Mark LohmeyerVP Products for Cloud Platform Business Unit
  • Guido AppenzellerCTO Cloud & Networking

During this session we will be showing some cool integrations with Virtual Reality and VMware products.

As part of this session we will also be giving away a fully spec’d Dell Alienware laptop and a full HTC Vive headset and accessories.

Believe me, this is an awesome piece of equipment that will blow your mind!

To enter all you need to do is attend the following session, watch the demo and wait for the chance to win this amazing prize!

Session: Simplifying and Accelerating Your Multi-Cloud Strategy [IPC7001KU]

Add it to your session list here: https://my.vmworld.com/scripts/catalog/uscatalog.jsp?search=[IPC7001KU]&showEnrolled=false

Im looking forward to blowing some minds in this session!

 

Using the Runecast API with Postman

In my previous post I had worked with a version of Runecast and provided an initial look at the awesome app that helps keep your vSphere environment running at peak operational configuration.

As part of my feedback I suggested they start looking at a REST API, as it turns out the smart guys at Runecast were already way ahead of me and on June 13th released a new version with a great REST API and API Explorer to work with it, within a couple of clicks I updated my Runecast deployment to the latest version (super easy) and it gave me the latest and greatest features to work with including the API which can be found under the settings page and API Access token and then clicking the “Runecast API” link at the top, this brings up a swagger based API Explorer as seen below:

runecast-api-explorer

You can use the API live here or through any other REST based client, personally I like to try postman and start to understand the API a little more by creating a collection, this is exactly what I did and have made available via a github repo for you to download, use against your environment and also contribute back to with more samples in the collection.

Getting started with the Runecast Postman collection

Getting started couldn’t be easier just follow the below steps to use the collection against your Runecast server:

  1. Ensure you have Runecast 1.5.4.0 or above as this has the API
  2. Download and install Postman if you don’t have it already from https://www.getpostman.com/
  3. Download or clone my Runecast Postman Collection from my github repo from here
  4. You should now have 2 files from that repo, the first is the collection of REST calls and the second is an environment, the environment is used to specify 2 key pieces of information so we don’t have to keep retying these and also makes the collection portable.
  5. Open postman and click the import button at the top left, import the two files from the github repo and close the import button.
  6. You will now see the collection in the left hand pane and the environment will be available for you to adjust on the right hand side as seen below:

colelction

7. Next you will need to edit the environment and change the information to match your setup, firstly change the IP to the hostname or IP of your Runecast server.

8. Secondly change the APIKey to an APIKey that you have generated from the Runecast app, to do this go to Settings -> API Access tokens and select “Generate API access token“. Provide a description so you know what it is used for and once you click on “Generate“, your access token will be ready. Make sure to copy it, as you’ll not be able to see the same token again and we will need it in Postman. Paste the APIKey into the postman environment replacing the one in there at the moment and close the environment.

9. If all was done correctly above you should now be able to click on the collections and use the SEND button to call the API and see the results, note that some of these APIs require an ID which you will need to customize in the URL in postman as at the moment it has my IDs for things like my VC.

An example of me using postman to call the Runecast API is below:

Runecast-Postman-Usage

Conclusion

Using the Runecast API either by the API Explorer built into the app or via a standard REST based tool from the internet is super easy to do and allows integration and access to the wealth of details in the Runecast App, I hope the guys from Runecast extend this API to include configuration items in the future to allow a zero touch deployment of the app for automated rollouts but this is a great start.

Stay tuned for my next post where I will show you how we can easily integrate this with PowerCLI and get interesting information using a combination of PowerShell functions I have written and PowerCLI.

A Quick Reference of vSphere IDs

How do you identify the components within your virtual environment? You give them names right?! Well to programmatically identify the same components that’s exactly what VMware does but rather than names they give them IDs and guess what, there are a lot of different IDs, so many that people often get mistaken by which ID to use in which circumstances and what they refer to.

After a discussion with one of VMware’s brightest engineers (Thanks Jeff Hu) and a long email thread where he dumped his brains on what these IDs were for, I thought I would blog them and make use of this awesome information.

vCenter IDsSo here goes, here is a list of a number of the different IDs used in the virtual infrastructure and how they are used:

image1. VC Instance UUID (aka serverGuid): This is a GUID that identifies the vCenter server.  This is accessible from the AboutInfo property in the VIM API.  The property name is AboutInfo#instanceUuid.  It’s set at install time and is persisted so the value is durable for a given VC instance.

To access this via PowerCLI you can use the following:

PS C:\> $vcenter = Connect-viserver vcsa-01a.corp.local -User Administrator@vsphere.local -Password VMware1!

PS C:\> $vcenter.InstanceUuid

d322b019-58d4-4d6f-9f8b-d28695a716c0

2. The ESX Host UUID is read by the ESX host from the System Management BIOS (SMBIOS). This UUID is not generated by VMware, it is unique to the hardware and is set in the BIOS by the vendor.

To access this via PowerCLI you can use the following:

(Get-VMHost | Select -first 1).ExtensionData.hardware.systeminfo.uuid

3. VC-VM Instance UUID: This is the vc.uuid property in the VM vmx configuration file and also the instanceUuid property on the VmConfigInfo for a VirtualMachine in the VIM API.  This UUID is used by vCenter to uniquely identify VMs that it is managed.  vCenter assigns this UUID to the VM after it is created.  There are different workflows where a VM may not have a UUID initially or may have a duplicate.  vCenter actively looks over the VM inventory and will automatically patch the VM instance UUID if it sees a duplicate.

The scope of this uniqueness scan is a vCenter instance.  If there are duplicate VC-VM Instance UUIDs, they will not be detected as duplicates unless the VMs are managed by the same vCenter instance.  This value can be changed through the API.

To access this via PowerCLI you can use the following:

PS C:\> (Get-VM | Select -first 1).extensiondata.config.InstanceUUID

502e363d-393c-b0a4-8ede-639db30a625e

4. VM SMBIOS UUID: This is the uuid.bios property in the VM vmx configuration file.  In the VIM API, this is the uuid property on the VmConfigInfo for a VirtualMachine managed object.  This UUID is visible to the guest OS as the SMBIOS UUID.  VMware generally try to avoid changing this UUID since it is often used by applications that manage the guest OS instances.  When the VM is migrated this UUID is maintained.

vCenter does a best effort to try to make sure these UUIDs are unique in an environment.  For operations like clone and deploy that create a new VM, a new UUID is provided to the VM by clearing the uuid.bios from the VM’s vmx file.  If the VM is copied without vCenter’s knowledge, 3rd party tools are advised to do the same thing as vCenter.  A new uuid.bios is generated the next time the VM is powered on.  This UUID is generated by the ESXi server so vCenter does not have to be in the control flow for the uuid.bios to be generated.

To access this via PowerCLI you can use the following:

PS C:\> (Get-VM | Select -first 1).extensiondata.Config.UUID

422ee9f4-6cfd-1fb7-1376-a8ecb8eb8568

5. VM Location ID: This identifier is stored in the VM configuration file as the variable uuid.location.  In the VIM API, the name is locationId also on the VmConfigInfo of the VirtualMachine.  This is one other detail that might be relevant to a 3rd party solution that might be moving the VM without vCenter’s knowledge.  This property is used in conjunction with the VM SMBIOS UUID.  This property is a hash of the VM’s configuration file and some UUID of the ESXi. The purpose of this UUID is to detect out-of-band migrations and copies of the VM.  If vSphere (or Workstation/Fusion) detect that the locationId is no longer valid, it will pop up dialog/question/error asking the user why the locationId is no longer valid.  The user is prompted to answer whether the VM was moved or copied.  The purpose is so that vSphere can determine whether it should keep the existing the SMBIOS UUID or generate a new one.

Recall, I mentioned that vCenter is doing a best effort to ensure the SMBIOS UUID is unique.  But when it detects a potential conflict, vCenter will not automatically patch the UUID since this could break 3rd party and VMware products that rely on the guest visible UUID to correlate the VM with other management entities in the environment.

The way 3rd party solutions can best interoperate with vCenter and it’s attempt to preserve a unique SMBIOS UUID is to be aware of these semantics.  If a 3rd party solution or program is moving the VM, it should clear out the uuid.location (ie. ConfigInfo.locationId) property.  On next power on, a new uuid.location will be generated, binding the VM to ESXi host and the file path where it is running.

Despite this however, there is a theoretical and real possibility that there could be duplicate SMBIOS UUIDs.  Because vCenter is deferring to what the user of the system what the the SMBIOS UUID should be, it will not change the UUID automatically if it detects conflicts.  If there SMBIOS UUIDs that are duplicated, it will not fix them.

To access this via PowerCLI you can use the following:

PS C:\> (Get-VM | Select -first 1).extensiondata.config.LocationId

564d043c-5dab-5413-c4a7-fb0837d354d9

6. VM MoRef: The VM MoRef is a short key used by a vCenter instance to identify the VM.  This is the primary identifier used by the VIM API to refer to the VM.  The other identifiers can generally be used to find the VM, but the VM MoRef is the one that must ultimately be used to get data and issue operations to modify the VM.

In general, the MoRef is the important identifier because that’s what is used in the VC database to associate a VM to its stats, events, and configuration.

In environments where multiple vCenters are used, the MoRef will not necessarily be unique.  As a result, another identifier needs to paired with the VM MoRef or used instead.  In general, vSphere uses a combination of the vCenter instance UUID (ie. the serverGuid) with the MoRef to identify the VM for cross-vCenter scenarios like Linked Mode.

To access this via PowerCLI you can use the following:

PS C:\> (Get-VM | Select -first 1).ExtensionData.Moref.Value

vm-43

More Information

William Lam also has some awesome posts on IDs which you may find useful, please read these for further related information:

Conclusion

A lot of Information and different IDs I know but hopefully this will help you identify which to use and when so that you can get the most out of your Virtual Infrastructure!

Same company different focus, let me know about your API wants!

For over a year I have been focused on improving VMware Command Line Interfaces including PowerCLI, vCLI, vMA, ESXCLI & DCLI.  I have tried to stay close to what the users of VMware want from a command line interface and have been delivering this as part of our current offerings and future offerings, I have been working with some of the best development teams in the industry (I may be biased) and have enjoyed talking to customers who use my products to do a variety of awesome things.

Well, none of that changes yet! I mean I am still responsible for working with the command line tools so please keep the feedback coming.

 

imageI have however recently taken over a new role and focus at VMware, one which I am highly excited to work on and make a real impact.  Around a month ago I took over the responsibility for the vSphere API and the vCloud Suite API, SDKs and CLIs.  There is a lot going on here and obviously that does not mean I am responsible for every feature which has an API!  In this new role I will be helping drive VMware APIs forward, working with customers and partners to identify gaps in our API/SDK/CLIs, define new APIs/SDKs/CLIs and work with multiple products and services within VMware to drive a better experience for people who use VMware products for automation or customers/partners who develop against our APIs to provide integration or DevOps engineers who want to just automate the entire experience and provide a constant lifecycle for their business processes or products.

Talk to me

Hopefully those who I have spoken to before, be it on twitter or via phone call or email or even over a beer know that I am an approachable guy, I may not always be able to talk about timeframes or where we are headed with our products but I promise you I will certainly take your feedback and prioritize it to produce the most valuable product to you.  Please do feel free to let me know what you think about the VMware APIs/SDKs/CLIs, the good, the bad and the ugly!

I would appreciate your quick thoughts on our APIs and what you would like to see going forward from us, feel free to use the comments on this post to pass them along or contact me via the other means mentioned.