Today we will explain how to use the VMware feature TAGs in the VMs and create Veeam Backup Jobs using TAGs. Since this article is too long, I will create the second article for this Veeam tasks.

In this article we will focus how to create and use TAGs (and category TAGs), in a second article will explain how to use the same TAGs in Veeam and create Veeam Backup Jobs using TAGs.

What are VM TAGs?

TAGs in VMware exists since version 5.1 but is a feature not very advertise (in my opinion), and only some VMware customers used it.

Tags are the ability to create custom labels and or metadata and apply to any object with the vCenter inventory.  TAGs purpose is to identify object by adding metadata to object.

TAGs are used for a better management of our Virtual Infrastructure. With TAGs, we can group VMs (as an example) by category(like Guest OS, Clusters, multiple vCenter. We can Backup VMs by Guest OS and quickly identify the Guest OS in the VMs with a script.

We can also use the Search in vSphere Web Client to find objects by TAGs.

We can also use to identify a VM by an application(like DNS, SQL, Exchange or another type of Application). For environments with thousand of VMs, TAGing is a very easy way to manage and organize our VMs(or other objects).

If you are managing a Hosting a Datacenter for several customers, TAGing VMs or Clusters by Costumers will also be easy to manage your Virtual Environment.

We can manage, search, or group VMs using TAGing regardless where they are located (like folder, Pool, host or even vCenter when using multiple vCenters)

VMware Notes:With vSphere 6.0, vSphere tags are no longer stored in the Inventory Service database table as the source of truth. They are relocated to the vCenter Server’s database (VCDB) table CIS_KV_Keystore and the VMware Directory Services (Lotus) Service Provider tagging. After the tag association is created, this information is then pulled into the Inventory Service database for display within the vSphere Web Client.”

Some extra information about TAGs: KB:2130130

TAGs are set by Category and then by TAG with a Category.

We can TAG at the following object level:

  • Cluster
  • Datacenter
  • Datastore
  • Datastore Cluster
  • Distributed Port Group
  • Distributed Switch
  • Folder
  • Host
  • Network
  • Resource Pool
  • vApp
  • vCO Scheduled Workflow
  • vCO Workflow
  • Virtual Machine

What will we use in our article?

In our case, we only TAG VMs and create a Category for the Guest System Operation (OS).

There will be a TAG Category call ‘Guest OS’

Name               Cardinality        Description
—-                     ———–               ———–
Guest OS        Single                   VMs System Operation TAG

Inside of this Category we will have the type of TAGs OS.
These are the type of TAGs that VMs will have depending of the Guest System Operation

Name                Category             Description
—-                      ——–                   ———–
Linux                Guest OS             Linux Virtual Machine
Windows          Guest OS             Windows Virtual Machine
Other OS          Guest OS             Other OS Virtual Machine

Note: TAGs can only be added, or checked using vSphere Web Client. vSphere Client Tool will not provide TAGs information.

How to create TAGs?

TAGs can only be created using vSphere Web Client. In this article we will focus how to create TAGs using PowerCli scripts and also in the vSphere Web Client tasks.

Note: In this example we will only use TAGing for VMs. Like we stated above, we can TAG most of the objects in the vCenter.

How to create TAGS using vSphere Web Client

Create TAG Category:

TAGCategory

As we can see in the image above, when connecting to vSphere Web Client in the left menu we have the TAG option.

Then we choose TAG Category (you cannot create a TAG without first create a TAG Category).

Options:

Category Name: The category name must be unique to the currently-selected vCenter Server system.
Description: You can provide text in the description to describe the purpose or usage of the category.
Cardinality:

>Select 1 tag per object to allow only one tag from this category to be applied to an object at any one time.

Use this option for categories whose tags are mutually exclusive. For example, a category called Priority with tags High, Medium, and Low should allow one tag per object, because an object should have only one priority.

>Select Many tags per object to allow multiple tags from the category to be applied to an object at any one time.

Use this option for categories whose tags are not mutually exclusive.

After you have set the cardinality of a category, you can change the cardinality from 1 tag per object to Many tags per object, but not from Many tags per object to 1 tag per object.

Associable Object Types:

Select whether tags in this category can be assigned to all objects or only to a specific type of managed object, such as virtual machines or datastores.

After you have set the associable object types for a category, you can change a category that is associable with a single object type to be associable with all object types, but you cannot restrict a category that is associable to all object types to being associable to a single object type.

Note: In our example, we have associated the TAG Category to Virtual Machines

After create the TAG Category we then can create TAGs linked to the TAG Category created above.

Create TAGs:

TAGs

Options:

TAG Name: Choose the name for your TAG. TAG name need to be unique inside of the same TAG Category.
TAG Category: Choose a TAG Category (created in the previous task) from the TAG Category list.
Description: You can provide text in the description to describe the purpose or usage of this TAGs.

Assign/Add TAG in VMs:

TAGs00

In the vSphere Client just go to the Virtual Machines section and click in the VM that you want to add the TAG.

As we can see above, in the VM summary will show a TAG area. Then just click Assign (1)

If we just click Mouse right click in the list of our VMs, we have also the VM menu and there is the option to assign a TAG to the VM.

Screen Shot 06-10-16 at 12.34 AM

 

 

 

 

 

 

 

 

Directly in the VM Summary, or VM menu options, will open the next Window to choose the VM TAG to assign.

TAGs02

 

 

 

 

 

 

 

Then we just need to choose one of the VMs TAGs that exists. In this case is a Windows VM, so we will choose the Windows TAG and click Assign.

TAGs01

After we can see the TAG already been assigned to this VM.

After all these tasks we have created TAG Category, TAGs and assign TAGs to our VMs using vSphere Web Client.

How to create TAGS using PowerCli scripts?

In the next section we will create the same TAG Category, same TAGs and also assign TAGs to all our VMs by checking automatically the type of Guest OS that VM is running.

Note: Since not all VMs can have VMware tools installed, checking Guest OS without VMware Tool cannot be 100% accurate. In that case we will check the Guest OS that user choose when created the VM.

Lets explain a little bit our script and how to use PowerCli commands to create TAGs.

Create TAG Category:

This line creates the ‘Guest OS’ Category adding the description and choosing Cardinality single (since we will only use for VMs).

The script will always check if there is already a TAG ‘Guest OS’, if yes will skip this section. We are using this for our example, but you can change the script and put whatever TAG Category you need in your environment.

Create TAGs:

This line creates the TAGs using the TAG Category created in the previous section.
Previously he have already set the TAGs names that we need for our environment

Again the script will always check if there is already this TAGs already exists, if yes will skip this section. Again this is just for our example, you can change the script and put whatever TAG you need in your environment. Just change the $TAGNames array for whatever you need in your environment.

Assign/Add TAG in VMs:

Then the script will check all VMs in the vCenter to see if the VMs Guest OS, after knowing the Guest OS will check if there is a TAG assigned already to the right OS, if not will assign a Guest OS TAG to the VM according to Guest OS used.

Note: We use also the option by Cluster that you can use, or comment to run in all Clusters in the vCenter.

The script will create a HTML report of all changes made (new TAG Category created, new TAGs created and all VMs that were assign to right TAG). Will also send by email (you need to change the script in the email settings, according to you email server)

This is the full script:

With the script we finish this first part of this TAGs article in VMware and Veeam Backup.

In our second part we will focus using the same VMs TAGs in Veeam and create Backup Jobs by VM TAG.

Final Note: I will like to thank to my colleague Vladimir Sokol for is great help improving the script. Thank you for all your support on this.

Important Note: This script and article is provided as-is, no warranty is provided or implied. The author is NOT responsible for any damages or data loss that may occur through the use these tasks or scripts included here in this article.

Second article: How to create and use VMs TAGs in Veeam Backup Jobs

Note: Share this article, if you think it is worth sharing.

©2017 ProVirtualzone. All Rights Reserved