Re: Creating NetworkManager connections via DBus API



On Fri, 2014-07-04 at 11:51 +1000, Stuart Longland wrote:
Hi Dan,
On 04/07/14 10:51, Dan Williams wrote:
On Fri, 2014-07-04 at 09:18 +1000, Stuart Longland wrote:
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:

http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python

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?

Ahh okay, that's handy.  I'll have a dig through those and see what I
can uncover.

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().

It does appear that way, I tried pulling the information out for my
Ethernet connection and got:
In [9]: conn.GetSettings()
Out[9]: 
{u'bridge': {u'interface-name': u'br0', u'stp': False},
 u'connection': {u'id': u'Bridge Ethernet',
  u'type': u'bridge',
  u'uuid': u'357c4dcf-2600-45fa-8687-05f4c2cb82b4',
  u'zone': u'work'},
 u'ipv4': {u'addresses': [],
  u'dns': [],
  u'may-fail': False,
  u'method': u'auto',
  u'routes': []},
 u'ipv6': {u'addresses': [], u'dns': [], u'method': u'auto', u'routes': []}}

It seems NetworkManager doesn't much like my hand-configured bridge
(won't see its IP address), but that's a side issue.

What I'm curious about is what sorts of keys and values are expected in
that dict of dicts?  At a basic level I need to be able to set IP
addresses, static routes, DNS servers, domain and DNS search order.

Did you see https://wiki.gnome.org/Projects/NetworkManager/Developers ?
especially
https://developer.gnome.org/NetworkManager/0.9/ref-settings.html
(or try `man nm-settings` if you have the manual pages installed)


Probably host name too (not sure if that's doable in NetworkManager).

SaveHostname , see
https://developer.gnome.org/NetworkManager/0.9/spec.html


At least that will be the starting point.  The devices in question we're
setting up will be headless boxes, basically appliances, intended to
poll energy meters in an energy management system and pump the data
elsewhere.

So mostly wired access, there's a couple of places where we have a
bridges and OpenVPN for technical support on some sites and I envisage
some possibly needing cellular 3G support.

No one has approached us with the need for WIFI support, but I bet
someone will some day, thus it'd be useful to know how that's configured
too.

I would say, this *should* all work (without knowing your exact
requirements) 


Is there some documentation as to how these various network types are
specified as dict objects to NetworkManager?


I think above links is a good starting point, otherwise just ask.


Thomas

Attachment: signature.asc
Description: This is a digitally signed message part



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