diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2006-05-15 20:07:32 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2006-05-15 20:07:32 +0000 |
commit | 1ef1dfeb7203242ffcc2ef4c27ed0e34f46337f7 (patch) | |
tree | 974192df32fdc56b8c4d701fd49962d937267c52 /src | |
parent | bef0233dacbdd6f63b08695e7622d40ab375ae04 (diff) | |
download | bcfg2-1ef1dfeb7203242ffcc2ef4c27ed0e34f46337f7.tar.gz bcfg2-1ef1dfeb7203242ffcc2ef4c27ed0e34f46337f7.tar.bz2 bcfg2-1ef1dfeb7203242ffcc2ef4c27ed0e34f46337f7.zip |
Add support for empty files
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1864 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Client/Toolset.py | 6 | ||||
-rw-r--r-- | src/lib/Server/Plugins/Cfg.py | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/Client/Toolset.py b/src/lib/Client/Toolset.py index fd8e01604..ceae8dda7 100644 --- a/src/lib/Client/Toolset.py +++ b/src/lib/Client/Toolset.py @@ -366,6 +366,8 @@ class Toolset(object): perms = os.stat(filename)[ST_MODE] if entry.get('encoding', 'ascii') == 'base64': tempdata = binascii.a2b_base64(entry.text) + elif entry.get('empty', 'false') == 'true': + tempdata = '' else: tempdata = entry.text @@ -383,7 +385,7 @@ class Toolset(object): def InstallConfigFile(self, entry): '''Install ConfigFile Entry''' - if entry.text == None: + if entry.text == None and entry.get('empty', 'false') != 'true': self.logger.error( "Incomplete information for ConfigFile %s. Cannot install" % (entry.get('name'))) return False @@ -418,6 +420,8 @@ class Toolset(object): newfile = open("%s.new"%(entry.get('name')), 'w') if entry.get('encoding', 'ascii') == 'base64': filedata = binascii.a2b_base64(entry.text) + elif entry.get('empty', 'false') == 'true': + filedata = '' else: filedata = entry.text newfile.write(filedata) diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py index f0f11b88e..402389663 100644 --- a/src/lib/Server/Plugins/Cfg.py +++ b/src/lib/Server/Plugins/Cfg.py @@ -200,6 +200,8 @@ class ConfigFileEntry(object): entry.attrib['paranoid'] = 'true' if entry.attrib['encoding'] == 'base64': entry.text = binascii.b2a_base64(filedata) + if filedata == '': + entry.set('empty', 'true') else: try: entry.text = filedata |