7
8
10 - def __init__(self, name, enabled=False, hostgroups=None):
11 self._name = name
12 self._enabled = enabled
13
14 if hostgroups is None or len(hostgroups) <= 0:
15 raise LayoutException("Layout: " + self._name + " without hostgroups is useless")
16 else:
17 self._hostgroups = hostgroups
18
26
29
32
34 return self._hostgroups
35
37 ret = "Layout: 'Name:" + str(self.name) + "', 'Enabled: " + str(self.enabled) + " "
38 for group in self.hostgroups:
39 ret += str(group)
40 return ret
41
42
44 - def __init__(self, layouts, hostgroups):
45 self.layouts = []
46 self.dict = layouts
47 self.plugins = []
48 for k, v in layouts.items():
49 if k in ("plugins", "Plugins"):
50 self.plugins = v
51 continue
52 else:
53 l = Layout(k)
54 for k1, v1 in v.items():
55 if k1 in ("enabled", "Enabled"):
56 l.enabled = v1
57 elif k1 in ("hostgroups", "Hostgroups"):
58 l.hostgroups = []
59 for group in v1:
60 h = None
61 for hostg in hostgroups:
62 if hostg.name == group:
63 h = hostg
64 break
65 if h is not None:
66 l.hostgroups.append(h)
67 else:
68
69
70 pass
71 self.layouts.append(l)
72
74 ret = ""
75 ret += "Plugins: " + str(self.plugins) + "\n"
76 for layout in self.layouts:
77 ret += str(layout) + "\n"
78 return ret
79