mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 05:20:02 +08:00
Ignore error when multiple interfaces are detected
This commit is contained in:
parent
84fa7f35f6
commit
c4f0fafc04
@ -40,8 +40,8 @@ def addr_of(addrs, dev : str) -> ipaddress.IPv4Interface:
|
|||||||
for addr in addrs:
|
for addr in addrs:
|
||||||
if addr['ifname'] != dev:
|
if addr['ifname'] != dev:
|
||||||
continue
|
continue
|
||||||
if len(addr['addr_info']) != 1:
|
#if len(addr['addr_info']) != 1:
|
||||||
raise ValueError('only exactly one address on dev is supported')
|
# raise ValueError('only exactly one address on dev is supported')
|
||||||
info = addr['addr_info'][0]
|
info = addr['addr_info'][0]
|
||||||
return ipaddress.IPv4Interface((info['local'], info['prefixlen']))
|
return ipaddress.IPv4Interface((info['local'], info['prefixlen']))
|
||||||
raise ValueError('dev {0} not found'.format(dev))
|
raise ValueError('dev {0} not found'.format(dev))
|
||||||
@ -50,11 +50,11 @@ def generate_conf(intf_name : str, dns : Iterable[str]) -> str:
|
|||||||
"""Generates a dhcpd config. `intf_name` is the interface to listen on."""
|
"""Generates a dhcpd config. `intf_name` is the interface to listen on."""
|
||||||
with subprocess.Popen(['ip', '-json', 'route'],
|
with subprocess.Popen(['ip', '-json', 'route'],
|
||||||
stdout=subprocess.PIPE) as proc:
|
stdout=subprocess.PIPE) as proc:
|
||||||
routes = json.load(proc.stdout)
|
routes = json.load(proc.stdout)
|
||||||
with subprocess.Popen(['ip', '-json', 'addr'],
|
with subprocess.Popen(['ip', '-json', 'addr'],
|
||||||
stdout=subprocess.PIPE) as proc:
|
stdout=subprocess.PIPE) as proc:
|
||||||
addrs = json.load(proc.stdout)
|
addrs = json.load(proc.stdout)
|
||||||
|
|
||||||
droute = default_route(routes)
|
droute = default_route(routes)
|
||||||
host_addr = addr_of(addrs, droute['dev'])
|
host_addr = addr_of(addrs, droute['dev'])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user