]> git.proxmox.com Git - mirror_lxc.git/commitdiff
lxc-ls: Add interfaces field
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 7 Mar 2014 20:20:28 +0000 (15:20 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 7 Mar 2014 22:18:50 +0000 (17:18 -0500)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc-ls.in

index 7e35ab26ecc8ad9e81941b539ec7c126dcf0d376..908a64a50826824539047df56d37e5bd01809de2 100755 (executable)
@@ -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: