Ok for my sake I did the following test: body common control { bundlesequence => { "ba", "bb", "bc" }; }
bundle agent ba { classes: "class_ba" expression => "$(sys.uqhost)"; files: "/tmp/dummy", create => true, classes => if_ok("dummy_ba"); reports: class_ba:: "Class ba is define in bundle ba"; dummy_ba:: "Class dummy_ba is define in bundle ba"; } bundle agent bb { classes: "class_bb" expression => "$(sys.uqhost)"; reports: class_ba:: "Class ba is define in bundle bb"; class_bb:: "Class bb is define in bundle bb"; dummy_ba:: "Class dummy_ba is define in bundle bb"; } bundle agent bc { classes: "class_use_bd" expression => "$(sys.uqhost)"; methods: "bd" usebundle => bd; reports: class_ba:: "Class ba is define in bundle bc"; class_bb:: "Class bb is define in bundle bc"; dummy_ba:: "Class dummy_ba is define in bundle bc"; } bundle agent bd { reports: class_ba:: "Class ba is define in bundle bd"; class_bb:: "Class bb is define in bundle bd"; class_use_bd:: "Class use_bd is define in bundle bd"; dummy_ba:: "Class dummy_ba is define in bundle bd"; } body classes if_ok(name) { promise_repaired => { "$(name)" }; promise_kept => { "$(name)" }; } And the output was (on community edition 3.0.4p2) R: Class ba is define in bundle ba R: Class dummy_ba is define in bundle ba R: Class bb is define in bundle bb R: Class dummy_ba is define in bundle bb R: Class dummy_ba is define in bundle bd R: Class dummy_ba is define in bundle bc So my take away from that single test is that classes that are define with the classes type are local to the bundle but classes define with the classes statement within a promise are global. When you think of it it makes perfect sense, that is if a promise does something within a bundle you want to have the ability to signal other promises in the current bundle or other bundles that a promise has change the state of our system. Hence making such classes global. As for classes defined with the classes type again it makes perfect sense for it to be local within that bundle. Now my last comment is that I would of thought that a local class would be visible by a bundle called with the usebundle promise, oh well simply a matter of interpretation/vision. Thanks to all that forced me into clarifying this for myself. Marco -----Original Message----- From: Jesse Becker [mailto:becker...@mail.nih.gov] Sent: Wednesday, April 21, 2010 10:48 PM To: Lebel, Marco Cc: Justin Lloyd; fo...@cfengine.com; help-cfengine@cfengine.org Subject: Re: Cfengine Help: Re: RE: Cfengine Help: cfengine program flow On Wed, Apr 21, 2010 at 05:42:14PM -0400, Lebel, Marco wrote: >Justin, > >You are bringing an interesting point since I struggle with classes in this >context. But I have not done any structured testing but I am under the >impression that once a class has been set it never gets unset. Actually, my last email on this may not have been correct. In a classes body, it is possible to define cancel_{kept,repaired,notkept), all of which take an slist of classes "to be cancelled" if a promise is kept/repaired/not kept. So perhaps they can be deasserted... hmm... I'll have to go re-ponder a few things. (amazing what you can learn if you read the docs...) > >Again I want to stress that I never did any exhaustive testing on this but I >believe that classes once set they are set globally (i.e. visible in all >subsequent bundle) and never get unset even if the condition that initially >created it is no longer true... Again the key word is an impression that needs >to be confirmed by someone in the know or has done the necessary testing. > >Marco > >-----Original Message----- >From: help-cfengine-boun...@cfengine.org >[mailto:help-cfengine-boun...@cfengine.org] On Behalf Of Justin Lloyd >Sent: Wednesday, April 21, 2010 5:31 PM >To: fo...@cfengine.com; help-cfengine@cfengine.org >Subject: RE: Cfengine Help: Re: RE: Cfengine Help: cfengine program flow > >As I understand it, it will reevalute the class promise, and therefore >check for the file's existence, on all three iterations. A good way to >see what is happening is to run cf-agent in verbose mode (cf-agent -vK) >and write its output to a file then read through it. You'll see lines >like this (yours will be prefixed with something other than "nova>"): > >[r...@rhn ~]# cf-agent -vK > /tmp/out >[r...@rhn ~]# grep '^nova>.* in bundle .* ([1-3])' /tmp/out >nova> vars in bundle def (1) >nova> classes in bundle def (1) >nova> vars in bundle def (2) >nova> classes in bundle def (2) >nova> vars in bundle def (3) >nova> classes in bundle def (3) >nova> vars in bundle update (1) >nova> classes in bundle update (1) >nova> processes in bundle update (1) >nova> commands in bundle update (1) >nova> files in bundle update (1) >nova> services in bundle update (1) >nova> vars in bundle update (2) >nova> classes in bundle update (2) >nova> processes in bundle update (2) >nova> commands in bundle update (2) >nova> files in bundle update (2) >nova> services in bundle update (2) >nova> vars in bundle update (3) >nova> classes in bundle update (3) >nova> processes in bundle update (3) >nova> commands in bundle update (3) >nova> files in bundle update (3) >nova> services in bundle update (3) >nova> vars in bundle dg (1) >nova> classes in bundle dg (1) >nova> vars in bundle dg (2) >nova> classes in bundle dg (2) >nova> vars in bundle dg (3) >nova> classes in bundle dg (3) > >Note how it does 3 iterations of the promise types in bundle "def", then >3 of bundle "update", etc. ("dg" is a custom bundle of mine). > >Justin > >-----Original Message----- >From: help-cfengine-boun...@cfengine.org >[mailto:help-cfengine-boun...@cfengine.org] On Behalf Of >fo...@cfengine.com >Sent: Wednesday, April 21, 2010 3:22 PM >To: help-cfengine@cfengine.org >Subject: Cfengine Help: Re: RE: Cfengine Help: cfengine program flow > >Forum: Cfengine Help >Subject: Re: RE: Cfengine Help: cfengine program flow >Author: nicolas >Link to topic: >https://cfengine.com/forum/read.php?3,16959,16960#msg-16960 > >thanks for the fast response. > >it helps, i thought this is a recommendation :-/ (i should read more >exactly) > >but one question i still have: > >if i define a class: > >classes: > >"xy_installed" expression => fileexists("/usr/example"); > >does it recheck this value each time i use > >xy_installed:: > >or only once at the beginning of each of the 3 times? > >regards > >nicolas > >_______________________________________________ >Help-cfengine mailing list >Help-cfengine@cfengine.org >https://cfengine.org/mailman/listinfo/help-cfengine > >This electronic communication and any attachments may contain confidential and >proprietary >information of DigitalGlobe, Inc. If you are not the intended recipient, or an >agent or employee >responsible for delivering this communication to the intended recipient, or if >you have received >this communication in error, please do not print, copy, retransmit, >disseminate or >otherwise use the information. Please indicate to the sender that you have >received this >communication in error, and delete the copy you received. DigitalGlobe >reserves the >right to monitor any electronic communication sent or received by its >employees, agents >or representatives. > >_______________________________________________ >Help-cfengine mailing list >Help-cfengine@cfengine.org >https://cfengine.org/mailman/listinfo/help-cfengine >_______________________________________________ >Help-cfengine mailing list >Help-cfengine@cfengine.org >https://cfengine.org/mailman/listinfo/help-cfengine -- Jesse Becker NHGRI Linux support (Digicon Contractor) _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine