diff options
| author | Michael Biebl <biebl@debian.org> | 2015-01-22 00:29:39 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2015-01-22 00:29:39 +0100 |
| commit | 2c032d8f1c6292c1338a615e6ec40252889ba85c (patch) | |
| tree | 1f77182220b2b0264288ba4a476ab47e5bc48716 /examples/python/dbus/add-connection.py | |
| parent | 33491bc4279481db8ae47213e34a6d695a0e8830 (diff) | |
Imported Upstream version 1.0.0 upstream/1.0.0
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 6df14c10..5ebb82a3 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'}) |