Hello,

I'm having some trouble passing parameters of different types to a
methods bundle, using CFEngine 3.3.4. Consider this example:

  body common control {
    bundlesequence => { "main" };
  }
  
  bundle agent main {
    methods:
      "any" usebundle => test("10","15");
  }
  
  bundle agent test(num1,num2) {
    vars:
      "list1" rlist => { "$(num1)", "100" };
      "list2" rlist => { "$(num1)", "100" };
  
      "x" real => product("list1");
      "y" real => product("list2");
  
    reports:
      cfengine_3::
        "x = $(x)";
        "y = $(y)";
  }

This fails horribly with the following error:

  cf3> /tmp/foo.cf:32,0: Error reading assumed real value $(num1) (anomalous 
remainder )
  cf3> /tmp/foo.cf:32,0: Error reading assumed real value $(num2) (anomalous 
remainder )

Also, consider this bundle:

  body common control {
    bundlesequence => { "main" };
  }
  
  bundle agent main {
    methods:
      "any" usebundle => test("root");
  }
  
  bundle agent test(user) {
    vars:
      "no_of_fields" int => 
getfields("^$(user):.*","/etc/shadow",":","userdata");
      "list3" rlist => { "$(userdata[3])", "100" };
      "z" real => product("list3");
  
    reports:
      cfengine_3::
        "z = $(z)";
  }

This one fails with a similar error:

  cf3> /tmp/foo.cf:21,0: Error reading assumed real value $(userdata[3]) 
(anomalous remainder )

However, it works if I don't use the 'user' parameter:

  body common control {
    bundlesequence => { "main" };
  }
  
  bundle agent main {
    methods:
      "any" usebundle => test("root");
  }
  
  bundle agent test(user) {
    vars:
      "no_of_fields" int => getfields("^root:.*","/etc/shadow",":","userdata");
      "list3" rlist => { "$(userdata[3])", "100" };
      "z" real => product("list3");
  
    reports:
      cfengine_3::
        "z = $(z)";
  }

Can anybody shed some light on this? What is going on here?

Regards,
-- 
Trond H. Amundsen <t.h.amund...@usit.uio.no>
Center for Information Technology Services, University of Oslo
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to