This example describes how to group VMs by department using nested methods.
Consider the following case: all names of VMs in the virtual infrastructure include a special suffix that indicates the department to which the VM belongs. According to this naming convention, the VM name has the following format: vmname_departmentname.
To automatically group VMs by department:
- Create a category with the following properties:
- Friendly name: Department
- Group type: Dynamic
- Object type: VM
For details on creating categories, see Creating Categories.
- Choose to create dynamic groups within the new category and specify the following grouping expression:
Replace(Replace(Name, Left(Name, IndexOf(Name, "_")), ""),"_","")
The expression returns a suffix after the underscore character in the VM name, and includes a VM to a group with this suffix.
For details on creating dynamic groups, see Creating Dynamic Groups.
As a result, the Department category will display several groups named after the departments that can be found in the VM names.