diff options
| author | Christos Triantafyllidis <christos.triantafyllidis@gmail.com> | 2012-06-12 00:49:17 +0300 |
|---|---|---|
| committer | Christos Triantafyllidis <christos.triantafyllidis@gmail.com> | 2012-06-12 00:49:17 +0300 |
| commit | cf9c34812219c3417d9e4d8af4cafaedd1e8988c (patch) | |
| tree | cef1abdeae93887b20de84202b6d7cd42e713a72 /modules/host_definitions | |
| download | DynamicNagiosConfig-cf9c34812219c3417d9e4d8af4cafaedd1e8988c.tar.gz DynamicNagiosConfig-cf9c34812219c3417d9e4d8af4cafaedd1e8988c.tar.xz DynamicNagiosConfig-cf9c34812219c3417d9e4d8af4cafaedd1e8988c.zip | |
Initial GIT import
Diffstat (limited to 'modules/host_definitions')
| -rw-r--r-- | modules/host_definitions/fedora_infra_hosts.py | 14 | ||||
| -rw-r--r-- | modules/host_definitions/file.py | 12 |
2 files changed, 26 insertions, 0 deletions
diff --git a/modules/host_definitions/fedora_infra_hosts.py b/modules/host_definitions/fedora_infra_hosts.py new file mode 100644 index 0000000..6ac1878 --- /dev/null +++ b/modules/host_definitions/fedora_infra_hosts.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +import os + +def get(config,result): + for host in [ name for name in os.listdir(config["path"]) if os.path.isdir(os.path.join(config["path"], name)) ]: + if not result.has_key(host): + result[host] = dict() + path = os.path.join(config["path"], host, "autoinfo") + if os.path.exists(os.path.join(path, "datacenter")): + result[host]["datacenter"] = open(os.path.join(path, "datacenter"),"r").read() + if os.path.exists(os.path.join(path, "distro")): + result[host]["distro"] = open(os.path.join(path, "distro"),"r").read() + + return result diff --git a/modules/host_definitions/file.py b/modules/host_definitions/file.py new file mode 100644 index 0000000..3466db3 --- /dev/null +++ b/modules/host_definitions/file.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python +import yaml + +def get(config,result): + hosts_config = yaml.load(file(config["file"], 'r')) + for host in hosts_config: + if result.has_key(host): + result[host].update(hosts_config[host]) + else: + result[host] = hosts_config[host] + + return result
\ No newline at end of file |
