nmcli 1.6.0__tar.gz → 1.8.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.8.0}/PKG-INFO +69 -7
- {nmcli-1.6.0 → nmcli-1.8.0}/README.md +68 -6
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/_connection.py +15 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/_device.py +22 -4
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/_general.py +20 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/dummy/_connection.py +12 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/dummy/_device.py +21 -3
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/dummy/_general.py +10 -1
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli.egg-info/PKG-INFO +69 -7
- {nmcli-1.6.0 → nmcli-1.8.0}/pyproject.toml +1 -1
- {nmcli-1.6.0 → nmcli-1.8.0}/tests/test_connection.py +22 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/tests/test_device.py +44 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/tests/test_general.py +41 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/LICENSE.txt +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/__init__.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/_const.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/_exception.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/_helper.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/_networking.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/_radio.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/_system.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/data/__init__.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/data/connection.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/data/device.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/data/general.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/data/hotspot.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/data/radio.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/dummy/__init__.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/dummy/_networking.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/dummy/_radio.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli/py.typed +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli.egg-info/SOURCES.txt +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli.egg-info/dependency_links.txt +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/nmcli.egg-info/top_level.txt +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/setup.cfg +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/setup.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/tests/test_helper.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/tests/test_networking.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.0}/tests/test_radio.py +0 -0
- {nmcli-1.6.0 → nmcli-1.8.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.8.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.
|
|
@@ -272,9 +307,11 @@ Connect to a Wi-Fi network specified by SSID or BSSID.
|
|
|
272
307
|
|
|
273
308
|
The `wait` argument applies the same effect to the command as the `--wait` option. If it is omitted, the default behavior is followed.
|
|
274
309
|
|
|
310
|
+
If `password` is `None`, the password option is omitted from the command. This allows connecting to open networks or known networks that already have credentials stored.
|
|
311
|
+
|
|
275
312
|
```
|
|
276
313
|
nmcli.device.wifi_connect(ssid: str,
|
|
277
|
-
password: str,
|
|
314
|
+
password: Optional[str] = None,
|
|
278
315
|
ifname: str = None,
|
|
279
316
|
wait: int = None) -> None
|
|
280
317
|
```
|
|
@@ -334,6 +371,21 @@ Change persistent system hostname.
|
|
|
334
371
|
nmcli.general.set_hostname(hostname: str) -> None
|
|
335
372
|
```
|
|
336
373
|
|
|
374
|
+
#### nmcli.general.reload
|
|
375
|
+
|
|
376
|
+
Reload NetworkManager's configuration and perform certain updates.
|
|
377
|
+
|
|
378
|
+
The `flags` argument specifies which configurations to reload. Valid flags are:
|
|
379
|
+
- `conf`: Reload NetworkManager.conf configuration from disk
|
|
380
|
+
- `dns-rc`: Update DNS configuration (equivalent to SIGUSR1)
|
|
381
|
+
- `dns-full`: Restart the DNS plugin
|
|
382
|
+
|
|
383
|
+
If no flags are provided, everything that is supported is reloaded.
|
|
384
|
+
|
|
385
|
+
```
|
|
386
|
+
nmcli.general.reload(flags: Optional[List[str]] = None) -> None
|
|
387
|
+
```
|
|
388
|
+
|
|
337
389
|
### networking
|
|
338
390
|
|
|
339
391
|
#### nmcli.networking
|
|
@@ -473,6 +525,16 @@ nmcli.set_lang(lang: str) -> None
|
|
|
473
525
|
|
|
474
526
|
## Change Log
|
|
475
527
|
|
|
528
|
+
### 1.8.0
|
|
529
|
+
|
|
530
|
+
- Allow `nmcli.device.wifi_connect` to accept `None` as password to connect to open or known networks without specifying a password.
|
|
531
|
+
|
|
532
|
+
### 1.7.0
|
|
533
|
+
|
|
534
|
+
- Added `nmcli.connection.show_all` method with active filtering support
|
|
535
|
+
- Added `nmcli.device.up` and `nmcli.device.down` methods
|
|
536
|
+
- Added `nmcli.general.reload` method with configuration flags support
|
|
537
|
+
|
|
476
538
|
### 1.6.0
|
|
477
539
|
|
|
478
540
|
- 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.
|
|
@@ -258,9 +293,11 @@ Connect to a Wi-Fi network specified by SSID or BSSID.
|
|
|
258
293
|
|
|
259
294
|
The `wait` argument applies the same effect to the command as the `--wait` option. If it is omitted, the default behavior is followed.
|
|
260
295
|
|
|
296
|
+
If `password` is `None`, the password option is omitted from the command. This allows connecting to open networks or known networks that already have credentials stored.
|
|
297
|
+
|
|
261
298
|
```
|
|
262
299
|
nmcli.device.wifi_connect(ssid: str,
|
|
263
|
-
password: str,
|
|
300
|
+
password: Optional[str] = None,
|
|
264
301
|
ifname: str = None,
|
|
265
302
|
wait: int = None) -> None
|
|
266
303
|
```
|
|
@@ -320,6 +357,21 @@ Change persistent system hostname.
|
|
|
320
357
|
nmcli.general.set_hostname(hostname: str) -> None
|
|
321
358
|
```
|
|
322
359
|
|
|
360
|
+
#### nmcli.general.reload
|
|
361
|
+
|
|
362
|
+
Reload NetworkManager's configuration and perform certain updates.
|
|
363
|
+
|
|
364
|
+
The `flags` argument specifies which configurations to reload. Valid flags are:
|
|
365
|
+
- `conf`: Reload NetworkManager.conf configuration from disk
|
|
366
|
+
- `dns-rc`: Update DNS configuration (equivalent to SIGUSR1)
|
|
367
|
+
- `dns-full`: Restart the DNS plugin
|
|
368
|
+
|
|
369
|
+
If no flags are provided, everything that is supported is reloaded.
|
|
370
|
+
|
|
371
|
+
```
|
|
372
|
+
nmcli.general.reload(flags: Optional[List[str]] = None) -> None
|
|
373
|
+
```
|
|
374
|
+
|
|
323
375
|
### networking
|
|
324
376
|
|
|
325
377
|
#### nmcli.networking
|
|
@@ -459,6 +511,16 @@ nmcli.set_lang(lang: str) -> None
|
|
|
459
511
|
|
|
460
512
|
## Change Log
|
|
461
513
|
|
|
514
|
+
### 1.8.0
|
|
515
|
+
|
|
516
|
+
- Allow `nmcli.device.wifi_connect` to accept `None` as password to connect to open or known networks without specifying a password.
|
|
517
|
+
|
|
518
|
+
### 1.7.0
|
|
519
|
+
|
|
520
|
+
- Added `nmcli.connection.show_all` method with active filtering support
|
|
521
|
+
- Added `nmcli.device.up` and `nmcli.device.down` methods
|
|
522
|
+
- Added `nmcli.general.reload` method with configuration flags support
|
|
523
|
+
|
|
462
524
|
### 1.6.0
|
|
463
525
|
|
|
464
526
|
- 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'])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
|
-
from typing import List, Tuple
|
|
2
|
+
from typing import List, Optional, Tuple
|
|
3
3
|
|
|
4
4
|
from ._exception import ConnectionActivateFailedException
|
|
5
5
|
from ._helper import add_fields_option_if_needed, add_wait_option_if_needed
|
|
@@ -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
|
|
|
@@ -69,7 +75,7 @@ class DeviceControlInterface:
|
|
|
69
75
|
|
|
70
76
|
def wifi_connect(self,
|
|
71
77
|
ssid: str,
|
|
72
|
-
password: str,
|
|
78
|
+
password: Optional[str] = None,
|
|
73
79
|
ifname: str = None,
|
|
74
80
|
wait: int = None) -> None:
|
|
75
81
|
raise NotImplementedError
|
|
@@ -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]
|
|
@@ -166,11 +182,13 @@ class DeviceControl(DeviceControlInterface):
|
|
|
166
182
|
|
|
167
183
|
def wifi_connect(self,
|
|
168
184
|
ssid: str,
|
|
169
|
-
password: str,
|
|
185
|
+
password: Optional[str] = None,
|
|
170
186
|
ifname: str = None,
|
|
171
187
|
wait: int = None) -> None:
|
|
172
188
|
cmd = add_wait_option_if_needed(
|
|
173
|
-
wait) + ['device', 'wifi', 'connect', ssid
|
|
189
|
+
wait) + ['device', 'wifi', 'connect', ssid]
|
|
190
|
+
if password is not None:
|
|
191
|
+
cmd += ['password', password]
|
|
174
192
|
if ifname is not None:
|
|
175
193
|
cmd += ['ifname', ifname]
|
|
176
194
|
r = self._syscmd.nmcli(cmd)
|
|
@@ -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
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
from typing import List, Tuple
|
|
1
|
+
from typing import List, Optional, Tuple
|
|
2
2
|
|
|
3
3
|
from .._device import DeviceControlInterface, DeviceDetails
|
|
4
4
|
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))
|
|
@@ -108,7 +126,7 @@ class DummyDeviceControl(DeviceControlInterface):
|
|
|
108
126
|
|
|
109
127
|
def wifi_connect(self,
|
|
110
128
|
ssid: str,
|
|
111
|
-
password: str,
|
|
129
|
+
password: Optional[str] = None,
|
|
112
130
|
ifname: str = None,
|
|
113
131
|
wait: int = None) -> None:
|
|
114
132
|
self._raise_error_if_needed()
|
|
@@ -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.8.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.
|
|
@@ -272,9 +307,11 @@ Connect to a Wi-Fi network specified by SSID or BSSID.
|
|
|
272
307
|
|
|
273
308
|
The `wait` argument applies the same effect to the command as the `--wait` option. If it is omitted, the default behavior is followed.
|
|
274
309
|
|
|
310
|
+
If `password` is `None`, the password option is omitted from the command. This allows connecting to open networks or known networks that already have credentials stored.
|
|
311
|
+
|
|
275
312
|
```
|
|
276
313
|
nmcli.device.wifi_connect(ssid: str,
|
|
277
|
-
password: str,
|
|
314
|
+
password: Optional[str] = None,
|
|
278
315
|
ifname: str = None,
|
|
279
316
|
wait: int = None) -> None
|
|
280
317
|
```
|
|
@@ -334,6 +371,21 @@ Change persistent system hostname.
|
|
|
334
371
|
nmcli.general.set_hostname(hostname: str) -> None
|
|
335
372
|
```
|
|
336
373
|
|
|
374
|
+
#### nmcli.general.reload
|
|
375
|
+
|
|
376
|
+
Reload NetworkManager's configuration and perform certain updates.
|
|
377
|
+
|
|
378
|
+
The `flags` argument specifies which configurations to reload. Valid flags are:
|
|
379
|
+
- `conf`: Reload NetworkManager.conf configuration from disk
|
|
380
|
+
- `dns-rc`: Update DNS configuration (equivalent to SIGUSR1)
|
|
381
|
+
- `dns-full`: Restart the DNS plugin
|
|
382
|
+
|
|
383
|
+
If no flags are provided, everything that is supported is reloaded.
|
|
384
|
+
|
|
385
|
+
```
|
|
386
|
+
nmcli.general.reload(flags: Optional[List[str]] = None) -> None
|
|
387
|
+
```
|
|
388
|
+
|
|
337
389
|
### networking
|
|
338
390
|
|
|
339
391
|
#### nmcli.networking
|
|
@@ -473,6 +525,16 @@ nmcli.set_lang(lang: str) -> None
|
|
|
473
525
|
|
|
474
526
|
## Change Log
|
|
475
527
|
|
|
528
|
+
### 1.8.0
|
|
529
|
+
|
|
530
|
+
- Allow `nmcli.device.wifi_connect` to accept `None` as password to connect to open or known networks without specifying a password.
|
|
531
|
+
|
|
532
|
+
### 1.7.0
|
|
533
|
+
|
|
534
|
+
- Added `nmcli.connection.show_all` method with active filtering support
|
|
535
|
+
- Added `nmcli.device.up` and `nmcli.device.down` methods
|
|
536
|
+
- Added `nmcli.general.reload` method with configuration flags support
|
|
537
|
+
|
|
476
538
|
### 1.6.0
|
|
477
539
|
|
|
478
540
|
- 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)
|
|
@@ -286,6 +309,27 @@ def test_wifi_connect():
|
|
|
286
309
|
'--wait', '10', 'device', 'wifi', 'connect', ssid, 'password', password]
|
|
287
310
|
|
|
288
311
|
|
|
312
|
+
def test_wifi_connect_without_password():
|
|
313
|
+
s = DummySystemCommand()
|
|
314
|
+
device = DeviceControl(s)
|
|
315
|
+
ssid = 'Open AP'
|
|
316
|
+
ifname = 'wlan0'
|
|
317
|
+
|
|
318
|
+
device.wifi_connect(ssid, None)
|
|
319
|
+
assert s.passed_parameters == ['device', 'wifi', 'connect', ssid]
|
|
320
|
+
|
|
321
|
+
device.wifi_connect(ssid, None, ifname)
|
|
322
|
+
assert s.passed_parameters == [
|
|
323
|
+
'device', 'wifi', 'connect', ssid, 'ifname', ifname]
|
|
324
|
+
|
|
325
|
+
device.wifi_connect(ssid, None, wait=10)
|
|
326
|
+
assert s.passed_parameters == [
|
|
327
|
+
'--wait', '10', 'device', 'wifi', 'connect', ssid]
|
|
328
|
+
|
|
329
|
+
device.wifi_connect(ssid)
|
|
330
|
+
assert s.passed_parameters == ['device', 'wifi', 'connect', ssid]
|
|
331
|
+
|
|
332
|
+
|
|
289
333
|
def test_wifi_connect_when_connection_activate_failed():
|
|
290
334
|
s = DummySystemCommand(
|
|
291
335
|
'''Error: Connection activation failed: (7) Secrets were required, but not provided.
|
|
@@ -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,42 @@ 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',
|
|
63
|
+
'reload', 'conf', 'dns-rc', 'dns-full']
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_reload_with_invalid_flag():
|
|
67
|
+
s = DummySystemCommand()
|
|
68
|
+
general = GeneralControl(s)
|
|
69
|
+
with pytest.raises(ValueError) as exc_info:
|
|
70
|
+
general.reload(['invalid-flag'])
|
|
71
|
+
assert "Invalid reload flag 'invalid-flag'" in str(exc_info.value)
|
|
72
|
+
assert "Valid flags are: conf, dns-rc, dns-full" in str(exc_info.value)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_reload_with_mixed_valid_and_invalid_flags():
|
|
76
|
+
s = DummySystemCommand()
|
|
77
|
+
general = GeneralControl(s)
|
|
78
|
+
with pytest.raises(ValueError) as exc_info:
|
|
79
|
+
general.reload(['conf', 'invalid'])
|
|
80
|
+
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
|