summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-10-08 13:06:34 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-10-08 13:06:34 +0000
commit05bbe5881f80c5919986f72ec8ec370468aa9659 (patch)
tree65f26620e022a576cf02ca73649bf3864ab42d44 /src/lib
parent8311349047d3dc28dcaefba9003b60b663ed3939 (diff)
downloadbcfg2-05bbe5881f80c5919986f72ec8ec370468aa9659.tar.gz
bcfg2-05bbe5881f80c5919986f72ec8ec370468aa9659.tar.bz2
bcfg2-05bbe5881f80c5919986f72ec8ec370468aa9659.zip
NagiosGen minor updates (based on pylint suggestions)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4929 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Plugins/NagiosGen.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/lib/Server/Plugins/NagiosGen.py b/src/lib/Server/Plugins/NagiosGen.py
index 30ac93984..f754fea3c 100644
--- a/src/lib/Server/Plugins/NagiosGen.py
+++ b/src/lib/Server/Plugins/NagiosGen.py
@@ -4,6 +4,14 @@ import re, os, glob, socket, logging
import Bcfg2.Server.Plugin
LOGGER = logging.getLogger('Bcfg2.Plugins.NagiosGen')
+
+host_config_fmt = \
+'''define host{
+use default
+host_name %s
+alias %s
+address %s'''
+
class NagiosGen(Bcfg2.Server.Plugin.Plugin):
'''NagiosGen is a Bcfg2 plugin that dynamically generates
Nagios configuration file based on Bcfg2 data.'''
@@ -25,15 +33,10 @@ class NagiosGen(Bcfg2.Server.Plugin.Plugin):
def createhostconfig(self, entry, metadata):
'''Build host specific configuration file'''
host_address = socket.gethostbyname(metadata.hostname)
- host_groups = filter(lambda x: os.path.isfile('%s/%s-group.cfg' % \
- (self.data, x)), metadata.groups)
- host_config = \
- 'define host{\n\
- use default\n\
- host_name %s\n\
- alias %s\n\
- address %s\n' % \
- (metadata.hostname, metadata.hostname, host_address )
+ host_groups = [grp for grp in metadata.groups if \
+ os.path.isfile('%s/%s-group.cfg' % (self.data, grp))]
+ host_config = host_config_fmt % \
+ (metadata.hostname, metadata.hostname, host_address )
if host_groups:
host_config += ' hostgroups %s\n' % (",".join(host_groups))
host_config += ' }\n'
@@ -50,7 +53,7 @@ class NagiosGen(Bcfg2.Server.Plugin.Plugin):
(self.data, metadata.hostname))
LOGGER.error(ioerr)
- def createserverconfig(self, entry, metadata):
+ def createserverconfig(self, entry, _):
'''Build monolithic server configuration file'''
host_configs = glob.glob('%s/*-host.cfg' % self.data)
group_configs = glob.glob('%s/*-group.cfg' % self.data)