diff options
Diffstat (limited to 'examples/python')
| -rwxr-xr-x | examples/python/dbus/create-bond.py | 18 | ||||
| -rwxr-xr-x | examples/python/dbus/vpn.py | 11 | ||||
| -rwxr-xr-x | examples/python/gi/ovs-external-ids.py | 7 |
3 files changed, 17 insertions, 19 deletions
diff --git a/examples/python/dbus/create-bond.py b/examples/python/dbus/create-bond.py index 4ebec24a..fe35fcc0 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() diff --git a/examples/python/dbus/vpn.py b/examples/python/dbus/vpn.py index f86bf1ad..794fb022 100755 --- a/examples/python/dbus/vpn.py +++ b/examples/python/dbus/vpn.py @@ -10,11 +10,8 @@ # The uuid of the connection to activate CONNECTION_UUID = "c08142a4-00d9-45bd-a3b1-7610fe146374" -# UID to use. Note that NM only allows the owner of the connection to activate it. -# UID=1000 -UID = 0 - -import sys, os, dbus +import dbus +import sys from dbus.mainloop.glib import DBusGMainLoop from gi.repository import GLib @@ -127,10 +124,6 @@ def activate_connection(connection_path, device_path): ) -# Change the UID first if required -if UID != 0: - os.setuid(UID) - # Are we configured? if not len(CONNECTION_UUID): print("missing connection UUID") diff --git a/examples/python/gi/ovs-external-ids.py b/examples/python/gi/ovs-external-ids.py index 63f9695e..3bc9de8f 100755 --- a/examples/python/gi/ovs-external-ids.py +++ b/examples/python/gi/ovs-external-ids.py @@ -68,7 +68,7 @@ def can_sudo(): ).returncode == 0 ) - except: + except Exception: return False @@ -222,7 +222,6 @@ def die_usage(msg): def parse_args(argv): - had_dash_dash = False args = { "mode": MODE_GET, "select_arg": None, @@ -615,7 +614,9 @@ def do_apply(nmc, device, ids_arg, do_test): die("FAILURE to get applied connection after reapply") _print() - connection_print(connection, MODE_APPLY, [], device.get_path(), prefix="AFTER: ") + connection_print( + connection_after, MODE_APPLY, [], device.get_path(), prefix="AFTER: " + ) _print() ovs_print_external_ids("AFTER-OVS-VSCTL: ") |