Commit 50df4a62 by Stéphane Graber

lxc-ls: Optimize things a bit

Don't bother access information that the user didn't request. Signed-off-by: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 869d48f4
...@@ -244,17 +244,17 @@ def get_containers(fd=None, base="/", root=False): ...@@ -244,17 +244,17 @@ def get_containers(fd=None, base="/", root=False):
continue continue
# Some extra field we may want # Some extra field we may want
if 'state' in args.fancy_format or args.nesting: if 'state' in args.fancy_format:
entry['state'] = state entry['state'] = state
if 'pid' in args.fancy_format or args.nesting: if 'pid' in args.fancy_format:
entry['pid'] = "-" entry['pid'] = "-"
if state == 'UNKNOWN': if state == 'UNKNOWN':
entry['pid'] = state entry['pid'] = state
elif container.init_pid != -1: elif container.init_pid != -1:
entry['pid'] = str(container.init_pid) entry['pid'] = str(container.init_pid)
if 'autostart' in args.fancy_format or args.nesting: if 'autostart' in args.fancy_format:
entry['autostart'] = "NO" entry['autostart'] = "NO"
try: try:
if container.get_config_item("lxc.start.auto") == "1": if container.get_config_item("lxc.start.auto") == "1":
...@@ -308,7 +308,7 @@ def get_containers(fd=None, base="/", root=False): ...@@ -308,7 +308,7 @@ def get_containers(fd=None, base="/", root=False):
# Get the IPs # Get the IPs
for family, protocol in {'inet': 'ipv4', 'inet6': 'ipv6'}.items(): for family, protocol in {'inet': 'ipv4', 'inet6': 'ipv6'}.items():
if protocol in args.fancy_format or args.nesting: if protocol in args.fancy_format:
entry[protocol] = "-" entry[protocol] = "-"
if state == 'UNKNOWN': if state == 'UNKNOWN':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment