summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2012-06-04 12:28:08 -0500
committerSol Jerome <sol.jerome@gmail.com>2012-06-04 12:30:09 -0500
commit8cc08eb59ddd87e32b67be4551f29af56f359eda (patch)
tree397c04b600c49296fbeb69cf5ba9d8fed30f1da7 /src/lib/Bcfg2/Server/Plugins/NagiosGen.py
parentf4bb86dee4e578d761d3161db30cd55b22c4142d (diff)
downloadbcfg2-8cc08eb59ddd87e32b67be4551f29af56f359eda.tar.gz
bcfg2-8cc08eb59ddd87e32b67be4551f29af56f359eda.tar.bz2
bcfg2-8cc08eb59ddd87e32b67be4551f29af56f359eda.zip
NagiosGen: Create empty config.xml when missing
This allows new users to get setup more quickly without having to worry about the tweaking capabilities available in config.xml. Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/NagiosGen.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/NagiosGen.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
index d132b0ff4..0c7b1daf7 100644
--- a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
+++ b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
@@ -17,7 +17,21 @@ line_fmt = '\t%-32s %s'
class NagiosGenConfig(Bcfg2.Server.Plugin.SingleXMLFileBacked,
Bcfg2.Server.Plugin.StructFile):
def __init__(self, filename, fam):
- Bcfg2.Server.Plugin.SingleXMLFileBacked.__init__(self, filename, fam)
+ # create config.xml if missing
+ if not os.path.exists(filename):
+ LOGGER.warning("NagiosGen: %s missing. "
+ "Creating empty one for you." % filename)
+ f = open(filename, "w")
+ f.write("<NagiosGen></NagiosGen>")
+ f.close()
+
+ try:
+ Bcfg2.Server.Plugin.SingleXMLFileBacked.__init__(self,
+ filename,
+ fam)
+ except OSError:
+ LOGGER.error("NagiosGen: Failed to read configuration file: %s" % err)
+ raise Bcfg2.Server.Plugin.PluginInitError(msg)
Bcfg2.Server.Plugin.StructFile.__init__(self, filename)