summaryrefslogtreecommitdiffstats
path: root/funcweb
diff options
context:
space:
mode:
authorLuke Macken <lmacken@redhat.com>2008-01-17 13:42:44 -0500
committerLuke Macken <lmacken@redhat.com>2008-01-17 13:42:44 -0500
commit97c21048ebfdcd205888c659393ae4e1f66de034 (patch)
tree6fbd7780118b786c8504991e3a87261a9fe02254 /funcweb
parent5beae9e4bee512ad0b52495a6fa8ba94052a3348 (diff)
downloadthird_party-func-97c21048ebfdcd205888c659393ae4e1f66de034.tar.gz
third_party-func-97c21048ebfdcd205888c659393ae4e1f66de034.tar.xz
third_party-func-97c21048ebfdcd205888c659393ae4e1f66de034.zip
Add ability to execute methods and view minions/modules/methods from funcweb
Diffstat (limited to 'funcweb')
-rw-r--r--funcweb/funcweb/controllers.py28
-rw-r--r--funcweb/funcweb/templates/master.html2
-rw-r--r--funcweb/funcweb/templates/method.html13
-rw-r--r--funcweb/funcweb/templates/minion.html15
-rw-r--r--funcweb/funcweb/templates/minions.html29
-rw-r--r--funcweb/funcweb/templates/module.html15
6 files changed, 80 insertions, 22 deletions
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="''" />
<title py:content="'Your Title Goes Here'"></title>
- <script type="text/javascript" src="${tg.url('/static/js/jquery.js')}" />
+ <script type="text/javascript" src="${tg.url('/static/javascript/jquery.js')}" />
<link py:for="js in tg_js_head" py:strip="">${XML(js)}</link>
<link py:for="css in tg_css" py:strip="">${XML(css)}</link>
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 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+<body>
+ <div class="method">
+ ${minion}.${module}.${method}
+ <form action="${tg.url('/run?minion=%s&amp;module=%s&amp;method=%s' % (minion, module, method))}" method="POST">
+ <input type="text" name="arguments" />
+ </form>
+ </div>
+</body>
+</html>
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 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+<body>
+ <div id="modules" class="modules">
+ <ul py:for="minion, mods in modules.items()">
+ <h2>${minion}</h2>
+ <li py:for="module in mods">
+ <a href="#" onclick="$('#col3').load('/minion/${minion}/${module}')">${module}</a>
+ </li>
+ </ul>
+ </div>
+</body>
+</html>
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 @@
<xi:include href="master.html"/>
<head/>
<body>
- <!--
- <div id="sidebar">
- <h2>FuncWeb</h2>
- <ul class="links">
- <li><a href="#">Groups</a></li>
- <li><a href="#">Minions</a></li>
- <li><a href="#">Modules</a></li>
- </ul>
+ <div class="col-group">
+ <div class="col" id="col1">
+ <b>Minions</b>
+ <ul>
+ <li py:for="minion in minions.keys()">
+ <a onclick="$('#col2').load('/minion/${minion}')" href="#">${minion}</a>
+ </li>
+ </ul>
+ </div>
+ <div class="col" id="col2" />
+ <div class="col" id="col3" />
+ <div class="col" id="col4" />
</div>
- -->
- <div id="getting_started">
- <ol id="getting_started_steps">
- <li py:for="minion in minions.keys()">
- <a href="${tg.url('/minion/' + minion)}">${minion}</a>
- </li>
- </ol>
- </div>
-
</body>
</html>
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 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+<body>
+ <div id="module" class="module">
+ <ul py:for="minion, methods in modules.items()">
+ <h2>${module}</h2>
+ <li py:for="method in methods">
+ <a href="#" onclick="$('#col4').load('/minion/${minion}/${module}/${method}')">${method}</a>
+ </li>
+ </ul>
+ </div>
+</body>
+</html>