> Subject: Re: Help with adding wifi connections with python
> From: awilliam whitemice org > To: networkmanager-list gnome org > Date: Mon, 20 Feb 2012 08:27:30 -0500 > > On Sun, 2012-02-19 at 11:02 +0000, Jonas Vikstrom wrote: > > Hello, > > I am trying to move from wicd to network-manager and from a python > > point of view it is not easy. > > I have found a number of libraries but non of them works with Ubuntu > > 11.10 (nm 0.9). > > (the project is wireless manager for xbmc) > > These examples are great > > http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python > > But do not cover more then one example of security setup. > > I have reviewed the code for nmcli but it does not cover create > > connections. > > I am now pretty close by using this example from this list > > http://osdir.com/ml/networkmanager-list/2010-07/msg00107.html > > It exectutes fine with sudo but the password is not set. I have no > > clue how to find more information and I really need some examples. > > s_con = { 'id': 'XXX', 'uuid': '5ef2d781-1197-44eb-8744-cd78b9c07315', > > 'type': '802-11-wireless', 'autoconnect': False, 'name': > > 'connection' } > > s_wifi = { 'ssid': dbus.ByteArray("XXX"), 'mode': 'infrastructure', > > 'security': '802-11-wireless-security', 'name': '802-11-wireless' } > > s_wsec = { 'key-mgmt': 'wpa-psk', 'wpa-key': 'xxx', 'name': > > '802-11-wireless-security' } > > s_ip4 = { 'method': 'auto', 'name': 'ipv4' } > > con = { 'connection': s_con, '802-11-wireless': s_wifi, > > '802-11-wireless-security': s_wsec, 'ipv4': s_ip4 } > > Is the password set by NetworkManager or does NetworkManager use the > GNOME keyring for the passwords? > > I don't know, but I'd check that out. > I think you are rigth. By chance I found this
------------------------------------------------
This function lists all the connections uuid that network manager manages.
The next step is to create an entry on gnome-keyring that can be done with the python command gk.item_create_sync('login', gk.ITEM_NETWORK_PASSWORD, 'Network secret for <your network name>/802-11-wireless-security/psk', {'connection-uuid': 'f63e5eae-2090-4639-a894-38f10006ccc9', 'setting-key':'psk', 'setting-name': '802-11-wireless-security'}, '<network key>', True) 'login' is the keyring name
gk.ITEM_NETWORK_PASSWORD is the type of the item being added 'Network secret for <your network name>/802-11-wireless-security/psk' is any string used to identify. I used the model seen on seahorse application. {'connection-uuid': 'f63e5eae-2090-4639-a894-38f10006ccc9', 'setting-key':'psk', 'setting-name': '802-11-wireless-security'} are the attributes. As far as i noted, network manager uses connection-uuid to know if that connection already has a password stored. <network key> is wep, wpa key to your network 'True' updates any other entry already existent ------------------------------------------------------
I have downloaded the source code for nm-connection-editor but I am not sure it is very realistic to go through it. nmcli is like reading a book in comparision. //J
> > This is how far I am nowbefore adding functionality to create > > connections. > > http://dl.dropbox.com/u/17892827/xbmc/vikjon0-py-nm.py > > http://forum.xbmc.org/showthread.php?t=119592 > > > -- > System & Network Administrator [ LPI & NCLA ] > <http://www.whitemiceconsulting.com> > OpenGroupware Developer <http://www.opengroupware.us> > Adam Tauno Williams > > _______________________________________________ > networkmanager-list mailing list > networkmanager-list gnome org > http://mail.gnome.org/mailman/listinfo/networkmanager-list |