Question about scheduler requirement expression syntax

Ideally I would like to be able to apply an attribute to hosts that contains an array of strings or integers, and use that to indicate that a particular host is suitable for hosting certain classes of VMs, something like ROLES=“ABC, ABCD, DEF”.

The 5.6 documentation on VM templates requirement expression syntax mentions that the ‘@>’ operator should evaluate against arrays, but I am having trouble getting any any attribute that I enter into a host template to be treated as an array.

I am using the following expression in the VM scheduling requirements:

And have attempted multiple different ways to define an array attribute on the host.
The following throw a syntax parsing error when I try to update a host template via onehost update <ID>:

The following I think are just recognized as strings and not arrays:

The scheduler log shows the following output:

Host 30 discarded for VM 242. It does not fulfill SCHED_REQUIREMENTS: (CLUSTER_ID = 0 | CLUSTER_ID = 101) & !(PUBLIC_CLOUD = YES) & ( ROLES @> ABC )
Mon Mar 11 18:07:06 2019 [Z0][SCHED][D]: Match-making results for VM 242:
Cannot schedule VM, there is no suitable host.

I have had some limited success with using wildcard matching, but this falls down when one of the values is comprised of another value, for example SCHED_REQUIREMENTS="ROLES = \"*ABC*\"" will match hosts that have the “ABC” role as well as the “ABCD” role.

It also seems like in the template documentation there is no clear pattern as to what parts of the expression require escaped-nested quotes or not.

Is it even possible to create an attribute with an array value that is successfully evaluated by @>, or alternatively, just generally evaluate a VM placement expression against a host attribute containing multiple values?

So to address some of your questions

  1. Escaping: Strings are define in double quotes, if you need to define a string within that’s need to be escaped; e.g. SCHED_REQUIREMENTS="ROLES = \"*ABC*\""
  2. Strings are matched with fnmatch(3), so any pattern there will be valid. I’d say that the *role_name* is a reasonable approach.
  3. @> Are used when there are more than one attribute with the same name in the element (host, datastore, network), e.g. <CLUSTERS><ID>1</ID><ID>34></ID>.... there you can use CLUSTER/ID @> 2 so 2 is included in the ID “list”


Thank you for the response @ruben!

OK so in continuing to try to use an attribute with multiple values, and knowing that strings are matched using fnmatch I tried make the globbing less greedy by including whitespace in the expression.

On the cluster/node:

On the VM:
`SCHED_REQUIREMENTS=“ROLES = “[[:space:]]ABC[[:space:]]””

Unfortunately this did not work as the scheduler could not find a suitable host. So my next attempt was to try using @> again, this time creating a vector attribute similar to your 134>` example like this:

On the cluster/host:

On the VM:

But for some reason the host template overwrote the subsequent ROLE values so the host template has only one entry, like this:

Am I missing something in trying to create a vector attribute with multiple elements of the same name?