From 11a57fdb320a08729eb28162e2d3fcee8a2e8a2a Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 23 Nov 2016 21:31:04 +0100 Subject: Server/Plugins/NagiosGen: Always include default group The default group file should be included, even if no server is in the 'default' hostgroup. It allows to include global definitions (like a service template). The behaviour is documented and was broken by 590a1314bca44f29fc34bd27f0d49599b7eeab10. --- src/lib/Bcfg2/Server/Plugins/NagiosGen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py index d3c38ef19..1584a5ab6 100644 --- a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py +++ b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py @@ -92,7 +92,7 @@ class NagiosGen(Plugin, Generator): for host in host_configs: host_data.append(open(host, 'r').read()) - group_list = [] + group_list = ['default'] for line in "\n".join(host_data).splitlines(): # only include those groups which are actually used if "hostgroup" in line: -- cgit v1.2.3-1-g7c22 From b4a27c9b3d2ebf2a143646f424f06a15e65a6cd9 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 23 Nov 2016 21:35:52 +0100 Subject: Server/Plugins/NagiosGen: Remove the list conversion --- src/lib/Bcfg2/Server/Plugins/NagiosGen.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py index 1584a5ab6..067e2faad 100644 --- a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py +++ b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py @@ -92,17 +92,15 @@ class NagiosGen(Plugin, Generator): for host in host_configs: host_data.append(open(host, 'r').read()) - group_list = ['default'] + used_groups = set(['default']) for line in "\n".join(host_data).splitlines(): # only include those groups which are actually used if "hostgroup" in line: - group_list += line.split()[1].split(',') - - group_list = list(set(group_list)) + used_groups.update(line.split()[1].split(',')) for group in group_configs: group_name = re.sub("(-group.cfg|.*/(?=[^/]+))", "", group) - if group_name in group_list: + if group_name in used_groups: groupfile = open(group, 'r') group_data.append(groupfile.read()) groupfile.close() -- cgit v1.2.3-1-g7c22