Skip to content

Commit 8b41fbf

Browse files
committed
CP-54444: Use MAC addresses to find out the mgmt interface.
The interface-rename functionality will be deprecated. Consequently, the names of the network interfaces will not be renamed as eth<N>. To setup the host installer's own networking, it can not use the name of management interface in product since the name is returned from networkd_db command and will not present in the new host installer's running environment. The solution is to use MAC address to find the interface. This also requires the networkd_db change to return the MAC address. Signed-off-by: Ming Lu <[email protected]>
1 parent e86cdb7 commit 8b41fbf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

product.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,20 @@ def fetchIfaceInfoFromNetworkdbAsDict(bridge, iface=None):
268268
if not d.get('interfaces') and 'parent' in d:
269269
p = fetchIfaceInfoFromNetworkdbAsDict(d['parent'])
270270
d['interfaces'] = p['interfaces']
271+
d['hwaddrs'] = p.get('hwaddrs')
271272

272273
results['net-admin-bridge'] = mgmt_iface
273-
results['net-admin-interface'] = d.get('interfaces').split(',')[0]
274+
hwaddrs = d.get('hwaddrs')
275+
if hwaddrs:
276+
net_admin_ifaces = []
277+
nics = [(name, netutil.getHWAddr(name)) for name in netutil.getNetifList()]
278+
for mac in hwaddrs.lower().split(','):
279+
net_admin_ifaces.extend([name for (name, hwaddr) in nics if mac == hwaddr])
280+
if not net_admin_ifaces:
281+
raise SettingsNotAvailable("Could not find any net admin interface")
282+
results['net-admin-interface'] = net_admin_ifaces[0]
283+
else:
284+
results['net-admin-interface'] = d.get('interfaces').split(',')[0]
274285

275286
if_hwaddr = netutil.getHWAddr(results['net-admin-interface'])
276287

0 commit comments

Comments
 (0)