summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authorSteve Salevan <ssalevan@marillion.rdu.redhat.com>2008-06-27 14:51:21 -0400
committerSteve Salevan <ssalevan@marillion.rdu.redhat.com>2008-06-27 14:51:21 -0400
commitb7fae3c9a31cd55b51334843053c74e0221e4b8b (patch)
treeb7ab27b26b27cd70dc2bf2ce410630e026da4b4c /func
parent466e8afe8444ce68a1e81ad70d5fcf1d2cf32316 (diff)
downloadfunc-b7fae3c9a31cd55b51334843053c74e0221e4b8b.tar.gz
func-b7fae3c9a31cd55b51334843053c74e0221e4b8b.tar.xz
func-b7fae3c9a31cd55b51334843053c74e0221e4b8b.zip
Adding in a command-line map building tool,
adjusting spec and setup.py to account for new PyYAML dependency and new script
Diffstat (limited to 'func')
-rwxr-xr-xfunc/overlord/mapper.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/func/overlord/mapper.py b/func/overlord/mapper.py
new file mode 100755
index 0000000..dc7a750
--- /dev/null
+++ b/func/overlord/mapper.py
@@ -0,0 +1,74 @@
+##
+## func topology map-building tool
+## If you've got a giant, tangled, complex web of func overlords
+## and minions, this tool will help you construct or augment a map
+## of your func network topology so that delegating commands to
+## minions and overlords becomes a simple matter.
+##
+## Copyright 2008, Red Hat, Inc.
+## Steve Salevan <ssalevan@redhat.com>
+##
+## This software may be freely redistributed under the terms of the GNU
+## general public license.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+##
+
+import optparse
+import sys
+import yaml
+import func.overlord.client as func_client
+
+DEFAULT_TREE = "/var/lib/func/inventory/map"
+
+class MapperTool(object):
+
+ def __init__(self):
+ pass
+
+ def run(self,args):
+
+ p = optparse.OptionParser()
+ #currently not implemented
+ p.add_option("-a", "--append",
+ dest="append",
+ action="store_true",
+ help="append new map to current map")
+ p.add_option("-r", "--rebuild",
+ dest="rebuild",
+ action="store_true",
+ help="rebuild map from scratch")
+ p.add_option("-o", "--onlyalive",
+ dest="only_alive",
+ action="store_true",
+ help="gather only currently-living minions")
+ p.add_option("-v", "--verbose",
+ dest="verbose",
+ action="store_true",
+ help="provide extra output")
+
+ (options, args) = p.parse_args(args)
+ self.options = options
+
+ if options.verbose:
+ print "- recursively calling map function"
+
+ self.build_map()
+
+ return 1
+
+ def build_map(self):
+
+ minion_hash = func_client.Overlord("*").overlord.map_minions(self.options.only_alive==True)
+
+ 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)
+