WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Uncategorized / vSphere Tagging Feature Not So Invisible

vSphere Tagging Feature Not So Invisible

06.08.2011 by William Lam // 9 Comments

This evening I was reading a new blog post Tagging: An Invisible Feature in vSphere by Steve Jin in which he describes a hidden vSphere feature for tagging particular managed entities in your vSphere environment. The main consumer of this hidden feature is primarily VMware and it provides a level of meta data tagging to denote the importance of an entity. These tags are used in workflows in various vSphere products such as vCenter Server, vCenter Update Manager and View to just name a few.

Here is a screenshot of a VM entity using the vSphere MOB and as you can see from the tags, VMware can identify that this particular VM is running both vCenter Server and vCenter Update Manager.

If you have a VM that is a View Replica/Linked Clone, you may see these tags associated with the VM:

SYSTEM/COM.VMWARE.SIM.SVIMANAGEDOBJECT
SYSTEM/COM.VMWARE.VIM.SVIMANAGEDOBJECT

This feature can be really useful to allow users to tag particular objects in their environment of importance and easily correlate/integrate with a provisioning system and/or CMDB without having to resort to a separate database to store the meta data. You might say that custom fields exists today that can provide the same level of functionality, but they are actually pretty limited in scope. It only allows you to create custom attributes at a global vCenter level, host and virtual machine but not all managed objects such as Datastore, Networks, Resource Pool, etc.

So what if you wanted to create your own custom tags? Since these are hidden methods from VMware and they are not exposed through the public vSphere API, how might we access it? I spent a few minutes of digging and I was able to identify the two methods that pertained to tag management in the vSphere API:

addTag - Adds a tag to a managed entity
removeTag - Removes a tag to a managed entity

You can access both of these methods using the vSphere MOB as none of the official vSphere SDKs have these methods implemented. These methods are only supported when connecting to vCenter Server and are not exposed at an ESX(i) level.

In this example, I will create a custom tag at the Datacenter level called "WWW.VIRTUALLYGHETTO.COM"

Here is the path to a Datacenter object using the vSphere MOB:

If we scroll down on the page, you will notice a property called "tag" and as you can see in the screenshot below, no tags have been defined:

I will now craft the URL to the "addTag" method using the Datacenter as a point of reference:

https://reflex.primp-industries.com/mob/?moid=datacenter-1246&method=addTag

As you can see the method accepts an array of tags which can be defined within the section. All tags MUST begin with "SYSTEM/" and then a unique string following, in our example I used "SYSTEM/WWW.VIRTUALLYGHETTO.COM". Once you have created your tag, you will then click on the "Invoke Method" to add the tag. Since this method does not return anything, the return result is void.

Now if we go back to the Datacenter page and refresh the page, you should see the new tag that was just created:

To delete a tag, you will generate the same URL but replace "add" with "remove":

https://reflex.primp-industries.com/mob/?moid=datacenter-1246&method=removeTag

You will again fill in the tags to be removed and then click on "Invoke Method":

As you can see, you now have the power to create your own tags on various managed entities in your vSphere environment. If you want to automate this through a script or command line, you can create simple HTTP POST operations to the vSphere MOB or create the appropriate interface methods to the SDK bindings to support these hidden methods. I'll leave the latter as an exercise for the readers.

More from my site

  • Whitepaper: Migrating From VIX API to the vSphere Guest Operations API
  • Creating Custom vSphere Reports is a Breeze with CloudPhysics
  • How to Access vSphere Remote Console Using vSphere & VMRC API
  • Enabling/Disabling EVC using the vSphere MOB
  • The Dreaded fault.RestrictedVersion.summary Error

Categories // Uncategorized Tags // api, tag, vSphere

Comments

  1. *protectedGaurav says

    01/20/2015 at 5:05 am

    Is it also possible to get tags on vSphere 5.x using vSphere APIs ?

    Reply
    • William Lam says

      01/20/2015 at 7:55 pm

      No, currently there are no vSphere APIs for Tags. You can use PowerCLI, but its limited to read-only operations. Take a look at this blog post for some more details http://www.virtuallyghetto.com/2015/01/custom-attributes-vsphere-tags.html

      Reply
  2. *protectedDerick Winkworth (@cloudtoad) says

    02/12/2015 at 4:47 pm

    Where did you find these hidden methods? In a schema file or something?

    Reply
    • William Lam says

      02/12/2015 at 9:37 pm

      Just poking around various places, no specific area to find these things.

      Reply
  3. *protectedDavid Homer says

    01/28/2016 at 4:18 am

    Hey William, great post

    We were looking to document tags as part of our VMware inventory tool
    http://www.centrel-solutions.com/XIAConfiguration/Capabilities.aspx?capability=VMwareSystem

    I noticed that in vSphere 6 the Tags property in the MOB always seems empty - have VMware dropped this support now?

    Dave

    Reply
    • William Lam says

      01/28/2016 at 10:22 am

      The "Tag" feature noted in this blog is NOT the same as the new vSphere Tagging feature which was first introduced in vSphere 5.1. In vSphere 5.5, we have PowerCLI cmdlets to interact with vSphere Tags (https://blogs.vmware.com/PowerCLI/2014/03/using-vsphere-tags-powercli.html) and in vSphere 6.0, we now also have APIs which are part of the vCloud Suite SDK (https://developercenter.vmware.com/sdks) that allow you to interact with them.

      Reply

Trackbacks

  1. Quick Tip – How to quickly find the VM Display Name of your vCenter Server? | virtuallyGhetto says:
    07/07/2016 at 9:02 am

    […] vCenter Server detects that it is in a self-managed configuration, it will automatically add a "System" metadata tag (not to be confused with vSphere Tags) to the actual vCenter Server VM. For vCenter Server, the […]

    Reply
  2. Developing your first VCenter plugin – Bluemeric says:
    02/06/2017 at 2:14 am

    […] to a VI object across client sessions. Method to update this property is hidden as of now. This link gives a way to add/update/delete this hidden […]

    Reply
  3. vSphere Tagging feature - identify uplink port in dSwitch - asvignesh says:
    07/12/2019 at 2:04 am

    […] William Lam published a great post on changing tags with […]

    Reply

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025