File: lsb.cf

package info (click to toggle)
cfengine3 3.6.2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 20,256 kB
  • ctags: 9,613
  • sloc: ansic: 116,129; sh: 12,366; yacc: 1,088; makefile: 1,006; lex: 391; perl: 197; xml: 21; sed: 4
file content (79 lines) | stat: -rw-r--r-- 2,953 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
bundle agent inventory_lsb
# @brief LSB inventory bundle
#
# This common bundle is for LSB inventory work.
{
  classes:
      "have_lsb" expression => fileexists($(lsb_exec));

      "_inventory_lsb_found" expression => regcmp("^[1-9][0-9]*$", $(dim)),
                                  scope => "namespace";

    _inventory_lsb_found::
      "lsb_$(os)" expression => "any",
      comment => "LSB Distributor ID",
      depends_on => { "inventory_lsb_os" },
      scope => "namespace",
      meta => { "inventory", "attribute_name=none" };

      "lsb_$(os)_$(release)" expression => "any",
      comment => "LSB Distributor ID and Release",
      depends_on => { "inventory_lsb_os", "inventory_lsb_release" },
      scope => "namespace",
      meta => { "inventory", "attribute_name=none" };

      "lsb_$(os)_$(codename)" expression => "any",
      comment => "LSB Distributor ID and Codename",
      depends_on => { "inventory_lsb_os", "inventory_lsb_codename" },
      scope => "namespace",
      meta => { "inventory", "attribute_name=none" };

  vars:
      "lsb_exec" string => "$(inventory_control.lsb_exec)";

    have_lsb::
      "data" string => execresult("$(lsb_exec) -a", "noshell");
      "dim" int => parsestringarray(
                                     "lsb",
                                     $(data),
                                     "\s*#[^\n]*",
                                     "\s*:\s+",
                                     "15",
                                     "4095"
      );

    _inventory_lsb_found::
      "lsb_keys" slist => getindices("lsb");

      "os" string => canonify("$(lsb[Distributor ID][1])"),
      handle => "inventory_lsb_os",
      comment => "LSB-provided OS name",
      meta => { "inventory", "attribute_name=none" };

      "codename" string => canonify("$(lsb[Codename][1])"),
      handle => "inventory_lsb_codename",
      comment => "LSB-provided OS code name",
      meta => { "inventory", "attribute_name=none" };

      "release" string => "$(lsb[Release][1])",
      handle => "inventory_lsb_release",
      comment => "LSB-provided OS release",
      meta => { "inventory", "attribute_name=none" };

      "flavor" string => canonify("$(lsb[Distributor ID][1])_$(lsb[Release][1])"),
      handle => "inventory_lsb_flavor",
      comment => "LSB-provided OS flavor",
      meta => { "inventory", "attribute_name=none" };

      "description" string => "$(lsb[Description][1])",
      handle => "inventory_lsb_description",
      comment => "LSB-provided OS description",
      meta => { "inventory", "attribute_name=none" };

  reports:
    inform_mode._inventory_lsb_found::
      "$(this.bundle): OS = $(os), codename = $(codename), release = $(release), flavor = $(flavor), description = $(description)";
    verbose_mode._inventory_lsb_found::
      "$(this.bundle): got $(dim) LSB keys";
      "$(this.bundle): prepared LSB key $(lsb_keys) = '$(lsb[$(lsb_keys)][1])'";
}