diff options
Diffstat (limited to 'examples/python/dbus/add-connection.py')
-rwxr-xr-x | examples/python/dbus/add-connection.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/examples/python/dbus/add-connection.py b/examples/python/dbus/add-connection.py index 6df14c103c..5ebb82a38b 100755 --- a/examples/python/dbus/add-connection.py +++ b/examples/python/dbus/add-connection.py @@ -18,20 +18,17 @@ # # -# This example adds a new ethernet connection via AddConnection() D-Bus call. +# This example adds a new ethernet connection via the AddConnection() +# D-Bus call, using the new 'ipv4.address-data' and 'ipv4.gateway' +# settings introduced in NetworkManager 1.0. Compare +# add-connection-compat.py, which will work against older versions of +# NetworkManager as well. # # Configuration settings are described at -# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html +# https://developer.gnome.org/NetworkManager/1.0/ref-settings.html # -import socket, struct, dbus, uuid - -# Helper functions -def ip_to_int(ip_string): - return struct.unpack("=I", socket.inet_aton(ip_string))[0] - -def int_to_ip(ip_int): - return socket.inet_ntoa(struct.pack("=I", ip_int)) +import dbus, uuid s_wired = dbus.Dictionary({'duplex': 'full'}) s_con = dbus.Dictionary({ @@ -39,9 +36,12 @@ s_con = dbus.Dictionary({ 'uuid': str(uuid.uuid4()), 'id': 'MyConnectionExample'}) -addr1 = dbus.Array([ip_to_int("10.1.2.3"), dbus.UInt32(8L), ip_to_int("10.1.2.1")], signature=dbus.Signature('u')) +addr1 = dbus.Dictionary({ + 'address': '10.1.2.3', + 'prefix': dbus.UInt32(8L)}) s_ip4 = dbus.Dictionary({ - 'addresses': dbus.Array([addr1], signature=dbus.Signature('au')), + 'address-data': dbus.Array([addr1], signature=dbus.Signature('a{sv}')), + 'gateway': '10.1.2.1', 'method': 'manual'}) s_ip6 = dbus.Dictionary({'method': 'ignore'}) |