Nima-

Comments inline, below...

-Dan

On Sep 11, 2010, at 11:03 PM, no-re...@cfengine.com wrote:

> Forum: Cfengine Help
> Subject: Handles vs Classes - Scope Intersection
> Author: nima
> Link to topic: https://cfengine.com/forum/read.php?3,18170,18170#msg-18170
> 
> Are we free to do the following:
> 
> bundle agent Client {
>   files:
>       linux::
>           "$(sys.workdir)/inputs/."
>               handle => "a_unique_identifier",
>               comment => "$(this.promiser):$(this.handle)",
>               copy_from => ...,
>               classes => DefineSoftClass"$(this.handle)"
>           ;
>   ...:
> }
> 
> 
> Note that I've defined a single unique identifier, then reused that in the 
> comment, and also in the dynamic declaration of classes.  Basically I'm 
> trying to minimize the number of unique strings that I need to pull out of 
> thin air to reduce complexity.  I would generally just test this, but since I 
> get so many cf3 crashes, it's a little difficult to tell what is actually the 
> root cause for the crash.
> 
> In summary, my questions boils down to the following:
> 
> 1. Is the scope of handle names mutually exclusive to the class names

As far as I know, yes

> 2. Is the comment field valid

Yes, as long as the open/quotes balance, it's just a "special" comment (which 
means Nova uses it in reports, but it is otherwise ignored)

> 3. Can I define classes based on $(this.handle), as long as I make sure that 
> it contains only valid characters

Yes, but you're better off using the classify() function to make sure for you 
:-)  There is no "DefineSoftClass" in Cfengine-3, and your "classes" attribute 
requires a compound body to be defined for it 
(seehttp://www.cfengine.org/manuals/cf3-reference.html#classes-in-_002a, for 
the definition, and look in the COPBL 
http://www.cfengine.org/manuals/CfengineStdLibrary.html#body-classes-cf2_005fif_005felse,
 etc. for examples)

> 
> Oh one more thing that's bugged me - is this valid:
> 
> bundle common control {
>   vars:
>       #. Core - Minimal (Don't EVER break these!)...
>       "bundle" slist => { "Client", "Server" };
>       "inputs" slist => {
>           "lib-conf.cf",      #. User configurations
>           "lib-core.cf",      #. System variables and library functions
>           "cf-agent.cf",      #. Starting point for cfengine clients & servers
>           "cf-serverd.cf",    #. Cfengine server configuration
>       };   
> 
> 
> 4. Note the last comma in the slist block.  This is so I can move lines 
> around without having to worry about the absence of the last comma everytime.

This was fixed about 8 months ago - if you have a recent copy of the source, a 
trailing comment is harmless in the inputs and bundlesequence.  However, other 
than that, your syntax is otherwise about 70% wrong :-/  It should be:

body common control {
      #. Core - Minimal (Don't EVER break these!)...
      bundlesequece => { "Client", "Server" };
      inputs => {
          "lib-conf.cf",      #. User configurations
          "lib-core.cf",      #. System variables and library functions
          "cf-agent.cf",      #. Starting point for cfengine clients & servers
          "cf-serverd.cf",    #. Cfengine server configuration
      };   

-Dan
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to