support the case of no enp0 if is present

if seems on ionopimax, with predictable network IF on, the
main (only) interface is named enx....... instead of end0
this is a fix to support it
This commit is contained in:
2025-08-21 15:45:42 +02:00
parent 327496553d
commit 206d58ea91
3 changed files with 16 additions and 6 deletions

View File

@@ -98,6 +98,14 @@ class BoxInfo:
if ifname in ('eth0', 'enp1s0', 'end0'):
macaddr = addr
self.main_if = ifname
if self.main_if is None:
if len(self.network_interfaces) == 1:
self.main_if = list(self.network_interfaces)[0]
macaddr = self.network_interfaces[self.main_if]
elif self.network_interfaces:
raise RuntimeError(f'ambiguous main if: {self.network_interfaces}')
else:
raise RuntimeError('no main if found')
self.macaddr = macaddr
if macaddr:
self.id = int(''.join(macaddr.split(':')[-3:]), 16) & 0xffffff