[PATCH] Add method to get delegation built map in mapper.py calss

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi guys,

I've added a little method to mapper.py and then to func-transmit class, that enables to get current delegation map using func-transmit. Probably would have been better to inser method directly in func... but I don't know... ;)

Anyway... you can call func-transmit using "delegation_map" as method to get content of map file (parsed with selected language).

Bye
Marco

---
func/overlord/mapper.py |   13 +++++++++++++
scripts/func-transmit   |    6 +++++-
2 files changed, 18 insertions(+), 1 deletions(-)
mode change 100644 => 100755 scripts/func-transmit

diff --git a/func/overlord/mapper.py b/func/overlord/mapper.py
index 6a1131c..179f6e7 100755
--- a/func/overlord/mapper.py
+++ b/func/overlord/mapper.py
@@ -91,3 +91,16 @@ class MapperTool(object):
        data = yaml.dump(minion_hash)
        mapfile.write(data)
+
+    def get_current_map(self):
+        try:
+            f = file(DEFAULT_TREE, 'r')
+            oldmap = f.read()
+            old_hash = yaml.load(oldmap).next()
+            f.close()
+        except:
+            print "ERROR: old map could not be read: " + str(sys.exc_info()[0])
+            sys.exit(-1)
+ + return old_hash + \ No newline at end of file
diff --git a/scripts/func-transmit b/scripts/func-transmit
old mode 100644
new mode 100755
index 4fe3cc3..b77fdb9
--- a/scripts/func-transmit
+++ b/scripts/func-transmit
@@ -44,6 +44,8 @@ import func.overlord.func_command as func_command
import func.overlord.client as fc
import func.yaml as yaml

+import func.overlord.mapper as mapper
+

class NoAsyncForListMinionException(exceptions.Exception):
        def __init__(self, msg):
@@ -103,7 +105,9 @@ def main(argv):
        minion_set = fc.Minions(clients)
        servers = minion_set.get_all_hosts()
        results = servers
-
+    elif method == "delegation_map":
+        mpTool = mapper.MapperTool()
+        results = mpTool.get_current_map()
    else:
        # scan more arguments
        nforks     = params.get('nforks', 1)
--
1.5.5.1



--
Dott. Ing. Mornati Marco
Byte-Code s.r.l
via Antonio Cechov, 1
San Giuliano Milanese (MI)
E-Mail: mmornati@xxxxxxxxxxxxx


_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux