From e5ccb4206f6958ea8796ab86f02aaa4c3ad72f9f Mon Sep 17 00:00:00 2001 From: Kamil Swiatkowski Date: Fri, 25 Oct 2013 13:18:17 +0200 Subject: [PATCH] pass arguments to wsman as xml file to allow list arguments --- wsman/provider/wsmancli.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/wsman/provider/wsmancli.py b/wsman/provider/wsmancli.py index 249a1f1..664e2bb 100644 --- a/wsman/provider/wsmancli.py +++ b/wsman/provider/wsmancli.py @@ -23,6 +23,7 @@ # along with WSManAPI. If not, see . import sys +import tempfile from wsman import WSManProvider @@ -735,11 +736,22 @@ def invoke(self, reference, command, arguments, remote=None, raw=False): if isinstance(arguments, basestring): get_command += "--input=\"%s\"" % arguments elif isinstance(arguments, dict): + input_file = tempfile.NamedTemporaryFile() + input_file.write('\n' % (command, reference.resource_uri)) for k,v in arguments.items(): - get_command += '-k \"%s=%s\" ' % (k,v) - + if isinstance(v, list): + for vitem in v: + input_file.write('%s\n' % (k, vitem, k)) + else: + input_file.write('%s\n' % (k, v, k)) + input_file.write('\n' % command) + get_command += '--input \"%s\" ' % input_file.name + + log.debug ("Executing command %s" % get_command) output = self.get_transport().execute(get_command) - + if input_file: + input_file.close() + if raw: return output else: