From 97c21048ebfdcd205888c659393ae4e1f66de034 Mon Sep 17 00:00:00 2001
From: Luke Macken
Date: Thu, 17 Jan 2008 13:42:44 -0500
Subject: Add ability to execute methods and view minions/modules/methods from
funcweb
---
funcweb/funcweb/controllers.py | 28 ++++++++++++++++++++++++----
funcweb/funcweb/templates/master.html | 2 +-
funcweb/funcweb/templates/method.html | 13 +++++++++++++
funcweb/funcweb/templates/minion.html | 15 +++++++++++++++
funcweb/funcweb/templates/minions.html | 29 ++++++++++++-----------------
funcweb/funcweb/templates/module.html | 15 +++++++++++++++
6 files changed, 80 insertions(+), 22 deletions(-)
create mode 100644 funcweb/funcweb/templates/method.html
create mode 100644 funcweb/funcweb/templates/minion.html
create mode 100644 funcweb/funcweb/templates/module.html
diff --git a/funcweb/funcweb/controllers.py b/funcweb/funcweb/controllers.py
index 0754526..5fa6630 100644
--- a/funcweb/funcweb/controllers.py
+++ b/funcweb/funcweb/controllers.py
@@ -10,12 +10,32 @@ class Root(controllers.RootController):
def minions(self):
""" Return a list of our minions """
fc = Client("*")
- return dict(minions=fc.system.list_methods())
+ return dict(minions=fc.system.list_methods(), widgets=[])
@expose(template="funcweb.templates.minion")
- def minion(self, name):
+ def minion(self, name, module=None, method=None):
""" View all modules for a given minion """
fc = Client(name)
- return dict(modules=fc.system.list_modules())
+ if not module: # list all modules
+ modules = fc.system.list_modules()
+ return dict(modules=modules)
+ else: # a module is specified
+ if method: # minion.module.method specified; bring up execution form
+ return dict(minion=name, module=module, method=method,
+ tg_template="funcweb.templates.method")
+ else: # return a list of methods for specified module
+ modules = getattr(fc, module).list_methods()
+ return dict(modules=modules, module=module,
+ tg_template="funcweb.templates.module")
- index = minions
+ index = minions # start with our minion view, for now
+
+ @expose(template="funcweb.templates.run")
+ def run(self, minion="*", module=None, method=None, arguments=None):
+ fc = Client(minion)
+ if arguments:
+ results = getattr(getattr(fc, module), method)(arguments)
+ else:
+ results = getattr(getattr(fc, module), method)()
+ cmd = "%s.%s.%s(%s)" % (minion, module, method, arguments)
+ return dict(cmd=cmd, results=results)
diff --git a/funcweb/funcweb/templates/master.html b/funcweb/funcweb/templates/master.html
index 729c170..a0033da 100644
--- a/funcweb/funcweb/templates/master.html
+++ b/funcweb/funcweb/templates/master.html
@@ -8,7 +8,7 @@
py:replace="''" />
-
+
${XML(js)}
${XML(css)}
diff --git a/funcweb/funcweb/templates/method.html b/funcweb/funcweb/templates/method.html
new file mode 100644
index 0000000..daa0578
--- /dev/null
+++ b/funcweb/funcweb/templates/method.html
@@ -0,0 +1,13 @@
+
+
+
+
+ ${minion}.${module}.${method}
+
+
+
+
diff --git a/funcweb/funcweb/templates/minion.html b/funcweb/funcweb/templates/minion.html
new file mode 100644
index 0000000..bb36d31
--- /dev/null
+++ b/funcweb/funcweb/templates/minion.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/funcweb/funcweb/templates/minions.html b/funcweb/funcweb/templates/minions.html
index 2769ab0..63e6396 100644
--- a/funcweb/funcweb/templates/minions.html
+++ b/funcweb/funcweb/templates/minions.html
@@ -5,23 +5,18 @@
-
-
-
diff --git a/funcweb/funcweb/templates/module.html b/funcweb/funcweb/templates/module.html
new file mode 100644
index 0000000..ff49b98
--- /dev/null
+++ b/funcweb/funcweb/templates/module.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
--
cgit