Commit e7535ae
authored
[sonic-cli-gen] first phase implementation of the SONiC CLI Auto-generation tool (#1644)
What I did
Implemented the sonic-cli-gen according to the SONiC CLI Auto-generation HLD
How I did it
How the sonic-cli-gen works:
Parse provided YANG model to the intermediate representation - python dictionary (you can find the structure in the sonic_cli_gen/yang_parser.py file).
Pass the python dictionary to the appropriate j2 template (config or show) and generate the CLI plugin.
Put the auto-generated CLI plugin to an appropriate location, where it can be discovered by SONiC CLI.
How to verify it
Check the file with unit tests - tests/cli_autogen_yang_parser_test.py
Command output
admin@sonic: sonic-cli-gen generate config sonic-acl
Loaded below Yang Models
['sonic-acl', 'sonic-breakout_cfg', 'sonic-crm', 'sonic-device_metadata', 'sonic-device_neighbor', 'sonic-extension', 'sonic-flex_counter', 'sonic-interface', 'sonic-loopback-interface', 'sonic-port', 'sonic-portchannel', 'sonic-types', 'sonic-versions', 'sonic-vlan', 'sonic-vrf']
Note: Below table(s) have no YANG models:
COPP_GROUP, COPP_TRAP, FEATURE, KDUMP, MGMT_INTERFACE, SNMP, SNMP_COMMUNITY, WJH, WJH_CHANNEL,
INFO:sonic-cli-gen: Auto-generation successful! Location: /usr/local/lib/python3.7/dist-packages/config/plugins/auto/sonic-acl_yang.py
admin@sonic: sonic-cli-gen remove config sonic-acl
/usr/local/lib/python3.7/dist-packages/config/plugins/auto/sonic-acl_yang.py was removed.1 parent a3e34e3 commit e7535ae
39 files changed
Lines changed: 3759 additions & 8 deletions
File tree
- clear
- plugins/auto
- config
- plugins/auto
- show
- plugins/auto
- sonic-utilities-data
- bash_completion.d
- debian
- templates/sonic-cli-gen
- sonic_cli_gen
- tests
- cli_autogen_input
- autogen_test
- yang_parser_test
- utilities_common
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
487 | | - | |
488 | | - | |
| 487 | + | |
489 | 488 | | |
490 | 489 | | |
491 | 490 | | |
| |||
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5966 | 5966 | | |
5967 | 5967 | | |
5968 | 5968 | | |
5969 | | - | |
5970 | | - | |
| 5969 | + | |
5971 | 5970 | | |
5972 | 5971 | | |
5973 | 5972 | | |
| |||
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| |||
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
| 62 | + | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
| |||
172 | 176 | | |
173 | 177 | | |
174 | 178 | | |
| 179 | + | |
175 | 180 | | |
176 | 181 | | |
177 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1701 | 1701 | | |
1702 | 1702 | | |
1703 | 1703 | | |
1704 | | - | |
1705 | | - | |
| 1704 | + | |
1706 | 1705 | | |
1707 | 1706 | | |
1708 | 1707 | | |
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments