Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Improve exception handling for listing (#775)
Browse files Browse the repository at this point in the history
This commit improves exception handling for a case when we tried to determine a jail's ip address and failed to parse the output.
Ticket: #65931
  • Loading branch information
sonicaj authored and Brandon Schneider committed Jan 4, 2019
1 parent 539fab0 commit c1b0b59
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions iocage_lib/ioc_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def list_all(self, jails):
ip6 = "-"

# Will be set already by a corrupt jail
status = False
if state != 'CORRUPT':
status, jid = self.list_get_jid(uuid_full)

Expand Down Expand Up @@ -264,12 +265,14 @@ def list_all(self, jails):
"ifconfig", interface, "inet"]
try:
out = su.check_output(full_ip4_cmd)
except su.CalledProcessError as e:
short_ip4 += "(Network Issue)"
full_ip4 = f"DHCP - Network Issue:{e}"
else:
full_ip4 = f"{interface}|" \
f"{out.splitlines()[2].split()[1].decode()}"
full_ip4 = f'{interface}|' \
f'{out.splitlines()[2].split()[1].decode()}'
except (su.CalledProcessError, IndexError) as e:
short_ip4 += '(Network Issue)'
if isinstance(e, su.CalledProcessError):
full_ip4 = f'DHCP - Network Issue: {e}'
else:
full_ip4 = f'DHCP - Failed Parsing: {e}'
elif conf["dhcp"] == "on" and not status:
short_ip4 = "DHCP"
full_ip4 = "DHCP (not running)"
Expand Down

0 comments on commit c1b0b59

Please sign in to comment.