FAQ
Hi,

I use SALT API to send command to remote system

local = LocalClient(...)
value = '["a", "b", "c"]' # RAW STRING JSON ARRAY WITH THREE ITEM a, b, c
jid = local.cmd_async("minion", "cmd.run_all", arg=["cat"], kwarg={"stdin":
value})
while True:
     rets = p .local_get_cache_returns(jid)
     if rets:
       for hwaddr, opts in rets.items():
           print hwaddr
           print opts
           ret = opts.get("ret")
           stdout = ret.get("stdout")
           sys.stdout.write(stdout)
           break
       time.sleep(0.5)

And have returns:

['a', 'b', 'c']

But when I am sending:

value = '1["a", "b", "c"]' # RAW STRING JSON ARRAY WITH THREE ITEM a, b, c

I have result:

1["a", "b", "c"]

How to send my request without change? byte as byte.... Dont tell me about
MIME and BASE64 please...

Thanx.

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Daniel Jagszent at Jul 11, 2014 at 11:22 am
    Hi Vitold,

    interesting. Same result on the command line
    $ salt-call cmd.run_all cat stdin='["a", "b", "c"]'

    Looks like all arguments get YAMLified
    https://github.com/saltstack/salt/blob/develop/salt/utils/args.py#L41

    Does not look like there is a way around it. A workaround is of course
    to create a temp file with the input and use shell stdin redirection
    ("cat < /temp/file")

    Vitold S wrote:
    Hi,

    I use SALT API to send command to remote system

    local = LocalClient(...)
    value = '["a", "b", "c"]' # RAW STRING JSON ARRAY WITH THREE ITEM a, b, c
    jid = local.cmd_async("minion", "cmd.run_all", arg=["cat"],
    kwarg={"stdin": value})
    while True:
    rets = p .local_get_cache_returns(jid)
    if rets:
    for hwaddr, opts in rets.items():
    print hwaddr
    print opts
    ret = opts.get("ret")
    stdout = ret.get("stdout")
    sys.stdout.write(stdout)
    break
    time.sleep(0.5)

    And have returns:

    ['a', 'b', 'c']

    But when I am sending:

    value = '1["a", "b", "c"]' # RAW STRING JSON ARRAY WITH THREE ITEM a, b, c

    I have result:

    1["a", "b", "c"]

    How to send my request without change? byte as byte.... Dont tell me
    about MIME and BASE64 please...

    Thanx.
    --
    You received this message because you are subscribed to the Google
    Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to salt-users+unsubscribe@googlegroups.com
    For more options, visit https://groups.google.com/d/optout.
  • Seth House at Jul 12, 2014 at 4:00 pm
    Ending the content with a newline character will bypass the YAML
    conversion. There's an open ticket to add a CLI flag to do it too.

    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsalt-users @
postedJul 11, '14 at 10:04a
activeJul 12, '14 at 4:00p
posts3
users3

People

Translate

site design / logo © 2022 Grokbase