From 34105d3ae7d7f07e1b377bbaf9b246593da1f471 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Mon, 7 Jul 2008 11:14:59 -0400 Subject: 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. --- scripts/func-transmit | 65 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/func-transmit-demo | 6 +++++ 2 files changed, 71 insertions(+) create mode 100644 scripts/func-transmit create mode 100644 scripts/func-transmit-demo (limited to 'scripts') 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 +## Michael DeHaan +## +## 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" -- cgit