Re: [lxc-users] lxd api return of /1.0/containers//exec
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 15G4,6G 9,8G 32% / ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
[lxc-users] lxd api return of /1.0/containers//exec
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 15G4,6G 9,8G 32% / ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] Pre and post flight checks for container start/stop
Just recently I had similar requirement of making sure NFS is up before starting an LXC container. After some unsuccessful experiments with lxc.hook.pre-start etc I settled upon a systemd solution. If your system happen to use systemd, then e.g. for a container user1 create file /etc/systemd/units/lxc@user1.service: .include /lib/systemd/system/lxc@.service [Unit] After=mnt-nfs-home.mount Requires=mnt-nfs-home.mount [Install] WantedBy=multi-user.target (replace mnt-nfs-home.mount with whatever checks you want), then run: systemctl enable /etc/systemd/units/lxc@user1.service . Deactivation is handled similarly. Of course, you will have to do everything through systemd after that, which is why some people believe it is evil and contagious. -- With Best Regards, Marat Khalili On 23/12/16 08:01, Kees Bos wrote: Hi, Is it possible to do some pre-flight checks before starting a container. E.g. to verify network connectivity before starting the container, or to check in a central 'database' that the container isn't running on a different host and register it? Note, that the preflight check should be able to cancel a startup. And similar on stopping a container execute some commands e.g. yo deactivate registration of the container in the central. Cheers, Kees ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users