File: unpack_method_calls.cf

package info (click to toggle)
cfengine3 3.15.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 34,456 kB
  • sloc: ansic: 145,932; sh: 8,550; makefile: 1,558; yacc: 1,192; python: 1,056; lex: 758; perl: 211; pascal: 149; awk: 58; xml: 21; sed: 13
file content (39 lines) | stat: -rw-r--r-- 758 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#+begin_src cfengine3
body common control
{
      bundlesequence => { run };
}

bundle agent run
{
  vars:
      "todo" slist => { "call_1,a,b", "call_2,x,y", "call_2,p,q" };

  methods:
      "call" usebundle => unpack($(todo));
}

bundle agent unpack(list)
{
  vars:
      "split" slist => splitstring($(list), ",", "100");
      "method" string => nth("split", "0");
      "param1" string => nth("split", "1");
      "param2" string => nth("split", "2");

  methods:
      "relay" usebundle => $(method)($(param1), $(param2));
}

bundle agent call_1(p1, p2)
{
  reports:
      "$(this.bundle): called with parameters $(p1) and $(p2)";
}

bundle agent call_2(p1, p2)
{
  reports:
      "$(this.bundle): called with parameters $(p1) and $(p2)";
}
#+end_src