Thursday, February 21, 2013

vC Ops 5.6 Custom Groups - Using Wildcards

A question popped up in the vCenter Operations Manager community about using wildcards for custom group membership search criteria.  It seems that * is not a valid wildcard.  So, I guessed that since the query is performed against the PostgreSQL database in vC Ops then it's likely that PG wildcards could be used - I guessed correctly!  And that rarely happens....

This means, if you are defining membership using a search criteria on resource name, for example, you can select the "contains" operation and use the % and _ (that's percent sign and underscore characters) to broaden your criteria.

For example, I have the following VMs in my environment:

BM-SLES11.1-001
BM-W2K3-001
BM-W2K3-002
BM-W2K3-107

If I wanted only the VMs with 'BM-W2K3' in the name I would put 'BM-W2K3%' in the criteria properties.  See below.


Keep in mind, I don't have to put any wildcard characters.  It looks like the % wildcard is added on either side of the property if you don't put it.  So, doing something like just 'k' would return resources with 'k' anywhere in the name.  Like this...

 
Which would be the same as '%k%' right?  So, what else can we do?  The '_' character can be used to specify a wildcard of just one character, and I can stack these to get the results I need.  For example, I want all servers which start with 'BM-' and have exactly 8 characters in the middle followed by a '-' and then any number of additional characters (I am using 'BM-________-%' which has 8 underscore characters in the middle)...


This provides a lot of flexibility in setting up search criteria for custom group membership!