1PYTHON-NETWORKMANAGER(1)     python-networkmanager    PYTHON-NETWORKMANAGER(1)
2
3
4

NAME

6       python-networkmanager - python-networkmanager Documentation
7
8       NetworkManager  provides  a detailed and capable D-Bus interface on the
9       system bus. You can use this interface to  query  NetworkManager  about
10       the  overall  state  of the network and details of network devices like
11       current IP addresses or DHCP options, and to  configure,  activate  and
12       deactivate network connections.
13
14       python-networkmanager takes this D-Bus interface and wraps D-Bus inter‐
15       faces in classes and D-Bus  methods  and  properties  in  their  python
16       equivalents.
17

THE NETWORKMANAGER MODULE

19       All the code is contained in one module: NetworkManager. Using it is as
20       simple as you think it is:
21
22          >>> import NetworkManager
23          >>> NetworkManager.NetworkManager.Version
24          '1.2.0'
25
26       NetworkManager exposes a lot of information via D-Bus and  also  allows
27       full control of network settings. The full D-Bus interface can be found
28       on NetworkManager project website. All  interfaces  listed  there  have
29       been wrapped in classes as listed below.
30
31       NetworkManager.const(prefix, value)
32
33       Many  of  NetworkManagers  D-Bus  methods expect or return numeric con‐
34       stants, for which there are enums in the  C  source  code.  These  con‐
35       stants,  such  as  NM_STATE_CONNECTED_GLOBAL,  can  all be found in the
36       NetworkManager module as well. The const() function can help you trans‐
37       late them to text. For example:
38
39          >>> NetworkManager.const('state', 40)
40          'connecting'
41          >>> NetworkManager.const('device_type', 2)
42          'wifi'
43

LIST OF CLASSES

45       class NetworkManager.ObjectVanished
46
47       This Exception will be raised when you try to call a method or access a
48       property on a dbus object that no longer exists. Objects can go missing
49       if  devices  are removed, connections are disabled or NetworkManager is
50       restarted.
51
52       class NetworkManager.NMDbusInterface
53
54       This is the base class of all classes below. It handles the marshalling
55       of data and the automatic creation of properties and methods.
56
57       Each  property,  method  and  signal exposed via the D-Bus interface is
58       automatically mirrored as an attribute of the actual classes. Moreover,
59       the  data  is  made  slightly  more  usable by performing the following
60       transformations on received and sent data.
61
62       · IP addresses are returned as strings of the form 1.2.3.4  instead  of
63         network byte ordered integers.
64
65       · Route metrics are returned in host byte order, so you can use them as
66         integers.
67
68       · Mac addresses and BSSIDs are always returned as strings of  the  form
69         00:11:22:33:44:55 instead of byte sequences.
70
71       · Wireless  SSID's  are  returned as strings instead of byte sequences.
72         They will be decoded as UTF-8 data, so using any other  encoding  for
73         your SSID will result in errors.
74
75       · DHCP options are turned into integers or booleans as appropriate
76
77       · Signals can be connected to using calls to OnSignalName functions.
78
79       Here's a short example to illustrate:
80
81       >>> import NetworkManager
82       >>> NetworkManager.NetworkManager.Version
83       '1.4.4'
84       >>> NetworkManager.NetworkManager.GetPermissions()
85       {'org.freedesktop.NetworkManager.checkpoint-rollback': 'auth',
86        'org.freedesktop.NetworkManager.enable-disable-network': 'yes',
87        ...}
88       # Must have a mainloop to use signals
89       >>> import dbus.mainloop.glib
90       >>> dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
91       >>> NetworkManager.NetworkManager.OnStateChanged(handle_state_change)
92
93       class NetworkManager.TransientNMDbusInterface
94
95       Subclasses of this class, which are ActiveConnection, NSP, IP[46]Config
96       and  DHCP[46]Config  never  survive  a  NetworkManager  restart.  Other
97       objects may survive a restart, but get a different object path.
98
99       class NetworkManager.NetworkManager
100
101       The   main  NetworkManager  object;  the  NetworkManager.Networkmanager
102       object is actually the singleton instance of this class.
103
104       class NetworkManager.Settings
105
106       The Settings object, which can be used to add connections, list connec‐
107       tions  or  update  your hostname; the NetworkManager.Settings object is
108       actually the singleton instance of this class.
109
110       class NetworkManager.AgentManager
111
112       The AgentManager object, whose methods you'll need to call when  imple‐
113       menting  a  secrets  agent;  the  NetworkManager.AgentManager object is
114       actually the singleton instance of this class.
115
116       class NetworkManager.Connection
117
118       Connection objects represent network configurations configured  by  the
119       user.
120
121       class NetworkManager.ActiveConnection
122
123       class NetworkManager.VPNConnection
124
125       Active   connections   are  represented  by  ActiveConnection  objects.
126       VPNConnection is a subclass for active VPN connection  that  implements
127       both the Connection.Active and VPN.Connection interfaces.
128
129       class NetworkManager.IP4Config
130
131       class NetworkManager.IP6Config
132
133       class NetworkManager.DHCP4Config
134
135       class NetworkManager.DHCP6Config
136
137       Active  network  connections  and devices can all have IPv4, IPv6, IPv4
138       DHCP and IPv6 DHCP information attached to them, which  is  represented
139       by instances of these classes.
140
141       class NetworkManager.AccessPoint
142
143       Wifi Accesspoints, as visibly by any 802.11 wifi interface.
144
145       class NetworkManager.NSP
146
147       Wimax Network Service Providers.
148
149       class NetworkManager.Device
150
151       All  device  classes  implement  the  Device interface, which gives you
152       access to basic  device  properties.  Note  that  you  will  never  see
153       instances  of  this  class,  only of its devicetype-specific subclasses
154       which impletemnt not only the Device interface but also their own  spe‐
155       cific  interface.  Supported  device  types  are Adsl, Bluetooth, Bond,
156       Bridge, Generic, Infiniband, IPTunnel, Macvlan, Modem, OlpcMesh,  Team,
157       Tun, Veth, Vlan, Vxlan, Wimax, Wired and Wireless
158
159       class NetworkManager.SecretAgent
160
161       The NetworkManager daemon can ask separate programs, called agents, for
162       secrets if it needs them. The NetworkManager applet and the nmcli  com‐
163       mand-line  tool  are  examples  of such agents. You can also write such
164       agents by subclassing the SecretAgent class and providing a  GetSecrets
165       method as in the following example, which returns a static password for
166       each secret:
167
168          import dbus.mainloop.glib
169          import GObject
170          import NetworkManager
171
172          class MyAgent(NetworkManager.SecretAgent):
173              def GetSecrets(self, settings, connection, setting_name, hints, flags):
174                  return {setting_name: {'secrets': {'password': 'TopSecret!'}}}
175
176          agent = MyAgent()
177          dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
178          Gobject.MainLoop().run()
179
180       Beware that NetworkManager will ask each agent in turn in  what  is  in
181       essence  random order. Except it will prioritize the program that acti‐
182       vated the connection. So if you want to make sure your agent is  called
183       first, activate the connection from the same application.
184

AUTHOR

186       Dennis Kaarsemaker
187
189       2011-2019, Dennis Kaarsemaker
190
191
192
193
1942.1                              Jul 26, 2019         PYTHON-NETWORKMANAGER(1)
Impressum