From: Stéphane Graber Date: Fri, 7 Mar 2014 20:20:28 +0000 (-0500) Subject: lxc-ls: Add interfaces field X-Git-Tag: lxc-1.1.0.alpha1~227 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ec38a6dd72091d146e926291116f6223bfda169;p=thirdparty%2Flxc.git lxc-ls: Add interfaces field Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/lxc-ls.in b/src/lxc/lxc-ls.in index 7e35ab26e..908a64a50 100755 --- a/src/lxc/lxc-ls.in +++ b/src/lxc/lxc-ls.in @@ -102,7 +102,7 @@ def get_root_path(path): # Constants -FIELDS = ("name", "state", "ipv4", "ipv6", "autostart", "pid", +FIELDS = ("name", "state", "interfaces", "ipv4", "ipv6", "autostart", "pid", "memory", "ram", "swap") DEFAULT_FIELDS = ("name", "state", "ipv4", "ipv6", "autostart") @@ -323,6 +323,18 @@ def get_containers(fd=None, base="/", root=False): if ips: entry[protocol] = ", ".join(ips) + # Get the interfaces + if 'interfaces' in args.fancy_format: + entry['interfaces'] = "-" + + if state == 'UNKNOWN' or (container.running and + not SUPPORT_SETNS_NET): + entry['interfaces'] = "UNKNOWN" + elif container.running: + interfaces = container.get_interfaces() + if interfaces: + entry['interfaces'] = ", ".join(interfaces) + # Nested containers if args.nesting: if container.running: