1- Welcome to python-networkmanager's documentation!
2- =================================================
1+ Python API to talk to NetworkManager
2+ ====================================
33
4- python-networkmanager wraps NetworkManagers D-Bus interface so you can be less
5- verbose when talking to NetworkManager from python. All interfaces have been
6- wrapped in classes, properties are exposed as python properties and function
7- calls are forwarded to the correct interface .
4+ NetworkManager provides a detailed and capable D-Bus interface on the system
5+ bus. You can use this interface to query NetworkManager about the overall state
6+ of the network and details of network devices like current IP addresses or DHCP
7+ options, and to activate and deactivate network connections .
88
9- I wrote it to reduce a 100-line python script to 50 lines. Not realizing that
10- the library has more lines than the ones I removed. Oh well 😊
9+ python-networkmanager takes this D-Bus interface and wraps D-Bus interfaces in
10+ classes and D-Bus properties in python properties. It also provides a
11+ command-line utility to inspect the configuration and (de-)activate
12+ connections.
1113
12- As of version 0.9.2, python-networkmanager also ships a command-line utility
13- called n-m, which allows you to manipulate NetworkManager's state from the
14- command line.
15-
16- :mod: `NetworkManager ` -- Easy communication with NetworkManager
17- ---------------------------------------------------------------
14+ The :mod: `NetworkManager ` module
15+ --------------------------------
1816.. module :: NetworkManager
19- :platform: Linux systems with NetworkManager 0.90
20- :synopsis: Talk to NetworkManager without being verbose
17+ :platform: Linux systems with NetworkManager 0.9.x
18+ :synopsis: Talk to NetworkManager from python
2119
2220All the code is contained in one module: :mod: `NetworkManager `. Using it is as
2321simple as you think it is:
@@ -26,20 +24,33 @@ simple as you think it is:
2624
2725 >> > import NetworkManager
2826 >> > NetworkManager.NetworkManager.Version
29- ' 0.9.1.90 '
27+ ' 0.9.6.0 '
3028
3129 NetworkManager exposes a lot of information via D-Bus and also allows full
3230control of network settings. The full D-Bus API can be found on `NetworkManager
3331project website `_. All interfaces listed there have been wrapped in classes as
34- listed below.
32+ listed below. With a few exceptions, they behave exactly like the D-Bus
33+ methods. These exceptions are for convenience and limited to this list:
34+
35+ * IP addresses are returned as strings of the form :data: `1.2.3.4 ` instead of
36+ network byte ordered integers.
37+ * Route metrics are returned in host byte order, so you can use them as
38+ integers.
39+ * Mac addresses and BSSIDs are always returned as strings of the form
40+ :data: `00:11:22:33:44:55 ` instead of byte sequences.
41+ * Wireless SSID's are returned as strings instead of byte sequences. They will
42+ be decoded as UTF-8 data, so using any other encoding for your SSID will
43+ result in errors.
3544
3645.. class :: NMDbusInterface
3746
3847This is the base class for all interface wrappers. It adds a few useful
3948features to standard D-Bus interfaces:
4049
4150* All D-Bus properties are exposed as python properties
42- * Return values are automatically unwrapped (so no more :data: `dbus.String `)
51+ * Return values are automatically converted to python basic types (so no more
52+ :data: `dbus.String `, but simple :data: `str ` (python 3) or :data: `unicode `
53+ (python 2))
4354* Object paths in return values are automatically replaced with proxy objects,
4455 so you don't need to do that manually
4556* ...and vice versa when sending
@@ -48,7 +59,7 @@ features to standard D-Bus interfaces:
4859.. function :: const(prefix, value)
4960
5061Many of NetworkManagers D-Bus methods expect or return numeric constants, for
51- which there are enums in teh C sourece code only . These constants, such as
62+ which there are enums in the C source code. These constants, such as
5263:data: `NM_STATE_CONNECTED_GLOBAL `, can all be found in the
5364:mod: `NetworkManager ` module as well. The :func: `const ` function can help you
5465translate them to text. For example:
@@ -60,7 +71,7 @@ translate them to text. For example:
6071 >> > NetworkManager.const(' device_type' , 2 )
6172 ' wifi'
6273
63- .. _`NetworkManager project website` : http:// projects.gnome.org/NetworkManager/developers/migrating-to- 09/spec.html
74+ .. _`NetworkManager project website` : projects.gnome.org/NetworkManager/developers/api/ 09/spec.html
6475
6576List of classes
6677---------------
@@ -102,9 +113,19 @@ interface.
102113
103114.. class :: Bluetooth
104115
116+ .. class :: OlpcMesh
117+
105118.. class :: Wimax
106119
107- .. class :: OlpcMesh
120+ .. class :: Infiniband
121+
122+ .. class :: Bond
123+
124+ .. class :: Bridge
125+
126+ .. class :: Vlan
127+
128+ .. class :: Adsl
108129
109130These classes represent D-Bus interfaces for various types of hardware. Note
110131that methods such as :data: `NetworkManager.GetDevices() ` will only return
@@ -118,30 +139,50 @@ that methods such as :data:`NetworkManager.GetDevices()` will only return
118139 [(' eth0' , ' Wired' ), (' wlan0' , ' Wireless' ), (' wwan0' , ' Modem' )]
119140
120141 .. class :: IP4Config
142+
121143.. class :: IP6Config
122144
145+ .. class :: DHCP4Config
146+
147+ .. class :: DHCP6Config
148+
123149These classes represent the various IP configuration interfaces.
124150
151+ .. class :: AgentManager
152+
153+ .. class :: SecretAgent
154+
155+ Classes that can be used to handle and store secrets. Note that these are not
156+ for querying NetworkManager's exisiting secret stores. For that the
157+ :func: `GetSecrets ` method of the :class: `Connection ` class can be used.
158+
125159.. class :: VPNConnection
126160
127161This class represents the :data: `org.freedesktop.NetworkManager.VPN.Connection `
128162interface.
129163
164+ .. class :: VPNPlugin
165+
166+ A class that can be used to query VPN plugins.
167+
130168.. toctree ::
131169 :maxdepth: 2
132170
133171The n-m utility
134172---------------
135- n-m is a command-line tool to deal with network-manager. It can connect you to
136- defined networks and disconnect you again.
137-
138- Usage: [options] action [arguments]
139-
140- Actions:
141- list - List all defined and active connections
142- activate - Activate a connection
143- deactivate - Deactivate a connection
144- offline - Deactivate all connections
145- enable - Enable specific connection types
146- disable - Disable specific connection types
147- info - Information about a connection
173+ n-m is a command-line tool to interact with NetworkManager. With it, you can
174+ inspect various configuration items and (de-)activate connections.
175+
176+ Usage: [options] action [arguments]
177+
178+ Actions:
179+ list - List all defined and active connections
180+ activate - Activate a connection
181+ deactivate - Deactivate a connection
182+ offline - Deactivate all connections
183+ enable - Enable specific connection types
184+ disable - Disable specific connection types
185+ info - Information about a connection
186+ dump - Dump a python hash of connection information, suitable for
187+ creating new connections
188+
0 commit comments