Package lib :: Package config :: Module layouts
[hide private]
[frames] | no frames]

Source Code for Module lib.config.layouts

1 -class Layout:
2 - def __init__(self, myLayout):
3 self.name = myLayout 4 self.enabled = False 5 self.hostgroups = []
6
7 - def __str__(self):
8 ret = "Layout: 'Name:" + str(self.name) + "', 'Enabled: " + str(self.enabled) + " " 9 for group in self.hostgroups: 10 ret += str(group) 11 return ret
12 13
14 -class LayoutList:
15 - def __init__(self, layouts, hostgroups):
16 self.layouts = [] 17 self.dict = layouts 18 self.plugins = [] 19 for k, v in layouts.items(): 20 if k in ("plugins", "Plugins"): 21 self.plugins = v 22 continue 23 else: 24 l = Layout(k) 25 for k1, v1 in v.items(): 26 if k1 in ("enabled", "Enabled"): 27 l.enabled = v1 28 elif k1 in ("hostgroups", "Hostgroups"): 29 l.hostgroups = [] 30 for group in v1: 31 h = None 32 for hostg in hostgroups: 33 if hostg.name == group: 34 h = hostg 35 break 36 if h is not None: 37 l.hostgroups.append(h) 38 else: 39 # TODO: replace next line with new logging 40 #logger.logWarningConfig(file="hostgroups", missing=group) 41 self.layouts.append(l)
42
43 - def __str__(self):
44 ret = "" 45 ret += "Plugins: " + str(self.plugins) + "\n" 46 for layout in self.layouts: 47 ret += str(layout) + "\n" 48 return ret
49