Re: Creating NetworkManager connections via DBus API

2014-07-07 Thread Dan Williams
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.

As thomas already mentioned, these should be covered in the API
documentation that he linked.  Note that IPv4 addresses are arrays of
uint32 (address/prefix/optional gateway) and IPv4 routes are too
(network/prefix/next-hop/metric).  The address/network/next-hop IP
address members are network-byte-order.  So the code in Python to push
that into the dict that can be sent over D-Bus is something like this,
taken from:

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

def ip_to_int(ip_string):
return struct.unpack(=I, socket.inet_aton(ip_string))[0]

addr1 = dbus.Array([ip_to_int(10.1.2.3), dbus.UInt32(8L), 
ip_to_int(10.1.2.1)], signature=dbus.Signature('u'))
s_ip4 = dbus.Dictionary({
'addresses': dbus.Array([addr1], signature=dbus.Signature('au')),
'method': 'manual'})
...
con = dbus.Dictionary({
'802-3-ethernet': s_wired,
'connection': s_con,
'ipv4': s_ip4,
'ipv6': s_ip6})

this is mainly because Python doesn't have strongly-typed variables, but
D-Bus does, so you have to tell Python what the mapping is between the
Python types and the D-Bus types.

Dan

 Probably host name too (not sure if that's doable in NetworkManager).
 
 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.
 
 Is there some documentation as to how these various network types are
 specified as dict objects to NetworkManager?
 
 Regards,


___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: ANN: NetworkManager 0.9.10 released

2014-07-07 Thread Derek Atkins
Hey Dan,

Congrats, and excellent work!

Quick question on your 1.0 planning -- has VPN split-DNS with local
caching ever made it back into NM?  Back in the day it was working with
named but it was dropped due to the difficulty in maintaining the named
dbus interface patch.  I missed that feature for a while, and was
wondering if it might come back (if it hasn't already, in which case are
there docs on how to configure it on Fedora)?

Thanks, and again, congrats on 0.9.10.

-derek

Dan Williams d...@redhat.com writes:

 Hi!

 Well, we finally did it.  We released NetworkManager 0.9.10 with all the
 awesome goodness described here:

 http://blogs.gnome.org/dcbw/2014/06/20/well-build-a-dream-house-of-net/

 Grab the tarballs for NetworkManager and the applet/editor here:

 https://download.gnome.org/sources/NetworkManager/0.9/
 https://download.gnome.org/sources/network-manager-applet/0.9/
 (VPN plugins to come...)

 The final 0.9.10 release contains many bug fixes, most notably some
 changes in veth handling, crash fixes, nmtui fixes, ifcfg-rh and keyfile
 settings plugin fixes, Team fixes, translations, Bluez4 pairing fixes,
 and more.  A huge thanks to all of you who helped test the release
 candidates!

 

 Now that we've reached the moon, why not shoot for the stars?  I'm
 talking about NetworkManager 1.0 later this year.  To start with, we're
 planning to enhance VPN capabilities to finally bring multiple
 concurrent VPN/tunnels, runtime configuration API for clients, an even
 leaner footprint, more robust cooperation with external tools, nmcli
 interactivity fixes, connection priorities, porting away from dbus-glib
 to GDBus (finally!), Bluez5 DUN support, and way more greatness.

 But best of all, *we'll be 1.0*!  Nobody thought we'd get here, but 10
 years later, we're gonna finally do this.  Are you ready to party?

 Dan

 ___
 networkmanager-list mailing list
 networkmanager-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/networkmanager-list



-- 
   Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
   Member, MIT Student Information Processing Board  (SIPB)
   URL: http://web.mit.edu/warlord/PP-ASEL-IA N1NWH
   warl...@mit.eduPGP key available
___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: Creating NetworkManager connections via DBus API

2014-07-07 Thread Stuart Longland
Hi Dan,
On 08/07/14 02:55, Dan Williams wrote:
 As thomas already mentioned, these should be covered in the API
 documentation that he linked.  Note that IPv4 addresses are arrays of
 uint32 (address/prefix/optional gateway) and IPv4 routes are too
 (network/prefix/next-hop/metric).  The address/network/next-hop IP
 address members are network-byte-order.  So the code in Python to push
 that into the dict that can be sent over D-Bus is something like this,
 taken from:
[...]
 this is mainly because Python doesn't have strongly-typed variables, but
 D-Bus does, so you have to tell Python what the mapping is between the
 Python types and the D-Bus types.

Yep, just experimenting with python-networkmanager, it seems this is one
of the details it looks after: IP addresses are translated to strings,
endianness is taken care of, etc.  Dicts are plain Python dicts.

Just looking at the documentation there though, am I correct in assuming
that to set up a simple connection, you would have a dict of the form:

{'connection': { global connection settings },
 'ipv4': { IPv4 address settings },
 'ipv6': { IPv6 address settings },
}

and so the 'connection' bit would be mandatory, and you might have *one*
each of the other setting types?

Regards,
-- 
Stuart Longland
Systems Engineer
 _ ___
\  /|_) |   T: +61 7 3535 9619
 \/ | \ | 38b Douglas StreetF: +61 7 3535 9699
   SYSTEMSMilton QLD 4064   http://www.vrt.com.au


___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: Creating NetworkManager connections via DBus API

2014-07-07 Thread Dan Williams
On Tue, 2014-07-08 at 05:55 +1000, Stuart Longland wrote:
 Hi Dan,
 On 08/07/14 02:55, Dan Williams wrote:
  As thomas already mentioned, these should be covered in the API
  documentation that he linked.  Note that IPv4 addresses are arrays of
  uint32 (address/prefix/optional gateway) and IPv4 routes are too
  (network/prefix/next-hop/metric).  The address/network/next-hop IP
  address members are network-byte-order.  So the code in Python to push
  that into the dict that can be sent over D-Bus is something like this,
  taken from:
 [...]
  this is mainly because Python doesn't have strongly-typed variables, but
  D-Bus does, so you have to tell Python what the mapping is between the
  Python types and the D-Bus types.
 
 Yep, just experimenting with python-networkmanager, it seems this is one
 of the details it looks after: IP addresses are translated to strings,
 endianness is taken care of, etc.  Dicts are plain Python dicts.
 
 Just looking at the documentation there though, am I correct in assuming
 that to set up a simple connection, you would have a dict of the form:
 
 {'connection': { global connection settings },
  'ipv4': { IPv4 address settings },
  'ipv6': { IPv6 address settings },
 }
 
 and so the 'connection' bit would be mandatory, and you might have *one*
 each of the other setting types?

The type setting (eg 803-3-ethernet, 802-11-wireless, gsm, cdma,
bluetooth, etc) is required too.  The 'type' setting and the
'connection' setting are the only required ones.  Usually you'd lock the
connection to a MAC address with the type setting, or it would contain
stuff like MTU, SSID, and other hardware-specific stuff, so you can't
really leave it out.

IPv4 and IPv6 are optional if you want automatic (DHCP, PPP/WWAN, etc)
addressing, but obviously if you want static you have to specify one or
both.

Dan

___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: ANN: NetworkManager 0.9.10 released

2014-07-07 Thread Dan Williams
On Mon, 2014-07-07 at 08:24 -0400, Derek Atkins wrote:
 Hey Dan,
 
 Congrats, and excellent work!
 
 Quick question on your 1.0 planning -- has VPN split-DNS with local
 caching ever made it back into NM?  Back in the day it was working with
 named but it was dropped due to the difficulty in maintaining the named
 dbus interface patch.  I missed that feature for a while, and was
 wondering if it might come back (if it hasn't already, in which case are
 there docs on how to configure it on Fedora)?

VPN split DNS does work with the 'dnsmasq' dns plugin if the VPN pushes
a domain back to you, which should be as simple as dns=dnsmasq in the
config file and restarting NM.  There may be complications with some
distro-given default dnsmasq config files though (bind-interfaces
 I think), but since NM spawns dnsmasq itself, you could disable dnsmasq
as a system service to work around that, or remove that config option.
Let me know if that works!

Dan

 Thanks, and again, congrats on 0.9.10.
 
 -derek
 
 Dan Williams d...@redhat.com writes:
 
  Hi!
 
  Well, we finally did it.  We released NetworkManager 0.9.10 with all the
  awesome goodness described here:
 
  http://blogs.gnome.org/dcbw/2014/06/20/well-build-a-dream-house-of-net/
 
  Grab the tarballs for NetworkManager and the applet/editor here:
 
  https://download.gnome.org/sources/NetworkManager/0.9/
  https://download.gnome.org/sources/network-manager-applet/0.9/
  (VPN plugins to come...)
 
  The final 0.9.10 release contains many bug fixes, most notably some
  changes in veth handling, crash fixes, nmtui fixes, ifcfg-rh and keyfile
  settings plugin fixes, Team fixes, translations, Bluez4 pairing fixes,
  and more.  A huge thanks to all of you who helped test the release
  candidates!
 
  
 
  Now that we've reached the moon, why not shoot for the stars?  I'm
  talking about NetworkManager 1.0 later this year.  To start with, we're
  planning to enhance VPN capabilities to finally bring multiple
  concurrent VPN/tunnels, runtime configuration API for clients, an even
  leaner footprint, more robust cooperation with external tools, nmcli
  interactivity fixes, connection priorities, porting away from dbus-glib
  to GDBus (finally!), Bluez5 DUN support, and way more greatness.
 
  But best of all, *we'll be 1.0*!  Nobody thought we'd get here, but 10
  years later, we're gonna finally do this.  Are you ready to party?
 
  Dan
 
  ___
  networkmanager-list mailing list
  networkmanager-list@gnome.org
  https://mail.gnome.org/mailman/listinfo/networkmanager-list
 
 
 


___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: [PATCH 1/1] service: only attempt to load the 'tun' modules if necessary

2014-07-07 Thread Dan Williams
On Fri, 2014-07-04 at 16:27 +0200, Thomas Haller wrote:
 'tun' support might be compiled into the kernel, thus modprobe will
 always fail.
 
 https://mail.gnome.org/archives/networkmanager-list/2014-July/msg00014.html
 
 Signed-off-by: Thomas Haller thal...@redhat.com

Looks good to me.

Dan

 ---
  src/nm-openvpn-service.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c
 index 84968e8..b45eb28 100644
 --- a/src/nm-openvpn-service.c
 +++ b/src/nm-openvpn-service.c
 @@ -1623,7 +1623,8 @@ main (int argc, char *argv[])
   if (debug)
   g_message (nm-openvpn-service (version  DIST_VERSION ) 
 starting...);
  
 - if (system (/sbin/modprobe tun) == -1)
 + if (   !g_file_test (/sys/class/misc/tun, G_FILE_TEST_EXISTS)
 +  (system (/sbin/modprobe tun) == -1))
   exit (EXIT_FAILURE);
  
   plugin = nm_openvpn_plugin_new ();


___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: Creating NetworkManager connections via DBus API

2014-07-07 Thread Stuart Longland
On 08/07/14 07:56, Dan Williams wrote:
 and so the 'connection' bit would be mandatory, and you might have *one*
  each of the other setting types?
 The type setting (eg 803-3-ethernet, 802-11-wireless, gsm, cdma,
 bluetooth, etc) is required too.  The 'type' setting and the
 'connection' setting are the only required ones.  Usually you'd lock the
 connection to a MAC address with the type setting, or it would contain
 stuff like MTU, SSID, and other hardware-specific stuff, so you can't
 really leave it out.

Okay, so there's a setting called type too, that I presume is distinct
from the connection setting's type attribute.  i.e. the minimum
required:

{'connection': {...},
 'type': {...},
 ...}

Where do I find information on this type setting?  Doing a search for
type setting on
https://developer.gnome.org/NetworkManager/0.9/ref-settings.html shows
no matches.

 IPv4 and IPv6 are optional if you want automatic (DHCP, PPP/WWAN, etc)
 addressing, but obviously if you want static you have to specify one or
 both.

Ahh so a minimal one might give a 'connection' object, whose 'interface'
attribute references one of the physical network ports, and it'll just
configure the network via DHCP.
-- 
Stuart Longland
Systems Engineer
 _ ___
\  /|_) |   T: +61 7 3535 9619
 \/ | \ | 38b Douglas StreetF: +61 7 3535 9699
   SYSTEMSMilton QLD 4064   http://www.vrt.com.au
___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list