On Sun, 2018-12-23 at 23:41 +0100, Michael Hirmke wrote:
Hi, after a long time I found some time to start the rewrite of my script. There are a few questions remaining, though. If I understood correctly, for a generic script I have to iterate over all existing connections (ListConnections). What I don't understand actually is how to get a relation between the connection settings object and an existing active connection object. Do I have to iterate over all active connections and find a matching uuid? Or do we have a simpler way to get to this relation/information?
Yes, that's one way. Of, if you know already which Device you are interested in, you can get from the device to the active connection to the (settings) connection. best, Thomas
Thx. Bye. Michael. [...]Hi, sounds a bit like you want to perform some action when a particular connection profile activates/deactivates. First, you need to know which a connection profile you care about, that is, you need its /org/freedesktop/NetworkManager/Settings/* path. You need to call GetSettings() on each of the profiles, to match what you are looking for (for example, matching the connection.id). When a connection is activated, it has an active-connection that references it. Usually there is at most one such active-connection, but while re-activating a connection there can be multiple once (one that is about to deactivate, and once that is about to activate). Anyway, you need to monitor these active connections for whether they reference the profile you care about. The Manager's PropertyChanged event for ActiveConnections notifies you when active-connection come to be and cease to exist. The ActiveConnection basically ties the profile to the networking device. and as said, an active VPN connection is a bit odd, they are active- connections too (with an additional org.freedesktop.NetworkManager.VPN.Connection interface). I would inspect the state with the "d-feet" GUI. You could also use libnm via GObject introspection (e.g. from Perl or Python). That might be more convenient to use, then a plain D-Bus library (the latter works of course too). We don't have any perl examples, only Python: https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/pyth on best, Thomas
Attachment:
signature.asc
Description: This is a digitally signed message part