[lxc-users] Wildcard in lxd commands?
Will wildcards be supported in lxd commands? For example, I'd like to do this: $ lxc info host:* or $ lxc info host:web* and get info on all containers/containers starting with "web" on host. Is there a quick/easy way to do something similar now? ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] Wildcard in lxd commands?
On 2016-03-16 11:12, Serge Hallyn wrote: Quoting zzt...@openmailbox.org (zzt...@openmailbox.org): Will wildcards be supported in lxd commands? For example, I'd like to do this: $ lxc info host:* or $ lxc info host:web* and get info on all containers/containers starting with "web" on host. Is there a quick/easy way to do something similar now? See 'lxc help list'. Filters should get you what you want. ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users How would I use that in a command? For example would I stop dozens of containers whose names begin with "web" using the filter? ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] Wildcard in lxd commands?
2016-03-17 10:01 GMT-03:00 Janne Savikko : > > $ lxc list web|grep RUNNING|awk '{ print $2 }'|xargs lxc stop > > This is why lxc (not lxd) is BETTER for sysadmins: # lxc-ls --running | xargs -n1 lxc-stop -n and docker is even better: # docker ps -q | docker stop ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] Wildcard in lxd commands?
On 03/17/2016 01:03 AM, zzt...@openmailbox.org wrote: On 2016-03-16 11:12, Serge Hallyn wrote: Quoting zzt...@openmailbox.org (zzt...@openmailbox.org): Will wildcards be supported in lxd commands? For example, I'd like to do this: $ lxc info host:* or $ lxc info host:web* and get info on all containers/containers starting with "web" on host. Is there a quick/easy way to do something similar now? See 'lxc help list'. Filters should get you what you want. How would I use that in a command? For example would I stop dozens of containers whose names begin with "web" using the filter? lxc list is not the easiest to parse (https://github.com/lxc/lxd/issues/882). List uses tablewriter (https://github.com/olekukonko/tablewriter) to format output, but it does not have option to output e.g. CSV (sure you can use comma as a column separator, but you get whitespaces because columns data is variable length). You can not use filters to list running or stopped containers. Lxc start or stop do not support filters, only container name (or names). You though can always pipe commands if you want to stop dozens of containers whose names begin with "web" (note! lxc list keyword filter compares from the start of the name, so "lxc list eb" does not work in this case): $ lxc list web|grep RUNNING|awk '{ print $2 }'|xargs lxc stop ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] Wildcard in lxd commands?
On 17/03/16 23:01, Janne Savikko wrote: You can not use filters to list running or stopped containers. Lxc start or stop do not support filters, only container name (or names). You though can always pipe commands if you want to stop dozens of containers whose names begin with "web" (note! lxc list keyword filter compares from the start of the name, so "lxc list eb" does not work in this case): $ lxc list web|grep RUNNING|awk '{ print $2 }'|xargs lxc stop It's still rather awkward to reliably script a start/stop of a single container that happens to be called "web" when there might be web1, web2 etc. An explicit non-filtered arg to lxc list with optional regex would be more useful. Plus an option to have plain non-tablewriter output for easier script parsing. [[ `lxc list -cs web` = RUNNING ]]; echo $? ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] Wildcard in lxd commands?
Quoting zzt...@openmailbox.org (zzt...@openmailbox.org): > Will wildcards be supported in lxd commands? For example, I'd like > to do this: > > $ lxc info host:* > > or > > $ lxc info host:web* > > and get info on all containers/containers starting with "web" on host. > > Is there a quick/easy way to do something similar now? See 'lxc help list'. Filters should get you what you want. ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] Wildcard in lxd commands?
On 2016-03-17 07:07, Mark Constable wrote: On 17/03/16 23:01, Janne Savikko wrote: You can not use filters to list running or stopped containers. Lxc start or stop do not support filters, only container name (or names). You though can always pipe commands if you want to stop dozens of containers whose names begin with "web" (note! lxc list keyword filter compares from the start of the name, so "lxc list eb" does not work in this case): $ lxc list web|grep RUNNING|awk '{ print $2 }'|xargs lxc stop It's still rather awkward to reliably script a start/stop of a single container that happens to be called "web" when there might be web1, web2 etc. An explicit non-filtered arg to lxc list with optional regex would be more useful. Plus an option to have plain non-tablewriter output for easier script parsing. [[ `lxc list -cs web` = RUNNING ]]; echo $? ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users I agree. lxc list would be immensely useful if it could output just a list of names or other single attribute of containers that match particular criteria. That could then be fed to a command. Something easy to remember like: lxc list -cn --name=web* --state=running | lxc stop {} ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users