diff options
Diffstat (limited to 'src/lib/Server')
-rw-r--r-- | src/lib/Server/Plugins/Cfg.py | 15 | ||||
-rw-r--r-- | src/lib/Server/Plugins/SSHbase.py | 10 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py index ad1711d01..207f4465f 100644 --- a/src/lib/Server/Plugins/Cfg.py +++ b/src/lib/Server/Plugins/Cfg.py @@ -10,12 +10,6 @@ specific = re.compile('(.*/)(?P<filename>[\S\-.]+)\.((H_(?P<hostname>\S+))|' + '(G(?P<prio>\d+)_(?P<group>\S+)))$') probeData = {} -def update_file(path, diff): - '''Update file at path using diff''' - newdata = '\n'.join(difflib.restore(xml.sax.saxutils.unescape(diff).split('\n'), 1)) - print "writing file, %s" % path - open(path, 'w').write(newdata) - class SpecificityError(Exception): '''Thrown in case of filename parse failure''' pass @@ -362,7 +356,7 @@ class Cfg(Bcfg2.Server.Plugin.Plugin): logger.error("Got unknown event %s %s:%s" % (action, event.requestID, event.filename)) self.interpolate = len([entry for entry in self.entries.values() if entry.interpolate ]) > 0 - def AcceptEntry(self, meta, _, entry_name, diff): + def AcceptEntry(self, meta, _, entry_name, diff, fulldata): '''per-plugin bcfg2-admin pull support''' hsq = "Found host-specific file %s; Should it be updated (n/Y): " repo_vers = lxml.etree.Element('ConfigFile', name=entry_name) @@ -392,4 +386,9 @@ class Cfg(Bcfg2.Server.Plugin.Plugin): newname = basefile.name + ".H_%s" % (meta.hostname) print "This file will be installed as file %s" % newname if raw_input("Should it be installed? (N/y): ") in 'Yy': - update_file(newname, diff) + print "writing file, %s" % newname + if fulldata: + newdata = fulldata + else: + newdata = '\n'.join(difflib.restore(diff.split('\n'), 1)) + open(newname, 'w').write(newdata) diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py index 3e468d91f..bc5375da6 100644 --- a/src/lib/Server/Plugins/SSHbase.py +++ b/src/lib/Server/Plugins/SSHbase.py @@ -181,11 +181,17 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.DirectoryBacked): except OSError: self.logger.error("Failed to unlink temporary ssh keys") - def AcceptEntry(self, meta, _, entry_name, diff): + def AcceptEntry(self, meta, _, entry_name, diff, fulldata): '''per-plugin bcfg2-admin pull support''' filename = "%s/%s.H_%s" % (self.data, entry_name.split('/')[-1], meta.hostname) print "This file will be installed as file %s" % filename if raw_input("Should it be installed? (N/y): ") in 'Yy': - update_file(filename, diff) + print "writing file, %s" % filename + if fulldata: + newdata = fulldata + else: + newdata = '\n'.join(difflib.restore(diff.split('\n'), 1)) + open(filename, 'w').write(newdata) + |