[lxc-users] lxd api return of /1.0/containers/<name>/exec

laurent ducos laurentducos at gmail.com
Fri Dec 30 10:48:38 UTC 2016


Thanks Robert Johnson,  great guitarist ;) but i dont want to read log
files.

Now y try to read the websocket but the return is, "error": "missing
secret". I read the doc but i dont understand what is this secret ???

t=$(/usr/bin/curl  -s -k --cert .config/lxc/client.crt --key
.config/lxc/client.key
https://localhost:8443/1.0/containers/wondrous-mackerel/exec -X POST -d
'{"command": ["/bin/df"], "wait-for-websocket": true, "interactive": false
}'|jq .|grep operation |awk -F " " '{print $NF}'| tr -d '"');/usr/bin/curl
 -s -k --cert .config/lxc/client.crt --key .config/lxc/client.key
https://localhost:8443$t/websocket|jq .

{
  "error": "missing secret",
  "error_code": 500,
  "type": "error"
}


2016-12-23 18:47 GMT+01:00 Robert Johnson <robert.j at bendtel.com>:

> I've been working on obtaining two way communications with the /exec URI,
> but your needs may more simple then mine.
>
> When you POST to /exec, you probably want to include the 'record-output'
> key with a (boolean) value of true. ie
>
> '{"command": ["df -f /"], "record-output": true}'
>
> The doc's state that stdout and stderr will be redirected to a log file.
>
> It doesn't state where the log file is; but I'm willing to bet that the
> reply will include a path that you can subsequently GET.
>
> If this works for you, let me know, I'm interested in at least obtaining
> the output from some commands.
>
> On 12/23/2016 05:02 AM, laurent ducos wrote:
>
>> Hello.
>>
>> Is there a solution to get the return of a command launch by lxd exec API
>> ?
>>
>> curl -s --unix-socket /var/lib/lxd/unix.socket
>> a/1.0/containers/$CONTAINER/exec -X POST -d '{"command": ["df -f /"]}' |
>> jq .
>>
>> I would like to see something like this in return of the command.
>>
>> output: /dev/sda5           15G    4,6G  9,8G  32% /
>>
>>
>> _______________________________________________
>> lxc-users mailing list
>> lxc-users at lists.linuxcontainers.org
>> http://lists.linuxcontainers.org/listinfo/lxc-users
>>
>> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20161230/e945e6f1/attachment.html>


More information about the lxc-users mailing list