help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Iteration with method params doesn't seem to be happening


From: Chip Seraphine
Subject: Iteration with method params doesn't seem to be happening
Date: Thu, 30 Sep 2004 12:47:23 -0500
User-agent: KMail/1.5.4

I'm finding different iteration behavior depending on wether or not a list was 
defined locally or passed in as a parameter.  (Since the methods: stuff 
itself does not iterate, this is a Big Problem as it means there might be no 
way of iterating while using a method, which is a rather crippling problem!).

Is there some kind of nifty namespace stuff I should be doing to work around 
this?

Here's my calling file:
        # cfagent.conf
        control:
        actionsequence = ( methods shellcommands )
                string = ( "word1:word2:word3" )
                Split= ( ":" )

        methods:
        SimpleMethod( ${string} )
           action=cf.simple
           returnvars=null
           returnclasses=null
           server=localhost

        shellcommands:
                "/bin/echo mothership printing ${string}"


....and here is my function definition:

        control:
                MethodName       = ( SimpleMethod )
                MethodParameters = ( foo )
                actionsequence   = ( shellcommands )
                foo_local =        ( "foo2a:foo2b:foo2c" )
                Split=             ( ":" )

        shellcommands:
                "/bin/echo method printing parameter $(foo)"
                "/bin/echo foo_local is  $(foo_local)"

        alerts:
                ReturnVariables(void)
                ReturnClasses(void)


When I run it, I am expecting to see both $(foo) and $(foo_local) iterated 
over; instead, only the local variable is.  The calling file does 
successfully iterate $(foo)'s parent string, however.

Here's what it looks like:

cfengine::SimpleMethod: cfengine::/bin/echo metho: method printing parameter 
word1:word2:word3
cfengine::SimpleMethod: cfengine::/bin/echo foo_l: foo_local is foo2a
cfengine::SimpleMethod: cfengine::/bin/echo foo_l: foo_local is foo2b
cfengine::SimpleMethod: cfengine::/bin/echo foo_l: foo_local is foo2c
cfengine::/bin/echo mothe: mothership printing word1
cfengine::/bin/echo mothe: mothership printing word2
cfengine::/bin/echo mothe: mothership printing word3

In another test, I tried assigning the parameter to a local variable and 
iterating over *that*, but it failed.  Almost as if the parameter-ness of the 
value somehow stuck....   Concatenating the parameter value as a wierd 
result, too.   If I do this:

                MethodParameters = ( foo )
                bar = ( "cow:${foo}" )

...and run it with the above goodies, I get this:

cfengine::SimpleMethod: cfengine::/bin/echo metho: method printing parameter 
foo_local cow
cfengine::SimpleMethod: cfengine::/bin/echo metho: method printing parameter 
foo_local word1:word2:word3

It seems to recognize the first colon as a delimiter, but not those lurking 
within ${foo}.

I suspect I could get it to work by doing cheesy/gratuitous string 
manipulation within an ExecResult or something, but that is just ugly.

Thoughts?

-- 

Chip Seraphine
Unix Administrator
TradeLink, LLC
312-264-2048
chip@trdlnk.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]