Dynamic Groups#
In addition to attribute groups, the ICE ClusterWare ™ platform also supports admin-defined dynamic groups. Dynamic groups provide a quick way to select sets of similar nodes, similar to applying filters to search results. Dynamic groups use a node selector query language that allows for simple compound expressions. You can use dynamic groups to group nodes based on shared or common attributes, status, or hardware information.
Use the node selector to find a group of nodes and then create a dynamic group to save the selector for future use. For example:
Run the following command to return all nodes using the
DefaultBootboot configuration with an index value greater than 10:cw-nodectl -s 'n[index] > 10 and a[_boot_config]=="DefaultBoot"'
After verifying the list of nodes returned by the selector, create a dynamic group for that selector for future use:
cw-clusterctl dyngroups create name=DefaultBootNodes selector='n[index] > 10 and a[_boot_config]=="DefaultBoot"'
Example: Attribute Groups and Dynamic Groups#
Dynamic groups can be used in combination with attribute groups to simplify taking actions on a group of nodes. For example, you may want to take an action on all nodes in a particular data center or on a specific rack. To do this, you need to set attributes on each node, query for all nodes with a specific attribute, and run the action on the selected group of nodes. You can save that selection of nodes as a dynamic group to simplify future actions. The example steps give instructions for the ClusterWare command line, but you can also use the ClusterWare GUI to configure the nodes, attribute groups, and dynamic groups.
Define attribute groups "dc1" and "dc2":
cw-attribctl create name=dc1 description='Data center located in rear of building 1' cw-attribctl create name=dc2 description='Data center in building 2'
Add nodes to appropriate groups:
cw-nodectl -i n[0-31] join dc1 cw-nodectl -i n[32-63] join dc2
Identify the rack number in an attribute on each node:
cw-nodectl -i n[0-15] set rack=1 cw-nodectl -i n[16-31] set rack=2 cw-nodectl -i n[32-47] set rack=1 cw-nodectl -i n[48-63] set rack=2
Note
All attribute values are saved as strings, not integers. As a result, subsequent selector expressions must enclose these values in double-quotes.
Query a list of nodes in a particular rack of a particular building using a
--selector(or-s) expression, and perform an action on the results of that selection:cw-nodectl -s 'in dc1 and attributes[rack] == "2"' status # or use 'a' as the abbreviation of 'attributes' cw-nodectl -s 'in dc1 and a[rack] == "2"' set _boot_config=TestBoot # Show the nodes that have 32 CPUs. # These hardware _cpu_count values are integers, not strings, and are # not enclosed in double-quotes. cw-nodectl -s 'hardware[cpu_count] == 32' ls # or use 'h' as the abbreviation of 'hardware' cw-nodectl -s 'h[cpu_count] == 32' ls # Show the nodes that do not have 32 CPUs cw-nodectl -s 'h[cpu_count] != 32' ls
Create a dynamic group of a specific selector for later use:
cw-clusterctl dyngroups create name=b1_rack1 selector='in dc1 and a[rack] == "1"' cw-clusterctl dyngroups create name=b1_rack2 selector='in dc1 and a[rack] == "2"' # Show the nodes in building 1, rack 2 cw-nodectl -i %b1_rack2 ls # Show only those %b1_rack2 nodes with 32 CPUs cw-nodectl -i %b1_rack2 -s 'h[cpu_count] == 32' ls
List the dynamic groups using
cw-clusterctl:# Show the list of dynamic groups [admin1@headnode1 ~]$ cw-clusterctl dyngroups ls Dynamic Groups b1_rack1 b1_rack2
Show details of one or more dynamic group.
# Show the selector associated with a specific dynamic group [admin1@headnode1 ~]$ cw-clusterctl dyngroups -i b1_rack1 ls -l Dynamic Groups b1_rack1 name: b1_rack1 selector: in dc1 and a[rack] == "1" # Or show the selector associated with a specific dynamic group in full detail [admin1@headnode1 ~]$ cw-clusterctl dyngroups -i b1_rack1 ls -L Dynamic Groups b1_rack1 name: b1_rack1 parsed: ((in "dc1") and (attributes["rack"] == "1")) selector: in dc1 and a[rack] == "1"Tip
The parsed line in the above output can be useful when debugging queries to confirm how ClusterWare parsed the provided query text.