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:
- Datastore Cluster
- Distributed Port Group
- Distributed Switch
- Resource Pool
- 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.
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.
Since VMware PowerCLI version 5.5R1 and up there are a number of commands available to work with tags:
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”.
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.