summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2012-01-25 10:27:13 -0600
committerSol Jerome <sol.jerome@gmail.com>2012-01-25 10:28:47 -0600
commit60301459da33e4fdad4c5bc4c836c8990238dd61 (patch)
treef33b060327bbdc594740d17bf1b94a88930cd403 /src/lib
parentfbfd6bb0d6bc5c0b6660233269d8aabb13da49ea (diff)
downloadbcfg2-60301459da33e4fdad4c5bc4c836c8990238dd61.tar.gz
bcfg2-60301459da33e4fdad4c5bc4c836c8990238dd61.tar.bz2
bcfg2-60301459da33e4fdad4c5bc4c836c8990238dd61.zip
Cfg: Inform user of info.xml override (#1089)
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Plugins/Cfg.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py
index 0a791f171..d2e6e8a1d 100644
--- a/src/lib/Server/Plugins/Cfg.py
+++ b/src/lib/Server/Plugins/Cfg.py
@@ -31,6 +31,7 @@ try:
except:
have_cheetah = False
+# setup logging
logger = logging.getLogger('Bcfg2.Plugins.Cfg')
@@ -220,25 +221,33 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
return "%s.H_%s" % (bfname, specific.hostname)
def write_update(self, specific, new_entry, log):
+ # FIXME: need to redo print with python's logging module
if 'text' in new_entry:
name = self.build_filename(specific)
if os.path.exists("%s.genshi" % name):
- logger.error("Cfg: Unable to pull data for genshi types")
+ print("Cfg: Unable to pull data for genshi types")
raise Bcfg2.Server.Plugin.PluginExecutionError
elif os.path.exists("%s.cheetah" % name):
- logger.error("Cfg: Unable to pull data for cheetah types")
+ print("Cfg: Unable to pull data for cheetah types")
raise Bcfg2.Server.Plugin.PluginExecutionError
try:
etext = new_entry['text'].encode(self.encoding)
except:
- logger.error("Cfg: Cannot encode content of %s as %s" % (name, self.encoding))
+ print("Cfg: Cannot encode content of %s as %s" % (name, self.encoding))
raise Bcfg2.Server.Plugin.PluginExecutionError
open(name, 'w').write(etext)
if log:
- logger.info("Wrote file %s" % name)
+ print("Wrote file %s" % name)
badattr = [attr for attr in ['owner', 'group', 'perms']
if attr in new_entry]
if badattr:
+ # check for info files and inform user of their removal
+ if os.path.exists(self.path + "/:info"):
+ print("Removing :info file and replacing with info.xml")
+ os.remove(self.path + "/:info")
+ if os.path.exists(self.path + "/info"):
+ print("Removing info file and replacing with info.xml")
+ os.remove(self.path + "/info")
metadata_updates = {}
metadata_updates.update(self.metadata)
for attr in badattr:
@@ -251,7 +260,7 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
ofile.write(lxml.etree.tostring(infoxml, pretty_print=True))
ofile.close()
if log:
- logger.info("Wrote file %s" % (self.path + "/info.xml"))
+ print("Wrote file %s" % (self.path + "/info.xml"))
class Cfg(Bcfg2.Server.Plugin.GroupSpool,