Re: Creating NetworkManager connections via DBus API

On Fri, 2014-07-04 at 09:18 +1000, Stuart Longland wrote:
Hi all,

I'm in the process of writing a web frontend for a small Linux-based
appliance, thus am in need of a tool for configuring the network interfaces.

NetworkManager seems to be a good fit in that it supports a wide variety
of networks and runs as a daemon which is then accessed by unprivileged
users.  The web front-end software we're writing is based on Django, and
I'm creating a collection of models which will represent the
configuration of the network interface.  There's a nice Python library;
python-networkmanager which provides an abstraction ontop of DBus so
accessing NetworkManager isn't too painful.

So my task now, is knowing the name of a network device, its intended IP
address, routes, DNS configuration, etc, is to figure out how to tell
NetworkManager about it and get it to connect.

Now, there's a DBus spec which describes the objects here:

Great.  By the looks of things, I create a
org.freedesktop.NetworkManager.Settings.Connection object, then hand
that to org.freedesktop.NetworkManager's ActivateConnection method.

But how do I encode my address settings in a Settings.Connection object?
 Where do I find a list of the settings and their possible values?


There's actually a bunch of Python examples here:

that use both plain dbus and Python GObject introspection.  The GObject
introspection ones are similar to python-networkmanager actually.  I'm
not sure how python-networkmanager accepts a new connection to add, but
perhaps the examples give you an idea how to do that?  I'd expect it to
be a normal "dict of dicts" like the examples above show which is then
passed to org.freedesktop.NetworkManager.Settings.AddConnection().

Let me know if this helps, happy to answer any more questions you might


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]