tests: support D-Bus property Device.StateReason in mock service

The device interface (org.freedesktop.NetworkManager.Device) has
two properties: "State" and "StateReason". Both of them are supported by
NetworkManager for a very long time.

Note that "StateReason" is a tuple and also exposes the state along the
reason.

When reworking libnm, we will ignore the "State" property and only
consider "StateReason". The advantage is less code and not using
redundant state. This will also work well, because NetworkManager's
D-Bus API supports this property for a very long time.

However, that would then break the CI tests, because currently
"tools/test-networkmanager-service.py" does not expose that property.

Add it.
This commit is contained in:
Thomas Haller
2019-10-31 16:38:36 +01:00
parent abb68d90fc
commit ec39498fc6

View File

@@ -672,6 +672,7 @@ PRP_DEVICE_UDI = "Udi"
PRP_DEVICE_IFACE = "Interface"
PRP_DEVICE_DRIVER = "Driver"
PRP_DEVICE_STATE = "State"
PRP_DEVICE_STATE_REASON = "StateReason"
PRP_DEVICE_ACTIVE_CONNECTION = "ActiveConnection"
PRP_DEVICE_IP4_CONFIG = "Ip4Config"
PRP_DEVICE_IP6_CONFIG = "Ip6Config"
@@ -700,11 +701,14 @@ class Device(ExportedObj):
self.dhcp4_config = None
self.dhcp6_config = None
self.prp_state = NM.DeviceState.UNAVAILABLE
props = {
PRP_DEVICE_UDI: "/sys/devices/virtual/%s" % (iface),
PRP_DEVICE_IFACE: iface,
PRP_DEVICE_DRIVER: "virtual",
PRP_DEVICE_STATE: dbus.UInt32(NM.DeviceState.UNAVAILABLE),
PRP_DEVICE_STATE: dbus.UInt32(self.prp_state),
PRP_DEVICE_STATE_REASON: dbus.Struct((dbus.UInt32(self.prp_state), dbus.UInt32(NM.DeviceStateReason.NONE))),
PRP_DEVICE_ACTIVE_CONNECTION: ExportedObj.to_path(None),
PRP_DEVICE_IP4_CONFIG: ExportedObj.to_path(self.ip4_config),
PRP_DEVICE_IP6_CONFIG: ExportedObj.to_path(self.ip6_config),