File: add_connection.py

package info (click to toggle)
python-networkmanager 2.2-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 496 kB
  • sloc: python: 1,816; makefile: 116
file content (26 lines) | stat: -rw-r--r-- 951 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Add a connection to NetworkManager. You do this by sending a dict to
AddConnection. The dict below was generated with n-m dump on an existing
connection and then anonymised
"""

import NetworkManager
import uuid

example_connection = {
     '802-11-wireless': {'mode': 'infrastructure',
                         'security': '802-11-wireless-security',
                         'ssid': 'n-m-example-connection'},
     '802-11-wireless-security': {'auth-alg': 'open', 'key-mgmt': 'wpa-eap'},
     '802-1x': {'eap': ['peap'],
                'identity': 'eap-identity-goes-here',
                'password': 'eap-password-goes-here',
                'phase2-auth': 'mschapv2'},
     'connection': {'id': 'nm-example-connection',
                    'type': '802-11-wireless',
                    'uuid': str(uuid.uuid4())},
     'ipv4': {'method': 'auto'},
     'ipv6': {'method': 'auto'}
}

NetworkManager.Settings.AddConnection(example_connection)