nmcli 1.6.0__tar.gz → 1.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nmcli-1.6.0 → nmcli-1.7.0}/PKG-INFO +62 -6
- {nmcli-1.6.0 → nmcli-1.7.0}/README.md +61 -5
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/_connection.py +15 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/_device.py +16 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/_general.py +20 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/dummy/_connection.py +12 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/dummy/_device.py +19 -1
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/dummy/_general.py +10 -1
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli.egg-info/PKG-INFO +62 -6
- {nmcli-1.6.0 → nmcli-1.7.0}/pyproject.toml +1 -1
- {nmcli-1.6.0 → nmcli-1.7.0}/tests/test_connection.py +22 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/tests/test_device.py +23 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/tests/test_general.py +40 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/LICENSE.txt +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/__init__.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/_const.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/_exception.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/_helper.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/_networking.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/_radio.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/_system.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/data/__init__.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/data/connection.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/data/device.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/data/general.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/data/hotspot.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/data/radio.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/dummy/__init__.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/dummy/_networking.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/dummy/_radio.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli/py.typed +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli.egg-info/SOURCES.txt +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli.egg-info/dependency_links.txt +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/nmcli.egg-info/top_level.txt +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/setup.cfg +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/setup.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/tests/test_helper.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/tests/test_networking.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/tests/test_radio.py +0 -0
- {nmcli-1.6.0 → nmcli-1.7.0}/tests/test_system.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nmcli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: A python wrapper library for the network-manager cli client
|
|
5
5
|
Author: ushiboy
|
|
6
6
|
License-Expression: MIT
|
|
@@ -58,6 +58,7 @@ except Exception as e:
|
|
|
58
58
|
| general | hostname | supported |
|
|
59
59
|
| general | permissions | not supported |
|
|
60
60
|
| general | logging | not supported |
|
|
61
|
+
| general | reload | supported |
|
|
61
62
|
| networking | | supported |
|
|
62
63
|
| networking | on | supported |
|
|
63
64
|
| networking | off | supported |
|
|
@@ -75,6 +76,7 @@ except Exception as e:
|
|
|
75
76
|
| connection | clone | not supported |
|
|
76
77
|
| connection | edit | not supported |
|
|
77
78
|
| connection | delete | supported |
|
|
79
|
+
| connection | monitor | not supported |
|
|
78
80
|
| connection | reload | supported |
|
|
79
81
|
| connection | load | not supported |
|
|
80
82
|
| connection | import | not supported |
|
|
@@ -83,17 +85,20 @@ except Exception as e:
|
|
|
83
85
|
| device | status | supported |
|
|
84
86
|
| device | show | supported |
|
|
85
87
|
| device | set | not supported |
|
|
88
|
+
| device | up | supported |
|
|
86
89
|
| device | connect | supported |
|
|
87
90
|
| device | reapply | supported |
|
|
88
91
|
| device | modify | not supported |
|
|
92
|
+
| device | down | supported |
|
|
89
93
|
| device | disconnect | supported |
|
|
90
94
|
| device | delete | supported |
|
|
91
95
|
| device | monitor | not supported |
|
|
92
|
-
| device | wifi
|
|
93
|
-
| device | wifi connect
|
|
94
|
-
| device | wifi rescan
|
|
95
|
-
| device | wifi hotspot
|
|
96
|
-
| device |
|
|
96
|
+
| device | wifi | supported |
|
|
97
|
+
| device | wifi connect | supported |
|
|
98
|
+
| device | wifi rescan | supported |
|
|
99
|
+
| device | wifi hotspot | supported |
|
|
100
|
+
| device | wifi show-password | not supported |
|
|
101
|
+
| device | lldp | not supported |
|
|
97
102
|
| agent | | not supported |
|
|
98
103
|
| agent | secret | not supported |
|
|
99
104
|
| agent | polkit | not supported |
|
|
@@ -174,6 +179,16 @@ Use `active` argument to show only the active profile.
|
|
|
174
179
|
nmcli.connection.show(name: str, show_secrets: bool = False, active: bool = False) -> ConnectionDetails
|
|
175
180
|
```
|
|
176
181
|
|
|
182
|
+
#### nmcli.connection.show_all
|
|
183
|
+
|
|
184
|
+
Show all connections.
|
|
185
|
+
|
|
186
|
+
Use `active` argument to show only active connections.
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
nmcli.connection.show_all(active: bool = False) -> List[Connection]
|
|
190
|
+
```
|
|
191
|
+
|
|
177
192
|
#### nmcli.connection.reload
|
|
178
193
|
|
|
179
194
|
Reload all connection files from disk.
|
|
@@ -220,6 +235,16 @@ The `fields` argument applies the same effect to the command as the `-f | --fiel
|
|
|
220
235
|
nmcli.device.show_all(fields: str = None) -> List[DeviceDetails]
|
|
221
236
|
```
|
|
222
237
|
|
|
238
|
+
#### nmcli.device.up
|
|
239
|
+
|
|
240
|
+
Connect the device.
|
|
241
|
+
|
|
242
|
+
The `wait` argument applies the same effect to the command as the `--wait` option. If it is omitted, the default behavior is followed.
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
nmcli.device.up(ifname: str, wait: int = None) -> None
|
|
246
|
+
```
|
|
247
|
+
|
|
223
248
|
#### nmcli.device.connect
|
|
224
249
|
|
|
225
250
|
Connect the device.
|
|
@@ -230,6 +255,16 @@ The `wait` argument applies the same effect to the command as the `--wait` optio
|
|
|
230
255
|
nmcli.device.connect(ifname: str, wait: int = None) -> None
|
|
231
256
|
```
|
|
232
257
|
|
|
258
|
+
#### nmcli.device.down
|
|
259
|
+
|
|
260
|
+
Disconnect a device and prevent the device from automatically activating further connections without user/manual intervention.
|
|
261
|
+
|
|
262
|
+
The `wait` argument applies the same effect to the command as the `--wait` option. If it is omitted, the default behavior is followed.
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
nmcli.device.down(ifname: str, wait: int = None) -> None
|
|
266
|
+
```
|
|
267
|
+
|
|
233
268
|
#### nmcli.device.disconnect
|
|
234
269
|
|
|
235
270
|
Disconnect devices.
|
|
@@ -334,6 +369,21 @@ Change persistent system hostname.
|
|
|
334
369
|
nmcli.general.set_hostname(hostname: str) -> None
|
|
335
370
|
```
|
|
336
371
|
|
|
372
|
+
#### nmcli.general.reload
|
|
373
|
+
|
|
374
|
+
Reload NetworkManager's configuration and perform certain updates.
|
|
375
|
+
|
|
376
|
+
The `flags` argument specifies which configurations to reload. Valid flags are:
|
|
377
|
+
- `conf`: Reload NetworkManager.conf configuration from disk
|
|
378
|
+
- `dns-rc`: Update DNS configuration (equivalent to SIGUSR1)
|
|
379
|
+
- `dns-full`: Restart the DNS plugin
|
|
380
|
+
|
|
381
|
+
If no flags are provided, everything that is supported is reloaded.
|
|
382
|
+
|
|
383
|
+
```
|
|
384
|
+
nmcli.general.reload(flags: Optional[List[str]] = None) -> None
|
|
385
|
+
```
|
|
386
|
+
|
|
337
387
|
### networking
|
|
338
388
|
|
|
339
389
|
#### nmcli.networking
|
|
@@ -473,6 +523,12 @@ nmcli.set_lang(lang: str) -> None
|
|
|
473
523
|
|
|
474
524
|
## Change Log
|
|
475
525
|
|
|
526
|
+
### 1.7.0
|
|
527
|
+
|
|
528
|
+
- Added `nmcli.connection.show_all` method with active filtering support
|
|
529
|
+
- Added `nmcli.device.up` and `nmcli.device.down` methods
|
|
530
|
+
- Added `nmcli.general.reload` method with configuration flags support
|
|
531
|
+
|
|
476
532
|
### 1.6.0
|
|
477
533
|
|
|
478
534
|
- Added active option to `nmcli.connection.show`
|
|
@@ -44,6 +44,7 @@ except Exception as e:
|
|
|
44
44
|
| general | hostname | supported |
|
|
45
45
|
| general | permissions | not supported |
|
|
46
46
|
| general | logging | not supported |
|
|
47
|
+
| general | reload | supported |
|
|
47
48
|
| networking | | supported |
|
|
48
49
|
| networking | on | supported |
|
|
49
50
|
| networking | off | supported |
|
|
@@ -61,6 +62,7 @@ except Exception as e:
|
|
|
61
62
|
| connection | clone | not supported |
|
|
62
63
|
| connection | edit | not supported |
|
|
63
64
|
| connection | delete | supported |
|
|
65
|
+
| connection | monitor | not supported |
|
|
64
66
|
| connection | reload | supported |
|
|
65
67
|
| connection | load | not supported |
|
|
66
68
|
| connection | import | not supported |
|
|
@@ -69,17 +71,20 @@ except Exception as e:
|
|
|
69
71
|
| device | status | supported |
|
|
70
72
|
| device | show | supported |
|
|
71
73
|
| device | set | not supported |
|
|
74
|
+
| device | up | supported |
|
|
72
75
|
| device | connect | supported |
|
|
73
76
|
| device | reapply | supported |
|
|
74
77
|
| device | modify | not supported |
|
|
78
|
+
| device | down | supported |
|
|
75
79
|
| device | disconnect | supported |
|
|
76
80
|
| device | delete | supported |
|
|
77
81
|
| device | monitor | not supported |
|
|
78
|
-
| device | wifi
|
|
79
|
-
| device | wifi connect
|
|
80
|
-
| device | wifi rescan
|
|
81
|
-
| device | wifi hotspot
|
|
82
|
-
| device |
|
|
82
|
+
| device | wifi | supported |
|
|
83
|
+
| device | wifi connect | supported |
|
|
84
|
+
| device | wifi rescan | supported |
|
|
85
|
+
| device | wifi hotspot | supported |
|
|
86
|
+
| device | wifi show-password | not supported |
|
|
87
|
+
| device | lldp | not supported |
|
|
83
88
|
| agent | | not supported |
|
|
84
89
|
| agent | secret | not supported |
|
|
85
90
|
| agent | polkit | not supported |
|
|
@@ -160,6 +165,16 @@ Use `active` argument to show only the active profile.
|
|
|
160
165
|
nmcli.connection.show(name: str, show_secrets: bool = False, active: bool = False) -> ConnectionDetails
|
|
161
166
|
```
|
|
162
167
|
|
|
168
|
+
#### nmcli.connection.show_all
|
|
169
|
+
|
|
170
|
+
Show all connections.
|
|
171
|
+
|
|
172
|
+
Use `active` argument to show only active connections.
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
nmcli.connection.show_all(active: bool = False) -> List[Connection]
|
|
176
|
+
```
|
|
177
|
+
|
|
163
178
|
#### nmcli.connection.reload
|
|
164
179
|
|
|
165
180
|
Reload all connection files from disk.
|
|
@@ -206,6 +221,16 @@ The `fields` argument applies the same effect to the command as the `-f | --fiel
|
|
|
206
221
|
nmcli.device.show_all(fields: str = None) -> List[DeviceDetails]
|
|
207
222
|
```
|
|
208
223
|
|
|
224
|
+
#### nmcli.device.up
|
|
225
|
+
|
|
226
|
+
Connect the device.
|
|
227
|
+
|
|
228
|
+
The `wait` argument applies the same effect to the command as the `--wait` option. If it is omitted, the default behavior is followed.
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
nmcli.device.up(ifname: str, wait: int = None) -> None
|
|
232
|
+
```
|
|
233
|
+
|
|
209
234
|
#### nmcli.device.connect
|
|
210
235
|
|
|
211
236
|
Connect the device.
|
|
@@ -216,6 +241,16 @@ The `wait` argument applies the same effect to the command as the `--wait` optio
|
|
|
216
241
|
nmcli.device.connect(ifname: str, wait: int = None) -> None
|
|
217
242
|
```
|
|
218
243
|
|
|
244
|
+
#### nmcli.device.down
|
|
245
|
+
|
|
246
|
+
Disconnect a device and prevent the device from automatically activating further connections without user/manual intervention.
|
|
247
|
+
|
|
248
|
+
The `wait` argument applies the same effect to the command as the `--wait` option. If it is omitted, the default behavior is followed.
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
nmcli.device.down(ifname: str, wait: int = None) -> None
|
|
252
|
+
```
|
|
253
|
+
|
|
219
254
|
#### nmcli.device.disconnect
|
|
220
255
|
|
|
221
256
|
Disconnect devices.
|
|
@@ -320,6 +355,21 @@ Change persistent system hostname.
|
|
|
320
355
|
nmcli.general.set_hostname(hostname: str) -> None
|
|
321
356
|
```
|
|
322
357
|
|
|
358
|
+
#### nmcli.general.reload
|
|
359
|
+
|
|
360
|
+
Reload NetworkManager's configuration and perform certain updates.
|
|
361
|
+
|
|
362
|
+
The `flags` argument specifies which configurations to reload. Valid flags are:
|
|
363
|
+
- `conf`: Reload NetworkManager.conf configuration from disk
|
|
364
|
+
- `dns-rc`: Update DNS configuration (equivalent to SIGUSR1)
|
|
365
|
+
- `dns-full`: Restart the DNS plugin
|
|
366
|
+
|
|
367
|
+
If no flags are provided, everything that is supported is reloaded.
|
|
368
|
+
|
|
369
|
+
```
|
|
370
|
+
nmcli.general.reload(flags: Optional[List[str]] = None) -> None
|
|
371
|
+
```
|
|
372
|
+
|
|
323
373
|
### networking
|
|
324
374
|
|
|
325
375
|
#### nmcli.networking
|
|
@@ -459,6 +509,12 @@ nmcli.set_lang(lang: str) -> None
|
|
|
459
509
|
|
|
460
510
|
## Change Log
|
|
461
511
|
|
|
512
|
+
### 1.7.0
|
|
513
|
+
|
|
514
|
+
- Added `nmcli.connection.show_all` method with active filtering support
|
|
515
|
+
- Added `nmcli.device.up` and `nmcli.device.down` methods
|
|
516
|
+
- Added `nmcli.general.reload` method with configuration flags support
|
|
517
|
+
|
|
462
518
|
### 1.6.0
|
|
463
519
|
|
|
464
520
|
- Added active option to `nmcli.connection.show`
|
|
@@ -34,6 +34,9 @@ class ConnectionControlInterface:
|
|
|
34
34
|
def show(self, name: str, show_secrets: bool = False, active: bool = False) -> ConnectionDetails:
|
|
35
35
|
raise NotImplementedError
|
|
36
36
|
|
|
37
|
+
def show_all(self, active: bool = False) -> List[Connection]:
|
|
38
|
+
raise NotImplementedError
|
|
39
|
+
|
|
37
40
|
def reload(self) -> None:
|
|
38
41
|
raise NotImplementedError
|
|
39
42
|
|
|
@@ -104,5 +107,17 @@ class ConnectionControl(ConnectionControlInterface):
|
|
|
104
107
|
results[key] = None if value in ('--', '""') else value
|
|
105
108
|
return results
|
|
106
109
|
|
|
110
|
+
def show_all(self, active: bool = False) -> List[Connection]:
|
|
111
|
+
cmd = ['connection', 'show']
|
|
112
|
+
if active:
|
|
113
|
+
cmd += ['--active']
|
|
114
|
+
r = self._syscmd.nmcli(cmd)
|
|
115
|
+
results = []
|
|
116
|
+
for row in r.split('\n')[1:]:
|
|
117
|
+
if len(row) == 0:
|
|
118
|
+
continue
|
|
119
|
+
results.append(Connection.parse(row))
|
|
120
|
+
return results
|
|
121
|
+
|
|
107
122
|
def reload(self) -> None:
|
|
108
123
|
self._syscmd.nmcli(['connection', 'reload'])
|
|
@@ -52,9 +52,15 @@ class DeviceControlInterface:
|
|
|
52
52
|
def show_all(self, fields: str = None) -> List[DeviceDetails]:
|
|
53
53
|
raise NotImplementedError
|
|
54
54
|
|
|
55
|
+
def up(self, ifname: str, wait: int = None) -> None:
|
|
56
|
+
raise NotImplementedError
|
|
57
|
+
|
|
55
58
|
def connect(self, ifname: str, wait: int = None) -> None:
|
|
56
59
|
raise NotImplementedError
|
|
57
60
|
|
|
61
|
+
def down(self, ifname: str, wait: int = None) -> None:
|
|
62
|
+
raise NotImplementedError
|
|
63
|
+
|
|
58
64
|
def disconnect(self, ifname: str, wait: int = None) -> None:
|
|
59
65
|
raise NotImplementedError
|
|
60
66
|
|
|
@@ -131,11 +137,21 @@ class DeviceControl(DeviceControlInterface):
|
|
|
131
137
|
details[key] = None if value in ('--', '""') else value
|
|
132
138
|
return results
|
|
133
139
|
|
|
140
|
+
def up(self, ifname: str, wait: int = None) -> None:
|
|
141
|
+
cmd = add_wait_option_if_needed(
|
|
142
|
+
wait) + ['device', 'up', ifname]
|
|
143
|
+
self._syscmd.nmcli(cmd)
|
|
144
|
+
|
|
134
145
|
def connect(self, ifname: str, wait: int = None) -> None:
|
|
135
146
|
cmd = add_wait_option_if_needed(
|
|
136
147
|
wait) + ['device', 'connect', ifname]
|
|
137
148
|
self._syscmd.nmcli(cmd)
|
|
138
149
|
|
|
150
|
+
def down(self, ifname: str, wait: int = None) -> None:
|
|
151
|
+
cmd = add_wait_option_if_needed(
|
|
152
|
+
wait) + ['device', 'down', ifname]
|
|
153
|
+
self._syscmd.nmcli(cmd)
|
|
154
|
+
|
|
139
155
|
def disconnect(self, ifname: str, wait: int = None) -> None:
|
|
140
156
|
cmd = add_wait_option_if_needed(
|
|
141
157
|
wait) + ['device', 'disconnect', ifname]
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
|
|
1
3
|
from ._system import SystemCommand, SystemCommandInterface
|
|
2
4
|
from .data import General
|
|
3
5
|
|
|
@@ -16,9 +18,14 @@ class GeneralControlInterface:
|
|
|
16
18
|
def set_hostname(self, hostname: str):
|
|
17
19
|
raise NotImplementedError
|
|
18
20
|
|
|
21
|
+
def reload(self, flags: Optional[List[str]] = None) -> None:
|
|
22
|
+
raise NotImplementedError
|
|
23
|
+
|
|
19
24
|
|
|
20
25
|
class GeneralControl(GeneralControlInterface):
|
|
21
26
|
|
|
27
|
+
VALID_RELOAD_FLAGS = ['conf', 'dns-rc', 'dns-full']
|
|
28
|
+
|
|
22
29
|
def __init__(self, syscmd: SystemCommandInterface = None):
|
|
23
30
|
self._syscmd = syscmd or SystemCommand()
|
|
24
31
|
|
|
@@ -35,3 +42,16 @@ class GeneralControl(GeneralControlInterface):
|
|
|
35
42
|
|
|
36
43
|
def set_hostname(self, hostname: str):
|
|
37
44
|
self._syscmd.nmcli(['general', 'hostname', hostname])
|
|
45
|
+
|
|
46
|
+
def reload(self, flags: Optional[List[str]] = None) -> None:
|
|
47
|
+
if flags is not None:
|
|
48
|
+
for flag in flags:
|
|
49
|
+
if flag not in self.VALID_RELOAD_FLAGS:
|
|
50
|
+
raise ValueError(
|
|
51
|
+
f"Invalid reload flag '{flag}'. "
|
|
52
|
+
f"Valid flags are: {', '.join(self.VALID_RELOAD_FLAGS)}"
|
|
53
|
+
)
|
|
54
|
+
cmd = ['general', 'reload']
|
|
55
|
+
if flags:
|
|
56
|
+
cmd += flags
|
|
57
|
+
self._syscmd.nmcli(cmd)
|
|
@@ -31,6 +31,10 @@ class DummyConnectionControl(ConnectionControlInterface):
|
|
|
31
31
|
def show_args(self):
|
|
32
32
|
return self._show_args
|
|
33
33
|
|
|
34
|
+
@property
|
|
35
|
+
def show_all_args(self):
|
|
36
|
+
return self._show_all_args
|
|
37
|
+
|
|
34
38
|
@property
|
|
35
39
|
def called_reload(self) -> int:
|
|
36
40
|
return self._called_reload
|
|
@@ -38,16 +42,19 @@ class DummyConnectionControl(ConnectionControlInterface):
|
|
|
38
42
|
def __init__(self,
|
|
39
43
|
result_call: List[Connection] = None,
|
|
40
44
|
result_show: ConnectionDetails = None,
|
|
45
|
+
result_show_all: List[Connection] = None,
|
|
41
46
|
raise_error: Exception = None):
|
|
42
47
|
self._raise_error = raise_error
|
|
43
48
|
self._result_call = result_call or []
|
|
44
49
|
self._result_show = result_show
|
|
50
|
+
self._result_show_all = result_show_all or []
|
|
45
51
|
self._add_args: List[Tuple] = []
|
|
46
52
|
self._modify_args: List[Tuple] = []
|
|
47
53
|
self._delete_args: List[Tuple] = []
|
|
48
54
|
self._up_args: List[Tuple] = []
|
|
49
55
|
self._down_args: List[Tuple] = []
|
|
50
56
|
self._show_args: List[Tuple] = []
|
|
57
|
+
self._show_all_args: List[Tuple] = []
|
|
51
58
|
self._called_reload = 0
|
|
52
59
|
|
|
53
60
|
def __call__(self) -> List[Connection]:
|
|
@@ -86,6 +93,11 @@ class DummyConnectionControl(ConnectionControlInterface):
|
|
|
86
93
|
return self._result_show
|
|
87
94
|
raise ValueError("'result_show' is not properly initialized")
|
|
88
95
|
|
|
96
|
+
def show_all(self, active: bool = False) -> List[Connection]:
|
|
97
|
+
self._raise_error_if_needed()
|
|
98
|
+
self._show_all_args.append((active,))
|
|
99
|
+
return self._result_show_all
|
|
100
|
+
|
|
89
101
|
def reload(self) -> None:
|
|
90
102
|
self._raise_error_if_needed()
|
|
91
103
|
self._called_reload += 1
|
|
@@ -5,16 +5,24 @@ from ..data.device import Device, DeviceWifi
|
|
|
5
5
|
from ..data.hotspot import Hotspot
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class DummyDeviceControl(DeviceControlInterface):
|
|
8
|
+
class DummyDeviceControl(DeviceControlInterface): # pylint: disable=too-many-public-methods
|
|
9
9
|
|
|
10
10
|
@property
|
|
11
11
|
def show_args(self):
|
|
12
12
|
return self._show_args
|
|
13
13
|
|
|
14
|
+
@property
|
|
15
|
+
def up_args(self):
|
|
16
|
+
return self._up_args
|
|
17
|
+
|
|
14
18
|
@property
|
|
15
19
|
def connect_args(self):
|
|
16
20
|
return self._connect_args
|
|
17
21
|
|
|
22
|
+
@property
|
|
23
|
+
def down_args(self):
|
|
24
|
+
return self._down_args
|
|
25
|
+
|
|
18
26
|
@property
|
|
19
27
|
def disconnect_args(self):
|
|
20
28
|
return self._disconnect_args
|
|
@@ -57,7 +65,9 @@ class DummyDeviceControl(DeviceControlInterface):
|
|
|
57
65
|
self._result_show_all = result_show_all or []
|
|
58
66
|
self._result_wifi_hotspot = result_wifi_hotspot
|
|
59
67
|
self._show_args: List[Tuple] = []
|
|
68
|
+
self._up_args: List[Tuple] = []
|
|
60
69
|
self._connect_args: List[Tuple] = []
|
|
70
|
+
self._down_args: List[Tuple] = []
|
|
61
71
|
self._disconnect_args: List[Tuple] = []
|
|
62
72
|
self._reapply_args: List[str] = []
|
|
63
73
|
self._delete_args: List[Tuple] = []
|
|
@@ -85,10 +95,18 @@ class DummyDeviceControl(DeviceControlInterface):
|
|
|
85
95
|
self._raise_error_if_needed()
|
|
86
96
|
return self._result_show_all
|
|
87
97
|
|
|
98
|
+
def up(self, ifname: str, wait: int = None) -> None:
|
|
99
|
+
self._raise_error_if_needed()
|
|
100
|
+
self._up_args.append((ifname, wait))
|
|
101
|
+
|
|
88
102
|
def connect(self, ifname: str, wait: int = None) -> None:
|
|
89
103
|
self._raise_error_if_needed()
|
|
90
104
|
self._connect_args.append((ifname, wait))
|
|
91
105
|
|
|
106
|
+
def down(self, ifname: str, wait: int = None) -> None:
|
|
107
|
+
self._raise_error_if_needed()
|
|
108
|
+
self._down_args.append((ifname, wait))
|
|
109
|
+
|
|
92
110
|
def disconnect(self, ifname: str, wait: int = None) -> None:
|
|
93
111
|
self._raise_error_if_needed()
|
|
94
112
|
self._disconnect_args.append((ifname, wait))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import List
|
|
1
|
+
from typing import List, Optional
|
|
2
2
|
|
|
3
3
|
from .._general import GeneralControlInterface
|
|
4
4
|
from ..data.general import General
|
|
@@ -10,6 +10,10 @@ class DummyGeneralControl(GeneralControlInterface):
|
|
|
10
10
|
def set_hostname_args(self):
|
|
11
11
|
return self._set_hostname_args
|
|
12
12
|
|
|
13
|
+
@property
|
|
14
|
+
def reload_args(self):
|
|
15
|
+
return self._reload_args
|
|
16
|
+
|
|
13
17
|
def __init__(self,
|
|
14
18
|
result_call: General = None,
|
|
15
19
|
result_status: General = None,
|
|
@@ -20,6 +24,7 @@ class DummyGeneralControl(GeneralControlInterface):
|
|
|
20
24
|
self._result_status = result_status
|
|
21
25
|
self._result_hostname = result_hostname
|
|
22
26
|
self._set_hostname_args: List[str] = []
|
|
27
|
+
self._reload_args: List[Optional[List[str]]] = []
|
|
23
28
|
|
|
24
29
|
def __call__(self) -> General:
|
|
25
30
|
self._raise_error_if_needed()
|
|
@@ -41,6 +46,10 @@ class DummyGeneralControl(GeneralControlInterface):
|
|
|
41
46
|
self._raise_error_if_needed()
|
|
42
47
|
self._set_hostname_args.append(hostname)
|
|
43
48
|
|
|
49
|
+
def reload(self, flags: Optional[List[str]] = None) -> None:
|
|
50
|
+
self._raise_error_if_needed()
|
|
51
|
+
self._reload_args.append(flags)
|
|
52
|
+
|
|
44
53
|
def _raise_error_if_needed(self):
|
|
45
54
|
if not self._raise_error is None:
|
|
46
55
|
raise self._raise_error
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nmcli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: A python wrapper library for the network-manager cli client
|
|
5
5
|
Author: ushiboy
|
|
6
6
|
License-Expression: MIT
|
|
@@ -58,6 +58,7 @@ except Exception as e:
|
|
|
58
58
|
| general | hostname | supported |
|
|
59
59
|
| general | permissions | not supported |
|
|
60
60
|
| general | logging | not supported |
|
|
61
|
+
| general | reload | supported |
|
|
61
62
|
| networking | | supported |
|
|
62
63
|
| networking | on | supported |
|
|
63
64
|
| networking | off | supported |
|
|
@@ -75,6 +76,7 @@ except Exception as e:
|
|
|
75
76
|
| connection | clone | not supported |
|
|
76
77
|
| connection | edit | not supported |
|
|
77
78
|
| connection | delete | supported |
|
|
79
|
+
| connection | monitor | not supported |
|
|
78
80
|
| connection | reload | supported |
|
|
79
81
|
| connection | load | not supported |
|
|
80
82
|
| connection | import | not supported |
|
|
@@ -83,17 +85,20 @@ except Exception as e:
|
|
|
83
85
|
| device | status | supported |
|
|
84
86
|
| device | show | supported |
|
|
85
87
|
| device | set | not supported |
|
|
88
|
+
| device | up | supported |
|
|
86
89
|
| device | connect | supported |
|
|
87
90
|
| device | reapply | supported |
|
|
88
91
|
| device | modify | not supported |
|
|
92
|
+
| device | down | supported |
|
|
89
93
|
| device | disconnect | supported |
|
|
90
94
|
| device | delete | supported |
|
|
91
95
|
| device | monitor | not supported |
|
|
92
|
-
| device | wifi
|
|
93
|
-
| device | wifi connect
|
|
94
|
-
| device | wifi rescan
|
|
95
|
-
| device | wifi hotspot
|
|
96
|
-
| device |
|
|
96
|
+
| device | wifi | supported |
|
|
97
|
+
| device | wifi connect | supported |
|
|
98
|
+
| device | wifi rescan | supported |
|
|
99
|
+
| device | wifi hotspot | supported |
|
|
100
|
+
| device | wifi show-password | not supported |
|
|
101
|
+
| device | lldp | not supported |
|
|
97
102
|
| agent | | not supported |
|
|
98
103
|
| agent | secret | not supported |
|
|
99
104
|
| agent | polkit | not supported |
|
|
@@ -174,6 +179,16 @@ Use `active` argument to show only the active profile.
|
|
|
174
179
|
nmcli.connection.show(name: str, show_secrets: bool = False, active: bool = False) -> ConnectionDetails
|
|
175
180
|
```
|
|
176
181
|
|
|
182
|
+
#### nmcli.connection.show_all
|
|
183
|
+
|
|
184
|
+
Show all connections.
|
|
185
|
+
|
|
186
|
+
Use `active` argument to show only active connections.
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
nmcli.connection.show_all(active: bool = False) -> List[Connection]
|
|
190
|
+
```
|
|
191
|
+
|
|
177
192
|
#### nmcli.connection.reload
|
|
178
193
|
|
|
179
194
|
Reload all connection files from disk.
|
|
@@ -220,6 +235,16 @@ The `fields` argument applies the same effect to the command as the `-f | --fiel
|
|
|
220
235
|
nmcli.device.show_all(fields: str = None) -> List[DeviceDetails]
|
|
221
236
|
```
|
|
222
237
|
|
|
238
|
+
#### nmcli.device.up
|
|
239
|
+
|
|
240
|
+
Connect the device.
|
|
241
|
+
|
|
242
|
+
The `wait` argument applies the same effect to the command as the `--wait` option. If it is omitted, the default behavior is followed.
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
nmcli.device.up(ifname: str, wait: int = None) -> None
|
|
246
|
+
```
|
|
247
|
+
|
|
223
248
|
#### nmcli.device.connect
|
|
224
249
|
|
|
225
250
|
Connect the device.
|
|
@@ -230,6 +255,16 @@ The `wait` argument applies the same effect to the command as the `--wait` optio
|
|
|
230
255
|
nmcli.device.connect(ifname: str, wait: int = None) -> None
|
|
231
256
|
```
|
|
232
257
|
|
|
258
|
+
#### nmcli.device.down
|
|
259
|
+
|
|
260
|
+
Disconnect a device and prevent the device from automatically activating further connections without user/manual intervention.
|
|
261
|
+
|
|
262
|
+
The `wait` argument applies the same effect to the command as the `--wait` option. If it is omitted, the default behavior is followed.
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
nmcli.device.down(ifname: str, wait: int = None) -> None
|
|
266
|
+
```
|
|
267
|
+
|
|
233
268
|
#### nmcli.device.disconnect
|
|
234
269
|
|
|
235
270
|
Disconnect devices.
|
|
@@ -334,6 +369,21 @@ Change persistent system hostname.
|
|
|
334
369
|
nmcli.general.set_hostname(hostname: str) -> None
|
|
335
370
|
```
|
|
336
371
|
|
|
372
|
+
#### nmcli.general.reload
|
|
373
|
+
|
|
374
|
+
Reload NetworkManager's configuration and perform certain updates.
|
|
375
|
+
|
|
376
|
+
The `flags` argument specifies which configurations to reload. Valid flags are:
|
|
377
|
+
- `conf`: Reload NetworkManager.conf configuration from disk
|
|
378
|
+
- `dns-rc`: Update DNS configuration (equivalent to SIGUSR1)
|
|
379
|
+
- `dns-full`: Restart the DNS plugin
|
|
380
|
+
|
|
381
|
+
If no flags are provided, everything that is supported is reloaded.
|
|
382
|
+
|
|
383
|
+
```
|
|
384
|
+
nmcli.general.reload(flags: Optional[List[str]] = None) -> None
|
|
385
|
+
```
|
|
386
|
+
|
|
337
387
|
### networking
|
|
338
388
|
|
|
339
389
|
#### nmcli.networking
|
|
@@ -473,6 +523,12 @@ nmcli.set_lang(lang: str) -> None
|
|
|
473
523
|
|
|
474
524
|
## Change Log
|
|
475
525
|
|
|
526
|
+
### 1.7.0
|
|
527
|
+
|
|
528
|
+
- Added `nmcli.connection.show_all` method with active filtering support
|
|
529
|
+
- Added `nmcli.device.up` and `nmcli.device.down` methods
|
|
530
|
+
- Added `nmcli.general.reload` method with configuration flags support
|
|
531
|
+
|
|
476
532
|
### 1.6.0
|
|
477
533
|
|
|
478
534
|
- Added active option to `nmcli.connection.show`
|
|
@@ -132,6 +132,28 @@ def test_show():
|
|
|
132
132
|
'connection', 'show', "--active", name]
|
|
133
133
|
|
|
134
134
|
|
|
135
|
+
def test_show_all():
|
|
136
|
+
s = DummySystemCommand('''NAME UUID TYPE DEVICE
|
|
137
|
+
AP1 3eac760c-de77-4823-9ab8-773c276daca3 wifi wlan0
|
|
138
|
+
Home 700f5b18-cbb3-4d38-9c61-e3bc3a3852b9 ethernet eth0
|
|
139
|
+
Wired connection 1 700f5b18-cbb3-4d38-9c61-999999999999 ethernet eth1''')
|
|
140
|
+
connection = ConnectionControl(s)
|
|
141
|
+
|
|
142
|
+
r = connection.show_all()
|
|
143
|
+
assert s.passed_parameters == ['connection', 'show']
|
|
144
|
+
assert r == [
|
|
145
|
+
Connection('AP1', '3eac760c-de77-4823-9ab8-773c276daca3',
|
|
146
|
+
'wifi', 'wlan0'),
|
|
147
|
+
Connection('Home', '700f5b18-cbb3-4d38-9c61-e3bc3a3852b9',
|
|
148
|
+
'ethernet', 'eth0'),
|
|
149
|
+
Connection('Wired connection 1',
|
|
150
|
+
'700f5b18-cbb3-4d38-9c61-999999999999', 'ethernet', 'eth1')
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
connection.show_all(active=True)
|
|
154
|
+
assert s.passed_parameters == ['connection', 'show', '--active']
|
|
155
|
+
|
|
156
|
+
|
|
135
157
|
def test_reload():
|
|
136
158
|
s = DummySystemCommand()
|
|
137
159
|
connection = ConnectionControl(s)
|
|
@@ -171,6 +171,17 @@ IP6.ROUTE[1]: dst = ::1/128, nh = ::, mt = 256'''
|
|
|
171
171
|
assert s2.passed_parameters == ['-f', 'all', 'device', 'show']
|
|
172
172
|
|
|
173
173
|
|
|
174
|
+
def test_up():
|
|
175
|
+
s = DummySystemCommand()
|
|
176
|
+
device = DeviceControl(s)
|
|
177
|
+
ifname = 'eth0'
|
|
178
|
+
device.up(ifname)
|
|
179
|
+
assert s.passed_parameters == ['device', 'up', ifname]
|
|
180
|
+
|
|
181
|
+
device.up(ifname, wait=10)
|
|
182
|
+
assert s.passed_parameters == ['--wait', '10', 'device', 'up', ifname]
|
|
183
|
+
|
|
184
|
+
|
|
174
185
|
def test_connect():
|
|
175
186
|
s = DummySystemCommand()
|
|
176
187
|
device = DeviceControl(s)
|
|
@@ -182,6 +193,18 @@ def test_connect():
|
|
|
182
193
|
assert s.passed_parameters == ['--wait', '10', 'device', 'connect', ifname]
|
|
183
194
|
|
|
184
195
|
|
|
196
|
+
def test_down():
|
|
197
|
+
s = DummySystemCommand()
|
|
198
|
+
device = DeviceControl(s)
|
|
199
|
+
ifname = 'eth0'
|
|
200
|
+
device.down(ifname)
|
|
201
|
+
assert s.passed_parameters == ['device', 'down', ifname]
|
|
202
|
+
|
|
203
|
+
device.down(ifname, wait=10)
|
|
204
|
+
assert s.passed_parameters == [
|
|
205
|
+
'--wait', '10', 'device', 'down', ifname]
|
|
206
|
+
|
|
207
|
+
|
|
185
208
|
def test_disconnect():
|
|
186
209
|
s = DummySystemCommand()
|
|
187
210
|
device = DeviceControl(s)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
1
3
|
from nmcli._const import NetworkConnectivity, NetworkManagerState
|
|
2
4
|
from nmcli._general import GeneralControl
|
|
3
5
|
from nmcli.data import General
|
|
@@ -37,3 +39,41 @@ def test_set_hostname():
|
|
|
37
39
|
general = GeneralControl(s)
|
|
38
40
|
general.set_hostname('test')
|
|
39
41
|
assert s.passed_parameters == ['general', 'hostname', 'test']
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_reload_without_flags():
|
|
45
|
+
s = DummySystemCommand()
|
|
46
|
+
general = GeneralControl(s)
|
|
47
|
+
general.reload()
|
|
48
|
+
assert s.passed_parameters == ['general', 'reload']
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_reload_with_single_flag():
|
|
52
|
+
s = DummySystemCommand()
|
|
53
|
+
general = GeneralControl(s)
|
|
54
|
+
general.reload(['conf'])
|
|
55
|
+
assert s.passed_parameters == ['general', 'reload', 'conf']
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_reload_with_all_valid_flags():
|
|
59
|
+
s = DummySystemCommand()
|
|
60
|
+
general = GeneralControl(s)
|
|
61
|
+
general.reload(['conf', 'dns-rc', 'dns-full'])
|
|
62
|
+
assert s.passed_parameters == ['general', 'reload', 'conf', 'dns-rc', 'dns-full']
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_reload_with_invalid_flag():
|
|
66
|
+
s = DummySystemCommand()
|
|
67
|
+
general = GeneralControl(s)
|
|
68
|
+
with pytest.raises(ValueError) as exc_info:
|
|
69
|
+
general.reload(['invalid-flag'])
|
|
70
|
+
assert "Invalid reload flag 'invalid-flag'" in str(exc_info.value)
|
|
71
|
+
assert "Valid flags are: conf, dns-rc, dns-full" in str(exc_info.value)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_reload_with_mixed_valid_and_invalid_flags():
|
|
75
|
+
s = DummySystemCommand()
|
|
76
|
+
general = GeneralControl(s)
|
|
77
|
+
with pytest.raises(ValueError) as exc_info:
|
|
78
|
+
general.reload(['conf', 'invalid'])
|
|
79
|
+
assert "Invalid reload flag 'invalid'" in str(exc_info.value)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|