Managing Categories for EUC workloads in Prism Central

Nutanix.dev-ManagingCategoriesforEUCworkloadsinPri

Table of Contents

Categories in Nutanix Prism Central are used to group entities together based on a key value pairing. They are a similar concept to Tags. Categories are used to control many different aspects of an environment. Some common uses are outlined below: 

Many Citrix environments will use Citrix Provisioning Services or Citrix Machine Creation Services to quickly deploy thousands of virtual machines. These environments may require Categories to be applied to these virtual machines post provisioning.

Nutanix provides a way to automate the management of tags via the Prism v3 API for Prism Central, so naturally, we can automate the process at scale with PowerShell  

The Script Purpose and Logic 

To help automate the assignment or removal of Categories to virtual machines, we have written a PowerShell script example. The script operates with the following logic:

  • Connects to the specified Prism Central (PC) instances via Nutanix Prism Central v3 APIs. 
  • Validates the provided Category Key:Value pair exists within Prism Central. 
  • Queries the API for a list of machines matching either the included name list, or a name pattern match using wildcard logic. 
  • Loops through each virtual machine and either assigns or removes the Category depending on the script mode (add or remove). 

Operational Model 

The envisaged model of operation is as follows:

  • A Category is created in Nutanix Prism Central, for example Citrix_Provisioning_Type:MCS or Citrix_Provisioning_Type:PVS.
  • A Citrix Administrator creates a machine Catalog via either Citrix Machine Creation Services or Citrix Provisioning Services.
  • The script is executed with a mode of “Add” to apply the tag to all machines matching the name MCS* with a Category Name of Citrix_Provisioning_Type and a Value of MCS.
  • The Nutanix administrator applies the appropriate services to the now Categorized virtual machines, for example, Flow Micro Segmentation policies.

The administrator repeats the process as required for any additions or removals of Categories. 

The script is not limited to any form of Citrix use, it will work for any virtual machine within Prism Central, however, Citrix workloads offer a great example of where this script will help. 

In a scenario where a Citrix environment contains a range of Catalogs, Delivery Groups and Tags within Studio, an administrator could easily use the Citrix PowerShell capability to query machine objects, and then pass them as an array (IncludeList) to the UpdatePCVMVategopries.ps1 script to either apply or remove Nutanix Categories. 

Nutanix Automation Components Used

The script used the following API components as an example of what can be achieved via v3 APIs:

  • api/nutanix/v3/categories/{name}/{value}: To validate the existence of the specified Category Key:Value pair
  • api/nutanix/v3/vms/list: To retrieve a list of virtual machines
  • api/nutanix/v3/vms/{uuid}: To get and set the category against the appropriate virtual machine

Summary and Technical Requirements 

To successfully execute the script, the following requirements must be met:

  • An appropriate credential for the Prism Central tasks. We recommend a service account is used. For our testing of all components in the script, we used a Super Admin level account.
  • PowerShell 5.1 onwards can be used, including PowerShell 7.

You can find the script below on our GitHub Repository:

© 2024 Nutanix, Inc. All rights reserved. Nutanix, the Nutanix logo and all Nutanix product, feature and service names mentioned herein are registered trademarks or trademarks of Nutanix, Inc. in the United States and other countries. Other brand names mentioned herein are for identification purposes only and may be the trademarks of their respective holder(s). This post may contain links to external websites that are not part of Nutanix.com. Nutanix does not control these sites and disclaims all responsibility for the content or accuracy of any external site. Our decision to link to an external site should not be considered an endorsement of any content on such a site. Certain information contained in this post may relate to or be based on studies, publications, surveys and other data obtained from third-party sources and our own internal estimates and research. While we believe these third-party studies, publications, surveys and other data are reliable as of the date of this post, they have not independently verified, and we make no representation as to the adequacy, fairness, accuracy, or completeness of any information obtained from third-party sources.