diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py index a072a8d6931b..4f5893ecaa80 100644 --- a/cloudinit/net/__init__.py +++ b/cloudinit/net/__init__.py @@ -90,6 +90,16 @@ def is_vlan(devname): uevent = str(read_sys_net_safe(devname, "uevent")) return 'DEVTYPE=vlan' in uevent.splitlines() +def is_hv_nic(devname): + path = sys_dev_path(devname, "device/driver") + if not os.path.exists(path): + return false + return os.path.basename(os.readlink(path)) == "hv_netvsc" + + +def is_hv_mac(mac): + return mac.find("00:15:5d:") == 0 + def is_connected(devname): # is_connected isn't really as simple as that. 2 is @@ -404,6 +414,9 @@ def get_interfaces_by_mac(): # some devices may not have a mac (tun0) if not mac: continue + # on hyper-v skip synthetic NIC with paired VF + if is_hv_nic(name) and not is_hv_mac(mac) + continue if mac in ret: raise RuntimeError( "duplicate mac found! both '%s' and '%s' have mac '%s'" %