summaryrefslogtreecommitdiff
path: root/tools/test-networkmanager-service.py
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-12-20 07:48:31 +0100
committerThomas Haller <thaller@redhat.com>2019-01-13 15:28:05 +0100
commit911bd3603ce7d722e56dc1f54d78a28c0da10d19 (patch)
tree031618985e2d1e862510ce39ca5d6a112d23d72a /tools/test-networkmanager-service.py
parentcb29fbf1756116d4a38c5e04352fbf097ebb9788 (diff)
downloadNetworkManager-th/add-and-activate2-api.tar.gz
all: return output dictionary from "AddAndActivate2"th/add-and-activate2-api
Add a "a{sv}" output argument to "AddAndActivate2" D-Bus API. "AddAndActivate2" replaces "AddAndActivate" with more options. It also has a dictionary argument to be forward compatible so that we hopefully won't need an "AddAndActivate3". However, it lacked a similar output dictionary. Add it for future extensibility. I think this is really to workaround a shortcoming of D-Bus, which does provide strong typing and type information about its API, but does not allow to extend an existing API in a backward compatible manner. So we either resort to Method(), Method2(), Method3() variants, or a catch-all variant with a generic "a{sv}" input/output argument. In libnm, rename "nm_client_add_and_activate_connection_options()" to "nm_client_add_and_activate_connection2()". I think libnm API should have an obvious correspondence between D-Bus API. Or stated differently, if "AddAndActivateOptions" would be a better name, then the D-Bus API should be renamed. We should prefer one name over the other, but regardless of which is preferred, the naming for D-Bus and libnm API should correspond. In this case, I do think that AddAndActivate2() is a better name than AddAndActivateOptions(). Hence I rename the libnm API. Also, unless necessary, let libnm still call "AddAndActivate" instead of "AddAndActivate2". Our backward compatibility works the way that libnm requires a server version at least as new as itself. As such, libnm theoretically could assume that server version is new enough to support "AddAndActivate2" and could always use the more powerful variant. However, we don't need to break compatibility intentionally and for little gain. Here, it's easy to let libnm also handle old server API, by continuing to use "AddAndActivate" for nm_client_add_and_activate_connection(). Note that during package update, we don't restart the currently running NetworkManager instance. In such a scenario, it can easily happen that nmcli/libnm is newer than the server version. Let's try a bit harder to not break that. Changes as discussed in [1]. [1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/37#note_79876
Diffstat (limited to 'tools/test-networkmanager-service.py')
-rwxr-xr-xtools/test-networkmanager-service.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py
index 76601d0172..7d9eceb848 100755
--- a/tools/test-networkmanager-service.py
+++ b/tools/test-networkmanager-service.py
@@ -1341,15 +1341,14 @@ class NetworkManager(ExportedObj):
@dbus.service.method(dbus_interface=IFACE_NM, in_signature='a{sa{sv}}oo', out_signature='oo')
def AddAndActivateConnection(self, con_hash, devpath, specific_object):
- return self.AddAndActivateConnection2(con_hash, devpath, specific_object, dict())
+ conpath, acpath, result = self.AddAndActivateConnection2(con_hash, devpath, specific_object, dict())
+ return (conpath, acpath)
- @dbus.service.method(dbus_interface=IFACE_NM, in_signature='a{sa{sv}}ooa{sv}', out_signature='oo')
+ @dbus.service.method(dbus_interface=IFACE_NM, in_signature='a{sa{sv}}ooa{sv}', out_signature='ooa{sv}')
def AddAndActivateConnection2(self, con_hash, devpath, specific_object, options):
- # TODO: Do some processing of the "options" parameter.
-
device = self.find_device_first(path = devpath, require = BusErr.UnknownDeviceException)
conpath = gl.settings.AddConnection(con_hash)
- return (conpath, self.ActivateConnection(conpath, devpath, specific_object))
+ return (conpath, self.ActivateConnection(conpath, devpath, specific_object), [])
@dbus.service.method(dbus_interface=IFACE_NM, in_signature='o', out_signature='')
def DeactivateConnection(self, active_connection):