summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-05-12 18:50:45 +0200
committerThomas Haller <thaller@redhat.com>2021-05-14 10:53:09 +0200
commit86e99fca6bf7bba564365e94b8b904edd650207a (patch)
treea60a830b04e9fdda0472a76bf6d2d0d040ae9195
parent5f939cc1cb51aea9387a21df2b191f7b708234a9 (diff)
downloadNetworkManager-86e99fca6bf7bba564365e94b8b904edd650207a.tar.gz
examples: avoid deprecated PropertiesChanged signal in "create-bond.py" example
-rwxr-xr-xexamples/python/dbus/create-bond.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/examples/python/dbus/create-bond.py b/examples/python/dbus/create-bond.py
index 4ebec24a6c..fe35fcc0ba 100755
--- a/examples/python/dbus/create-bond.py
+++ b/examples/python/dbus/create-bond.py
@@ -40,8 +40,8 @@ def create_bond(bond_name):
"autoconnect-slaves": 1,
}
)
- s_ip4 = dbus.Dictionary({"method": "auto"})
- s_ip6 = dbus.Dictionary({"method": "ignore"})
+ s_ip4 = dbus.Dictionary({"method": "disabled"})
+ s_ip6 = dbus.Dictionary({"method": "disabled"})
con = dbus.Dictionary(
{"bond": s_bond, "connection": s_con, "ipv4": s_ip4, "ipv6": s_ip6}
@@ -97,18 +97,22 @@ print("Activating bond: %s (%s)" % (bond_name, ac))
loop = GLib.MainLoop()
-def properties_changed(props):
- if "State" in props:
- if props["State"] == 2:
+def properties_changed(interface_name, changed_properties, invalidated_properties):
+ if (
+ interface_name == "org.freedesktop.NetworkManager.Connection.Active"
+ and "State" in changed_properties
+ ):
+ state = changed_properties["State"]
+ if state == 2:
print("Successfully connected")
loop.quit()
- if props["State"] == 3 or props["State"] == 4:
+ if state == 3 or state == 4:
print("Bond activation failed")
loop.quit()
obj = bus.get_object("org.freedesktop.NetworkManager", ac)
-iface = dbus.Interface(obj, "org.freedesktop.NetworkManager.Connection.Active")
+iface = dbus.Interface(obj, "org.freedesktop.DBus.Properties")
iface.connect_to_signal("PropertiesChanged", properties_changed)
loop.run()