On Tue, 2015-03-03 at 06:28 -0500, Petr Horacek wrote:
> 
> ----- Original Message -----
> > From: "Thomas Haller" <[email protected]>
> > To: "Yegor Yefremov" <[email protected]>
> > Cc: "Petr Horacek" <[email protected]>, "networkmanager." 
> > <[email protected]>
> > Sent: Tuesday, March 3, 2015 12:03:43 PM
> > Subject: Re: D-bus create device, tutorials, resources
> > 
> > On Tue, 2015-03-03 at 10:28 +0100, Yegor Yefremov wrote:
> > > On Tue, Mar 3, 2015 at 10:03 AM, Petr Horacek <[email protected]> wrote:
> > > > Hello folks,
> > > >
> > > > I'm new to NetworkManager, getting familiar with D-bus interface etc.
> > > > I'd like to create a high level Python interface for nm, but I have
> > > > trouble
> > > > with insufficient documentation resources (or my Google skills).
> > > >
> > > > Is there any tutorial or D-bus code example for e.g. creating a bond
> > > > device
> > > > with defined IP? I've found plenty of 'list devices' but nothing like
> > > > this.
> > > 
> > > What's wrong with this project
> > > https://github.com/seveas/python-networkmanager ?
> (Copying from another response:)
> I know this lib, "problem" is, that you still have to handle NetworkManager 
> with
> some strings, dictionaries etc. I would like to do it more Pythonic way, like:
> 
> add_bond(name, slaves), or even better with some context managers and stuff.
> 
> > 
> > 
> > See also,
> > http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python/dbus
> > which are examples for using Python to access the D-Bus interface directly.
> > 
> > 
> > then there is also
> > http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python/gi
> > which uses libnm via gobject introspection. If you want something quick,
> > this might be better. If you want to implement the best possible python
> > NM library, you might don't want to use it.
> > 
> > Note that libnm will always be installed together with NetworkManager,
> > so the additional dependency is not that cumbersome.
> > But libnm was only introduced with nm-1-0, so if you want to support
> > older NM (too), you must use the now deprecated libnm-utils library.
> > http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python/gi?h=nm-0-9-10
> > The deprecated library libnm-utils also works with NM 1.0 and newer, but
> > it is... deprecated.
> > 
> > 
> > The D-Bus API for NM is quite stable, so if you are using D-Bus
> > directly, you should easily be able to support various version of
> > NetworkManager.
> > 
> > 
> > 
> > I didn't look at python-networkmanager, but that might be worth using
> > (and improving) instead of adding yet another wrapper.
> > 
> > 
> > 
> > 
> > Thomas
> > 
> 
> I would love to use D-Bus API, but I don't know what strings should I use for 
> for
> example adding bond and stuff like that. Thanks for links, but I think, i 
> read them all.

NetworkManager is all about connections (i.e. profiles, which basically
are a bunch of key-value dictionaries).

see:
http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python/dbus/add-connection.py


To create a bond setting, populate the dictionary accordingly, most
notably with a different connection.type='bond' entry.

To know which properties are supported, see `man nm-settings`.
Look also what nmcli does, i.e. create a connection there, and see how
it turns out. You can do that for example using d-feet and looking at
the (D-Bus) GetSettings() method.


For example
  $ $ nmcli connection add type bond 

afterwards, GetSettings() returns:

{'bond': {'interface-name': 'nm-bond', 'options': {'mode': 'balance-rr'}},
 'connection': {'id': 'bond',
                'interface-name': 'nm-bond',
                'permissions': [],
                'secondaries': [],
                'type': 'bond',
                'uuid': '38ac844a-670d-4efe-b9a0-a2b53b1abaee'},
 'ipv4': {'address-data': [],
          'addresses': [],
          'dns': [],
          'dns-search': [],
          'method': 'auto',
          'route-data': [],
          'routes': []},
 'ipv6': {'address-data': [],
          'addresses': [],
          'dns': [],
          'dns-search': [],
          'method': 'auto',
          'route-data': [],
          'routes': []}}

The 'bond' dictionary is special, because it contains yet another
dictionary 'options', so you would have to know which options are
supported.


> Improving python-networkmanager could be fine, but i would like to do more
> higher interface, as I mentioned in response to Yegor. Something like
> Python nmcli.

sure!


good luck
Thomas

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

_______________________________________________
networkmanager-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to