[lxc-devel] [PATCH] lxc-ls: Add interfaces field

Serge Hallyn serge.hallyn at ubuntu.com
Fri Mar 7 21:17:53 UTC 2014


Quoting Stéphane Graber (stgraber at ubuntu.com):
> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

> ---
>  src/lxc/lxc-ls.in | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/lxc-ls.in b/src/lxc/lxc-ls.in
> index 7e35ab2..908a64a 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:
> -- 
> 1.9.0
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list