mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-13 06:10:20 +01:00
test/nm-service: create Vlan devices matching the parent by hwaddr
This is how OCI VLANS will be looking up their parents. Make sure the mock is able to deal with this.
This commit is contained in:
parent
884e474114
commit
cb17b73ff6
1 changed files with 49 additions and 3 deletions
|
|
@ -1725,7 +1725,6 @@ class NetworkManager(ExportedObj):
|
|||
out_signature="ooa{sv}",
|
||||
)
|
||||
def AddAndActivateConnection2(self, con_hash, devpath, specific_object, options):
|
||||
device = self.find_or_create_device(devpath, con_hash)
|
||||
conpath = gl.settings.AddConnection(con_hash)
|
||||
return (conpath, self.ActivateConnection(conpath, devpath, specific_object), [])
|
||||
|
||||
|
|
@ -1862,8 +1861,55 @@ class NetworkManager(ExportedObj):
|
|||
return self.find_device_first(dev_type=WifiDevice)
|
||||
|
||||
if con_type == NM.SETTING_VLAN_SETTING_NAME:
|
||||
ifname = con_hash[NM.SETTING_CONNECTION_SETTING_NAME]["interface-name"]
|
||||
device = VlanDevice(ifname)
|
||||
|
||||
iface = con_hash[NM.SETTING_CONNECTION_SETTING_NAME].get("interface-name")
|
||||
parent_iface = con_hash[NM.SETTING_VLAN_SETTING_NAME].get("parent")
|
||||
mac = con_hash[NM.SETTING_WIRED_SETTING_NAME].get("mac-address")
|
||||
if mac is not None:
|
||||
parent_hwaddr = "%02X:%02X:%02X:%02X:%02X:%02X" % (
|
||||
mac[0],
|
||||
mac[1],
|
||||
mac[2],
|
||||
mac[3],
|
||||
mac[4],
|
||||
mac[5],
|
||||
)
|
||||
|
||||
parent_ident = parent_iface if parent_iface is not None else _DEFAULT_ARG
|
||||
parent_device = self.find_device_first(
|
||||
dev_type=WiredDevice, hwaddr=parent_hwaddr, ident=parent_ident
|
||||
)
|
||||
if parent_device is None:
|
||||
parent_device = self.find_device_first(
|
||||
dev_type=MacvlanDevice, hwaddr=parent_hwaddr, ident=parent_ident
|
||||
)
|
||||
if parent_device is None:
|
||||
raise BusErr.UnknownDeviceException("Parent device not found")
|
||||
|
||||
if parent_hwaddr is None:
|
||||
parent_hwaddr = parent_device.hwaddr
|
||||
|
||||
mac = con_hash[NM.SETTING_WIRED_SETTING_NAME].get("cloned-mac-address")
|
||||
if mac is not None:
|
||||
hwaddr = "%02X:%02X:%02X:%02X:%02X:%02X" % (
|
||||
mac[0],
|
||||
mac[1],
|
||||
mac[2],
|
||||
mac[3],
|
||||
mac[4],
|
||||
mac[5],
|
||||
)
|
||||
|
||||
if parent_iface is None:
|
||||
parent_iface = parent_device.ident
|
||||
|
||||
if iface is None:
|
||||
iface = "%s.%d" % (
|
||||
parent_iface,
|
||||
con_hash[NM.SETTING_VLAN_SETTING_NAME]["id"],
|
||||
)
|
||||
|
||||
device = VlanDevice(iface, mac=hwaddr)
|
||||
self.add_device(device)
|
||||
return device
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue