diff options
author | Steve Salevan <ssalevan@marillion.rdu.redhat.com> | 2008-06-27 15:07:49 -0400 |
---|---|---|
committer | Steve Salevan <ssalevan@marillion.rdu.redhat.com> | 2008-06-27 15:07:49 -0400 |
commit | 76d705aca2d8366cd9e920a2cb1431ca19951b1d (patch) | |
tree | 983bf34032f2fce6eedb83fbdd5bd2efa690e626 /func | |
parent | b7fae3c9a31cd55b51334843053c74e0221e4b8b (diff) | |
download | func-76d705aca2d8366cd9e920a2cb1431ca19951b1d.tar.gz func-76d705aca2d8366cd9e920a2cb1431ca19951b1d.tar.xz func-76d705aca2d8366cd9e920a2cb1431ca19951b1d.zip |
Adding in some basic map append functionality to mapper tool
Diffstat (limited to 'func')
-rwxr-xr-x | func/overlord/mapper.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/func/overlord/mapper.py b/func/overlord/mapper.py index dc7a750..6118741 100755 --- a/func/overlord/mapper.py +++ b/func/overlord/mapper.py @@ -66,9 +66,30 @@ class MapperTool(object): if self.options.verbose: print "- built the following map:" print minion_hash - print "- writing to %s" % DEFAULT_TREE - if not self.options.append: - mapfile = file(DEFAULT_TREE, 'w') - yaml.dump(minion_hash,mapfile) + if self.options.append: + try: + oldmap = file(DEFAULT_TREE, 'r') + old_hash = yaml.load(oldmap) + oldmap.close() + except e: + print "ERROR: old map could not be read, append failed" + sys.exit(-1) + + merged_map = {} + merged_map.update(old_hash) + merged_map.update(minion_hash) + + if self.options.verbose: + print "- appended new map to the following map:" + print old_hash + print " resulting in:" + print merged_map + + minion_hash = merged_map + + if self.options.verbose: + print "- writing to %s" % DEFAULT_TREE + mapfile = file(DEFAULT_TREE, 'w') + yaml.dump(minion_hash,mapfile) |