summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-07-07 11:14:59 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-07-07 11:14:59 -0400
commit34105d3ae7d7f07e1b377bbaf9b246593da1f471 (patch)
treeb24f97018da22c0336d3d305e1f1be1475e6b2da
parentdb0b4fb07b6b4e0b4a2e1af3a17d4638bc923c52 (diff)
downloadfunc-34105d3ae7d7f07e1b377bbaf9b246593da1f471.tar.gz
func-34105d3ae7d7f07e1b377bbaf9b246593da1f471.tar.xz
func-34105d3ae7d7f07e1b377bbaf9b246593da1f471.zip
Added func-transmit (Marco's version + tweaks) which allows calling Func via a YAML interface over stdin/stdout protocol. We still need to package yaml properly as Fedora/EPEL does not have a parser that we like well enough (FIXME). We could also change this to work over XMLRPC marshalling if so desired.
-rw-r--r--AUTHORS1
-rw-r--r--func.spec4
-rw-r--r--scripts/func-transmit65
-rw-r--r--scripts/func-transmit-demo6
-rw-r--r--setup.py2
-rw-r--r--version2
6 files changed, 78 insertions, 2 deletions
diff --git a/AUTHORS b/AUTHORS
index 5a7f982..eb20c3c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -24,6 +24,7 @@ Additional patches and contributions by ...
Brenton Leanhardt <bleanhar@redhat.com>
Luke Macken <lmacken@redhat.com>
Steve Milner <smilner@redhat.com>
+ Marco Mornati <mmornati@byte-code.com>
Stephen Nelson-Smith <atalanta.systems@googlemail.com>
Robin Norwood <rnorwood@redhat.com>
Al Tobey <tobert@gmail.com>
diff --git a/func.spec b/func.spec
index 6529680..fe1e43f 100644
--- a/func.spec
+++ b/func.spec
@@ -54,6 +54,7 @@ rm -fr $RPM_BUILD_ROOT
%{_bindir}/func
%{_bindir}/func-inventory
%{_bindir}/func-create-module
+%{_bindir}/func-transmit
#%{_bindir}/update-func
/etc/init.d/funcd
%dir %{_sysconfdir}/%{name}
@@ -124,6 +125,9 @@ fi
%changelog
+* Mon Jul 07 2008 Michael DeHaan <mdehaan@redhat.com> - 0.22-1
+- packaged func-transmit script
+
* Wed Jul 02 2008 Michael DeHaan <mdehaan@redhat.com> - 0.21-1
- new release, upstream changes
diff --git a/scripts/func-transmit b/scripts/func-transmit
new file mode 100644
index 0000000..163a99c
--- /dev/null
+++ b/scripts/func-transmit
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+
+##
+## func yaml wrapper tool.
+## allows usage of func over stdin/stdin using yaml as a marshalling format
+## for access to the Overlord() API from non-Python code.
+## this should typically be accessed via a pipe, though also works as
+## func-transmit < yamlfile
+##
+## Copyright 2008, Various
+## Marco Mornati <mmornati@byte-code.com>
+## Michael DeHaan <mdehaan@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.
+##
+
+
+## Example input file format:
+"""
+clients: "*"
+aysnc: False
+nforks: 1
+module: command
+method: run
+parameters: "/bin/echo Hello World"
+"""
+
+import sys
+import distutils.sysconfig
+
+import cobbler.yaml as yaml # FIXME: need to subpackage this as part of Func
+import func.overlord.func_command as func_command
+import func.overlord.client as fc
+
+# load input from stdin
+input = sys.stdin.read()
+params = yaml.load(input).next()
+
+# scan arguments
+clients = params.get('clients', "*")
+async = params.get('async', False)
+nforks = params.get('nforks', 1)
+module = params.get('module','unknown')
+method = params.get('method','unknown')
+parameters = params.get('parameters', [])
+
+# make the call
+client = fc.Overlord(clients, async=async, nforks=nforks)
+module_handle = getattr(client, module)
+method_handle = getattr(module_handle, method)
+results = method_handle(parameters)
+output = yaml.dump(results)
+
+# write to stdout
+print output
+
+
+
+
+
diff --git a/scripts/func-transmit-demo b/scripts/func-transmit-demo
new file mode 100644
index 0000000..b38c3a4
--- /dev/null
+++ b/scripts/func-transmit-demo
@@ -0,0 +1,6 @@
+clients: "*"
+aysnc: False
+nforks: 1
+module: command
+method: run
+parameters: "/bin/echo Hello World"
diff --git a/setup.py b/setup.py
index bba37f8..d11abac 100644
--- a/setup.py
+++ b/setup.py
@@ -33,7 +33,7 @@ if __name__ == "__main__":
"scripts/func",
"scripts/func-inventory",
"scripts/func-create-module",
- # "scripts/update-func",
+ "scripts/func-transmit"
],
# package_data = { '' : ['*.*'] },
package_dir = {"%s" % NAME: "%s" % NAME
diff --git a/version b/version
index bed8506..c9ec35a 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-0.21 1
+0.22 1