VMware has been clear about it, you should switch to the vSphere Web Client and stop using the good old Windows vSphere Client. Being best kid in the class, I of course tell my customers to start using the vSphere Web Client when possible and I work with it myself most of the time. During an upgrade to vSphere 5.5 the customer’s admin suddenly asked me where he could find the attributes in the vSphere Web Client. To my surprise, the vCenter Server attribute fields are not available in the vSphere Web Client. I did know that VMware now offers tags and categories for a lot of objects in vCenter and we should use these in favour of vCenter Attributes, but I wasn’t aware that the vSphere Web Client no longer shows the attribute fields. Vice versa, the tags and categories only work in the vSphere Web Client and not in the Windows vSphere Client.
What exactly are tags and categories?
According to the information in the vSphere Web Client: “Tags are a new feature of this vSphere release. Their purpose is to allow you to add metadata to objects. Tags allow you to bring information about your virtual infrastructure form outside vSphere and attach it to objects inside so that actions and decisions can be taken on the basis of that information. In order to avoid conflicts between the many possible uses of tags, tags are organized into categories.”. When looking at tags and categories you can best see them like this:
- vCenter attribute “name” is now called a category and you can set a category to be tagged only once or multiple times per object. For example the “Datacenter”.
- The value of an attribute is what is now called the name, for example “Open Line”.
How to use tags and categories
Tags can be assigned to the following objects:
- Cluster
- Datacenter
- Datastore
- Datastore Cluster
- Distributed Port Group
- Distributed Switch
- Folder
- Host
- Network
- Resource Pool
- vApp
- vCO Scheduled Workflow
- vCO Workflow
- Virtual Machine
To give you a few examples of how to use tags and categories I created a schema that I could use in the Open Line datacenter in which we host VMs for multiple customers. What does this vSphere environment look like? For most customers we host VMs in a shared environment but some have their own dedicated ESXi hosts (and cluster). We offer different types of backups for VMs: file level and vmdk level. We offer different types of management, some customers only buy a VM and they take care of their own guest, but for a big part we also manage the guest at the OS level and therefore we want to know what is running inside the VM. This by far is not a complete list but I think it is enough to help you understand how to work tags and categories.
Virtual Machine level
For each VM I would like to know the following details:
- Datacenter. This can only be one datacenter at the same time.
- Customer. This can only be one customer name at the same time.
- Backup Method. Several values can be needed here, since a VM can be backed up through VMDK level and also have SQL Agent backup.
- Guest Management. This can only be one, either Open Line manages the Guest OS or the customer manages the Guest OS.
- Services. Multiple values can be used here per VM. These services are for example: Exchange, SQL, DNS, DHCP, Domain Controller, Citrix Provisioning Server, Citrix XenApp Server, FTPserver, WebServer, etc.
- DR. This can also only be one value per VM, either the customer has a DR contract or not.
- VM Quality. This can only be one value per VM, either Gold, Silver, Bronze, etc.
- Storage Quality. A VM could potentially have more types of storage quality since this can be per VDMK.
In the above, where I write about “can only be one”, what I mean is that a VM can for example not be in two datacenters at the same time. But there will be multiple tags for this category. In the datacenter example, there would be a tag “DC-1” and “DC-2” but only one tag can be attached to the VM.
Creating categories and tags
First we need to create the categories. Let’s start with the datacenter. Open the vSphere Web Client, go to HOME and click “Tags” on the left hand side, followed by clicking the “items” tab and “Categories”. Now click “New Category” and enter the following:
- Category Name: Datacenter
- Description: Datacenter for this object
- Cardinality: One tag per object
- Associable Object types: All objects.
Now switch to the “Tags” section and create a the following new tags:
- Name: DC-1
- Description: Datacenter Number One
- Category: Datacenter
- Name: DC-2
- Description: Datacenter Number Two
- Category: Datacenter
Now navigate to a VM, click the summary tab and see the section called “Tags” and click “Assign….” in the lower right corner of the “Tags” section. Choose the Datacenter “DC-1” tag and you’re done. The same can be done for hosts, datastores, networks, etc. if the Category can be used on those objects that is. It is also very easy to quickly add a tag to multiple objects. For example go to the cluster, select the tab “Related Objects”, click the section “Hosts” and select all hosts, right click and choose “Assign Tag…”.
Reporting on tags
Using tags should make it very easy to quickly find objects that match a given tag, but the search / reporting function isn’t that functional yet. It seems that the “old” search function is moved to the vSphere Web Client without adding functionality for the tags and categories. It is possible to search “for” a tag but not “on” a tag.
For example I want a list of Virtual Machines in DC-1. On the home screen go to the “New Search” section on the left hand side and create a search in the middle pane. Click “Advanced Search” to search for a “Virtual Machine” that satisfies “any” of the following criteria. Strange thing is that in the properties I cannot select a Tag.
The closest thing to getting a list of Virtual Machines from DC-1 is to search for: “Tag Name” contains “DC-1” and click Search. What happens now is that you get a list of all tags that have “DC-1” in the tag name. You can now click that tag “DC-1” and get the list of related objects. But you will get all objects with that tag and then in the bottom right, you can choose to export as CSV. In this CSV you then have to filter out all non-VM objects, which is not very convenient.
Work around
There is a work around that is actually too stupid, but what you can do is created an object tag for each object. If you assign the tag “Virtual Machine” to each virtual machine, you can use that in an advanced search. To do this, create a new category named “Search-Objects” (or anything you prefer) and make it “one tag per object”.
Now create a new tag named “VirtualMachine” and connect it to the “Search-Objects” categorie. Now go to “New Search” select “Advanced Search” and create the following search:
“Virtual Machine” that satisfies “any” of the following criteria: “Virtual Machine Host Name” contains “*”.
You have to enter something in the criteria line, so I just picked “Virtual Machine host name” but it could have been anything. Now click search and you will get a list of all Virtual Machines in this vCenter Server. Select them all, right click and assign them the tag “VirtualMachine”. You have to select VMs and Templates separately or you can’t assign a tag. Now create a new search:
- “Everything” that satisfies “all” of the following criteria:
- “Everything tag name” – “contains” – “dc-1”
- “Everyhting tag name” – “contains” – “VirtualMachine”
And there you have it, a list of all VMs in datacenter one.
vCenter Attributes migration wizard
Luckily VMware has offered a migration wizard that will convert the vCenter attributes into tags and categories. Let’s walk through it using the following example. I have two vCenter custom attributes named “Customer” and “Datacenter”. Using the old Windows vSphere Client, you can see them and their values.
In the vSphere Web Client go to Home, then “Tags” on the left hand side and use the “Getting started” tab. In the middle pane you can now choose “Convert Custom Attributes”. A wizard pops up and in step 2 I get a list of all attributes I can convert. Here I select all the “customer” and “datacenter” entries.
Click next and now see the categories that the wizard suggests. By clicking on a category you can edit the category. After you’re satisfied with the entries, you can click next and see what the tags will be that will be created. Here you can also edit the description.
Click Next and Finish to complete the wizard. Now check if the VM indeed has these new tags. The wizard does not remove the vCenter attributes.
PowerShell commands
Since VMware PowerCLI version 5.5R1 and up there are a number of commands available to work with tags:
- Get-Tag
- New-TagAssignment
- Remove-TagAssignment
And the –Tag property has been added to many existing commands, for example:
Get-VM -Tag “DC-2” will list all VMs with a tag “DC-2”.
Conclusion
Working with tags does take some getting used to, but in the end they will give you more freedom and ease of use but I do hope reporting will improve a little in the next version.
Tags are still a pain in my opinion. I can partially manage them in powershell but I still can not create them. so I am still not able to convert my automation scripts that populate my custom attributes CreatedBy, CreatedOn, Support Team, etc.
Upgrade power shell to 5.5 SP2 which has even more support for tags.
What about esxcli commands to create tags or using the MOB? We apply custom attributes during our kickstart build process and can’t find a way to configure tags instead of attributes during the build process.
Is there a way to create categories and tags that span across vCenters in a linked mode configuration? I am running into some trouble implementing tags into my environment because we have many machines that we would like to use the same tags and categories for, but can only create tags and categories independently for each vCenter server.
Jumping on an old post, but hopefully someone runs across this. Thanks.
I would suggest using PowerShell for this. The latest update has even more PowerShell tag cmdlets. I would also advice you to slowly move away from linked mode. It “feels” as if VMware wants to move away from it too.
Any particular resources you could recommend?
I have been working in PowerCLI 5.8 which allows the creation of categories and tags, but only once I am connected to a specific vCenter server. It will only create the category for that server, the same result as if I were to create it via the GUI. What I am looking for is a vSphere environment-wide tagging capability so that I can apply the same tags to VMs in separate vCenters.
Thank you for your reply by the way! I have been searching for a solution to this all day and have come up short, there seems to be no discussion on this particular issue I am having.
You could try to connect to two vCenters. But what I usually do is create CSV files and import the contents and run it against multiple vCenters.
I think your solution is in vSphere 6.0, as they move more of this information into the inventory controllers you should be able to achieve this. I’d try it in the beta!
“Everything” that satisfies “all” of the following criteria:
“Everything tag name” – “contains” – “dc-1”
“Everyhting tag name” – “contains” – “VirtualMachine”
Is it possible to do the same in Powercli?
Get-VM -Tag “dc-1”, “VirtualMachine”
gives both not matching multiple criterias
I currently don’t have a lab environment at hand to test this. But can’t you do something with the “where-object” ? Or pipe two commands like Get-vm -Tag “dc1-” | Get-vm -Tag “VirtualMachine” ?
Thank you for thinking along! Got it like this:
# First we want to define the new “Tag” property of the VirtualMachine object:
New-VIProperty -Name Tag -ObjectType VirtualMachine -Value {
Get-TagAssignment -Entity $args[0] | select -ExpandProperty Tag }
# Now retrieve all VMs and their tags:
Get-VM | select Name, Tag | ft -a
Or in my case:
Get-VM | select-object Name, Tag | where {$_.Tag -match “Priority-1” -and $_.Tag -match “Service-1”}
Is there now a way (plugin) to manage tags and categories with vCO/vRO not using powershell?
I haven’t used vCO before, so I can’t really tell.