Newer
Older
Tools and test suites developed for the 4th ETSI mWT SDN Plugtests
ETSI is organizing the 4th mWT (millimetre Wave Transmission) SDN (Software Defined Network) Plugtests™ event under the mWT Plugtests Programme.
Contact: plugtests@etsi.org.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
### Script launch & first steps
The Lightweight NETCONF Controller is build on top of _cmd2_ Python package : it benefits from all [built-in features](https://cmd2.readthedocs.io/en/stable/features/index.html): [help](https://cmd2.readthedocs.io/en/stable/features/help.html), [history](https://cmd2.readthedocs.io/en/stable/features/history.html), [script](https://cmd2.readthedocs.io/en/stable/features/scripting.html) and more...
Start as any script: `python3 lncc.py` or `./lncc.py`.
* You will get help using the `help` command. More verbose will be available in future, using `help <command>` or `command --help`.
* You will exit using `quit` command or EOF (Ctrl+D).
<details><summary>help & quit commands feedback</summary>
```console
$ python3 lncc.py
Welcome to the Lightweight NETCONF Controller lncc.py
Type 'help' for more information
(Cmd) help
Documented commands (use 'help -v' for verbose/'help <topic>' for details):
Input & output handling
=======================
sleep table
NETCONF
=======
connect netconf
Parameter management
====================
mapping ne
Uncategorized
=============
alias help macro run_pyscript set shortcuts
edit history quit run_script shell
(Cmd) quit
$
```
</details>
<details><summary>"help netconf" commands feedback</summary>
```console
$ python3 lncc.py
Welcome to the Lightweight NETCONF Controller lncc.py
Type 'help' for more information
(Cmd) help netconf
Usage: netconf [-h] [--reply REPLY-NAME]
{get, get-config, edit-config, copy-config, delete-config, lock,
Run NETCONF operations on NEs
optional arguments:
-h, --help show this help message and exit
--reply REPLY-NAME
NETCONF operations:
{get, get-config, edit-config, copy-config, delete-config, lock, unlock, clos
(Cmd)
(Cmd) help netconf
Usage: netconf [-h] [--reply REPLY-NAME]
{get, get-config, edit-config, copy-config, delete-config,
lock, unlock, close-session, kill-session, commit,
discard-changes, cancel-commit, validate} ...
Run NETCONF operations on NEs
optional arguments:
-h, --help show this help message and exit
--reply REPLY-NAME
NETCONF operations:
{get, get-config, edit-config, copy-config, delete-config, lock, unlock, close-session, kill-session, commit, discard-changes, cancel-commit, validate}
(Cmd) quit
```
</details>
### Quick example
- Adding NEs or loading NEs --> `ne add`,
- connect to NEs --> `connect`,
- run NETCONF operations on NEs (get, edit-config, close-session, ...), -> The results is stored with the operation's name.
- transform NETCONF operations replies,
- write tranformed informations as file.
#### Add NEs
```
(Cmd) ne add my_ne1 --host 172.20.183.168 --username netconfuser --password NotSoSecret123*
NE my_ne1 added, current: 1 NEs
(Cmd) ne add my_ne2 --host 172.20.183.169 --username netconfuser --password NotSoSecret123* --port 830
NE my_ne2 added, current: 2 NEs
```
You can save NEs configuration in a YAML file using `ne dump my_nes.yaml`. Then load using `ne load my_nes.yaml`
#### Connect to all NEs
```
(Cmd) connect
2 new connections, 2 total: ['my_ne1', 'my_ne2']
```
#### Run NETCONF operations
```
(Cmd) netconf get --filter-file interface_type_microwaveCarrierTermination_filter.xml
NETCONF <get> operation completed: 2 NEs, stored in 'get'
```
#### Transform the results
```
(Cmd) table from_xml --xsl-transform get-interface-transform.xsl
New tables 'get' in each NE, build from XML stored in 'get'
(Cmd) table concat
Table 'get' available for group
(Cmd) table to_excel interfaces.xlsx
Wrote Excel file interfaces.xlsx, with 1 tabs: args.tables
```
### Creating a script
If the commands you can convert
We rely on _cmd2_ build-in commands: [`history --script`](https://cmd2.readthedocs.io/en/stable/features/history.html#for-users) then `run_script`.
Once the set of command make a interesting scenario, you can save it as TXT script file. You can edit this TXT script with you usual editor (type `edit` build-in command to start vim).
```
(Cmd) history --script > get_interface_inventory_script2.txt
(Cmd)
```
Then let's play again the same command sequence, using `run_script` command. You may see errors if you keep adding NEs taht exists.
```
(Cmd) run_script get_interface_inventory_script2.txt
Error: NE my_ne1 already exist
Error: NE my_ne2 already exist
0 new connections, 2 total: ['my_ne1', 'my_ne2']
NETCONF <get> operation completed: 2 NEs, stored in 'get'
New tables 'get' in each NE, build from XML stored in 'get'
Table 'get' available for group
Wrote Excel file interfaces.xlsx, with 1 tabs: args.tables
```
### Creating a transcript
Transcripts enable us to compare the script behavior from different NEs. Transcript records both the commands input and their ouputs. Transcript are created with the ['--transcript' argument of the 'run_script'](https://cmd2.readthedocs.io/en/stable/features/transcripts.html) command.
In order to compare the behavior, we need to redirect the feedback (~stderr) to the ouput (~stdout), using the `set feedback_to_output true`command.
```
(Cmd) set feedback_to_output true
(Cmd) run_script get_interface_inventory_script2.txt --transcript get_interface_inventory_transcript2.txt
7 commands and their outputs saved to transcript file '/home/jean/lncc/get_interface_inventory_transcript2.txt'
```
### Test a transcript
[Transcipt](https://cmd2.readthedocs.io/en/stable/features/transcripts.html#running-a-transcript) have to be run from your shell (not inside the lncc.py!).
It will play the commands and will compare the output of these commands with the content of the transcript.
```console
$ python3 lncc.py --test get_interface_inventory_transcript.txt
=========================================== cmd2 transcript test ============================================
platform linux -- Python 3.8.10, cmd2-2.4.0, readline-RlType.GNU
cwd: /home/jean/lncc
cmd2 app: lncc.py
collected 1 transcript
.
----------------------------------------------------------------------
Ran 1 test in 3.459s
OK
=================================== 1 transcript passed in 3.459 seconds ====================================
$
```
## Sharing your transcript
The command-line doesn't containt vendor-specific informations: they can be share to check that the behavior is common.
## Already available transcripts
2 transcript are already available, as of May 9th 2022:
- _get_interface_inventory_transcript.txt_ -- Basically the scenario described in this tutorial
- _set_tx_power_transcript.txt_
<details><summary>get_interface_inventory: script & transcript</summary>
```console
$ cat get_interface_inventory_script.txt
# get_interface_inventory_script.txt : script for Lightweight NETCONF controlleur lncc.py
# run me using: lncc.py 'run_script set_tx_power_script.txt' quit
set feedback_to_output true
ne load ne.yaml
# set logging_config logging_config.yaml
connect
netconf get --filter-file interface_type_microwaveCarrierTermination_filter.xml
netconf close-session
table from_xml --xsl-transform get-interface-transform.xsl
table concat
table to_excel interfaces.xlsx
```
```console
$ cat get_interface_inventory_transcript.txt
(Cmd) # get_interface_inventory_script.txt : script for Lightweight NETCONF controlleur lncc.py
(Cmd) # run me using: lncc.py 'run_script set_tx_power_script.txt' quit
(Cmd) set feedback_to_output true
feedback_to_output - was: False
now: True
(Cmd) ne load ne.yaml
Loading complete: 2 new NEs: ['ne1', 'ne2']
(Cmd) # set logging_config logging_config.yaml
(Cmd) connect
2 new connections, 2 total: ['ne1', 'ne2']
(Cmd) netconf get --filter-file interface_type_microwaveCarrierTermination_filter.xml
NETCONF <get> operation completed: 2 NEs, stored in 'get'
(Cmd) netconf close-session
NETCONF <close-session> operation completed: 2 NEs, stored in 'close-session'
(Cmd) table from_xml --xsl-transform get-interface-transform.xsl
New tables 'get' in each NE, build from XML stored in 'get'
(Cmd) table concat
Table 'get' available for group
(Cmd) table to_excel interfaces.xlsx
Wrote Excel file interfaces.xlsx, with 1 tabs: args.tables
```
</details>
<details><summary>set_tx_power: script & transcript</summary>
```console
$ cat set_tx_power_script.txt
# set_tx_power_script.txt for Lightweight NETCONF controlleur lncc.py
# run using: lncc.py 'run_script set_tx_power_script.txt' quit
set feedback_to_output true
ne load ne.yaml
mapping add set-power --ne ne1 '{if-name: RTL-63-255-1, tx-power: -8}'
mapping add set-power --ne ne2 '{if-name: RTL-63-255-1, tx-power: -7}'
connect
netconf lock
netconf edit-config --config-template set_tx_power.xml.pyformat --mappings set-power
netconf commit --confirmed
sleep 10
netconf commit
netconf unlock
netconf close-session
```
```console
$ cat set_tx_power_transcript.txt
(Cmd) # set_tx_power_script.txt for Lightweight NETCONF controlleur lncc.py
(Cmd) # run using: lncc.py 'run_script set_tx_power_script.txt' quit
(Cmd) set feedback_to_output true
feedback_to_output - was: False
now: True
(Cmd) ne load ne.yaml
Loading complete: 2 new NEs: ['ne1', 'ne2']
(Cmd) mapping add set-power --ne ne1 '{if-name: RTL-63-255-1, tx-power: -8}'
(Cmd) mapping add set-power --ne ne2 '{if-name: RTL-63-255-1, tx-power: -7}'
(Cmd) connect
2 new connections, 2 total: ['ne1', 'ne2']
(Cmd) netconf lock
NETCONF <lock> operation completed: 2 NEs, stored in 'lock'
(Cmd) netconf edit-config --config-template set_tx_power.xml.pyformat --mappings set-power
NETCONF <edit-config> operation completed: 2 NEs, stored in 'edit-config'
(Cmd) netconf commit --confirmed
NETCONF <commit> operation completed: 2 NEs, stored in 'commit'
(Cmd) sleep 10
Sleeping for 10 seconds
(Cmd) netconf commit
NETCONF <commit> operation completed: 2 NEs, stored in 'commit'
(Cmd) netconf unlock
NETCONF <unlock> operation completed: 2 NEs, stored in 'unlock'
(Cmd) netconf close-session
NETCONF <close-session> operation completed: 2 NEs, stored in 'close-session'
```
</details>
## License
The content of the present repository is released under the BSD-3 Clause license.