Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions wsman/provider/wsmancli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# along with WSManAPI. If not, see <http://www.gnu.org/licenses/>.

import sys
import tempfile

from wsman import WSManProvider

Expand Down Expand Up @@ -735,11 +736,25 @@ 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('<p:%s_INPUT xmlns:p="%s">\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('<p:%s>%s</p:%s>\n' % (k, vitem, k))
else:
input_file.write('<p:%s>%s</p:%s>\n' % (k, v, k))
input_file.write('</p:%s_INPUT>\n' % command)
input_file.seek(0)
get_command += '--input \"%s\" ' % input_file.name

log.debug ("Executing command %s" % get_command)
log.debug ("XML input file %s content:\n%s" % (input_file.name, input_file.read()))
output = self.get_transport().execute(get_command)


if input_file:
input_file.close()

if raw:
return output
else:
Expand Down