Permalink
Browse files

Rewrite lxc-ls in python

This rewrite is mostly compatible with the shell version.
--active and -1 still work and behave as they used to.

This adds --running, --stopped and --frozen as state filters.

A new "fancy" view is also implemented (can be used with --fancy) and
will show containers in a column-based interface with the following fields:
 - name
 - state
 - ipv4
 - ipv6
 - pid of init

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
  • Loading branch information...
1 parent 4a85ce2 commit 4e7186c53554cdbf4b4b85568daf84740c120505 @stgraber stgraber committed Nov 21, 2012
Showing with 343 additions and 138 deletions.
  1. +0 −1 .gitignore
  2. +0 −1 configure.ac
  3. +106 −41 doc/lxc-ls.sgml.in
  4. +1 −1 src/lxc/Makefile.am
  5. +236 −0 src/lxc/lxc-ls
  6. +0 −94 src/lxc/lxc-ls.in
View
@@ -50,7 +50,6 @@ src/lxc/lxc-freeze
src/lxc/lxc-info
src/lxc/lxc-init
src/lxc/lxc-kill
-src/lxc/lxc-ls
src/lxc/lxc-monitor
src/lxc/lxc-netstat
src/lxc/lxc-ps
View
@@ -256,7 +256,6 @@ AC_CONFIG_FILES([
src/Makefile
src/lxc/Makefile
src/lxc/lxc-ps
- src/lxc/lxc-ls
src/lxc/lxc-netstat
src/lxc/lxc-checkconfig
src/lxc/lxc-setcap
View
@@ -49,8 +49,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<refsynopsisdiv>
<cmdsynopsis>
<command>lxc-ls</command>
+ <arg choice="opt">-1</arg>
<arg choice="opt">--active</arg>
- <arg choice="opt">ls option</arg>
+ <arg choice="opt">--frozen</arg>
+ <arg choice="opt">--running</arg>
+ <arg choice="opt">--stopped</arg>
+ <arg choice="opt">--fancy</arg>
+ <arg choice="opt">--fancy-format</arg>
+ <arg choice="opt">filter</arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -65,55 +71,96 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<refsect1>
<title>Options</title>
<variablelist>
+ <varlistentry>
+ <term>
+ <option><optional>-1</optional></option>
+ </term>
+ <listitem>
+ <para>
+ Show one entry per line. (default when /dev/stdout isn't a tty)
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
- <term>
- <option><optional>--active</optional></option>
- </term>
- <listitem>
- <para>
- List active containers.
- </para>
- </listitem>
+ <term>
+ <option><optional>--active</optional></option>
+ </term>
+ <listitem>
+ <para>
+ List only active containers (same as --frozen --running).
+ </para>
+ </listitem>
</varlistentry>
<varlistentry>
- <term>
- <option><optional>ls options</optional></option>
- </term>
- <listitem>
- <para>
- The option passed to <command>lxc-ls</command> are the
- same as the <command>ls</command> command.
- </para>
- </listitem>
+ <term>
+ <option><optional>--frozen</optional></option>
+ </term>
+ <listitem>
+ <para>
+ List only frozen containers.
+ </para>
+ </listitem>
</varlistentry>
- </variablelist>
+ <varlistentry>
+ <term>
+ <option><optional>--running</optional></option>
+ </term>
+ <listitem>
+ <para>
+ List only running containers.
+ </para>
+ </listitem>
+ </varlistentry>
- </refsect1>
+ <varlistentry>
+ <term>
+ <option><optional>--stopped</optional></option>
+ </term>
+ <listitem>
+ <para>
+ List only stopped containers.
+ </para>
+ </listitem>
+ </varlistentry>
- <refsect1>
- <title>Examples</title>
- <variablelist>
<varlistentry>
- <term>lxc-ls -l</term>
- <listitem>
- <para>
- list all the container and their permissions.
- </para>
- </listitem>
+ <term>
+ <option><optional>--fancy</optional></option>
+ </term>
+ <listitem>
+ <para>
+ Use a fancy, column-based output.
+ </para>
+ </listitem>
</varlistentry>
<varlistentry>
- <term>lxc-ls --active -1</term>
- <listitem>
- <para>
- list active containers and display the list in one column.
- </para>
- </listitem>
+ <term>
+ <option><optional>--fancy-format</optional></option>
+ </term>
+ <listitem>
+ <para>
+ Comma separate list of column to show in the fancy output.
+ Valid values are: name, state, ipv4, ipv6 and pid
+ Default is: name,state,ipv4,ipv6
+ </para>
+ </listitem>
</varlistentry>
+ <varlistentry>
+ <term>
+ <option><optional>filter</optional></option>
+ </term>
+ <listitem>
+ <para>
+ The filter passed to <command>lxc-ls</command> will be
+ applied to the container name. The format is a regular expression.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
@@ -122,20 +169,38 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<simpara>
<citerefentry>
- <refentrytitle>ls</refentrytitle>
- <manvolnum>1</manvolnum>
+ <refentrytitle>ls</refentrytitle>
+ <manvolnum>1</manvolnum>
</citerefentry>,
</simpara>
- </refsect1>
+ <title>Examples</title>
+ <variablelist>
+ <varlistentry>
+ <term>lxc-ls --fancy</term>
+ <listitem>
+ <para>
+ list all the containers, listing one per line along with its
+ name, state, ipv4 and ipv6 addresses.
+ </para>
+ </listitem>
+ </varlistentry>
- &seealso;
+ <varlistentry>
+ <term>lxc-ls --active -1</term>
+ <listitem>
+ <para>
+ list active containers and display the list in one column.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
<refsect1>
<title>Author</title>
- <para>Daniel Lezcano <email>daniel.lezcano@free.fr</email></para>
+ <para>Stéphane Graber <email>stgraber@ubuntu.com</email></para>
</refsect1>
-
</refentry>
<!-- Keep this comment at the end of the file
View
@@ -87,7 +87,6 @@ liblxc_so_LDADD = -lutil $(CAP_LIBS) $(APPARMOR_LIBS) $(SECCOMP_LIBS) -lrt
bin_SCRIPTS = \
lxc-ps \
lxc-netstat \
- lxc-ls \
lxc-checkconfig \
lxc-setcap \
lxc-setuid \
@@ -99,6 +98,7 @@ bin_SCRIPTS = \
if ENABLE_PYTHON
bin_SCRIPTS += lxc-device
+ bin_SCRIPTS += lxc-ls
bin_SCRIPTS += lxc-start-ephemeral
endif
Oops, something went wrong.

0 comments on commit 4e7186c

Please sign in to comment.