On Wed, 14 Dec 2011, Ted Zlatanov wrote:
...
> I try to stay away from inverting classes. Rather, I'll define
> something global and then override it for each class that needs it
> different. But I've done inversion too, when it's very clear:
>
> bundle common g
> {
> classes:
> "file_exists" expression => fileexists("myfile");
>
> vars:
> file_exists::
> "root" string => "myroot1", policy => "overridable";
> !file_exists::
> "root" string => "myroot2", policy => "overridable";
> }
>
> In your example, if something defines the "location_unknown" class
> previously, suddenly the location_unknown definition will flip. So I
> would avoid it for that reason alone--it's not self-convergent.
...
Hi Ted,
OK, that is quite a disadvantage - but presumably could be overcome by
writing a custom body instead of using classmatch?
How would you cleanly do an if..elif..else ? The example you give appears
to be an if..else.
What I'm trying to avoid is the situation, like in the example below,
where the "no_file_exists" class expression has to be rewritten everytime
I need to test for another file:
bundle common g {
classes:
"my_file_exists" expression => fileexists("myfile");
"your_file_exists" expression => fileexists("yourfile");
"no_file_exists" expression => !(my_file_exists|your_file_exists);
vars:
my_file_exists::
"root" string => "myroot1", policy => "overridable";
your_file_exists::
"root" string => "myroot2", policy => "overridable";
no_file_exists::
"root" string => "myroot3", policy => "overridable";
}
Best wishes,
Mark
--
-----------------------------------------------------------------
Mark Dixon Email : [email protected]
HPC/Grid Systems Support Tel (int): 35429
Information Systems Services Tel (ext): +44(0)113 343 5429
University of Leeds, LS2 9JT, UK
-----------------------------------------------------------------
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine