Closed
Description
Somewhat of weird request, but I have a need to have empty group. I've been just using None
to keep the library from getting a traceback, but we populate a group yaml file with something like:
x1000:
c0: nid[0001-32]
c0r3: nid[0001-16]
c0r7: nid[0017-32]
c1: None
...
This is more for cluset
type operations rather than clush
operations specifically, but it's nice to provide some mechanism for empty set, but I don't know if there is a best mechanism for this or not. Leaving it empty gives a traceback. NULL
also can't be used. I've thought maybe False
, but still not great. So just looking how to mark an empty set as part of the configuration file. I'll continue scanning the docs, but I've not found anything (yet).
Activity
thiell commentedon Sep 18, 2023
Hi @jbaksta – thanks for your report. I assume you're talking about the group definition in
/etc/clustershell/groups.d/cluster.yaml
? I just tried to define an empty group c1 like this:And it seems to work as it is empty but listed by cluset.
However, if I use just
c1:
, I see a traceback indeed, so we should fix this. The yaml file definition must be valid so I don't think you can just specifyc1:
without the quotes to define an empty node set, but I will double check.jbaksta commentedon Sep 19, 2023
Thanks. Yeah, correct. I was just curious if maybe showing an empty set would be a good part of the docs as well. It wasn't an issue until I had collection of empty chassis or empty slots in our chassis, but I can see how an empty string would work, just didn't really cross my mind. I'll try this because I also want to see what happens when I do a
clush
on an empty set. I would like to see common ways to represent empty sets though just for YAML consistency:null
,NULL
,~
, and possibly Python'sNone
but that maybe limited by the underlying lib. Not sure. I would say a clearer message on the traceback rather thansplitlines
would be appreciated. Emitting a warning or error on yaml file parsing failure would be most excellent.thiell commentedon Sep 19, 2023
Sounds good. The underlying
NodeSet
classes does support either an empty string orNone
to instantiate an empty set, but for whatever reason there is an issue here if the field is "null" in the yaml file. We will try to fix that so we can support an empty yaml field, so usingnull
or~
would work to define an empty node set in there.With the CLI tools, like
cluset
, the empty string can be used to define an empty set:Union:
Intersection:
Difference:
The quotes are interpreted by the shell and the empty string is passed as command argument, which is supported to define an empty node set in that case.
What we don't have at this time is a representation of a generic empty node set to be used with in-line arithmetic operators like:
NodeUtils: allow null values in cluster.yaml (cea-hpc#533)
NodeUtils: allow null values in cluster.yaml (#533)