-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sonic-cli-gen] first phase implementation of the SONiC CLI Auto-gene…
…ration 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.
- Loading branch information
1 parent
a3e34e3
commit e7535ae
Showing
39 changed files
with
3,759 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
_sonic_cli_gen_completion() { | ||
COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \ | ||
COMP_CWORD=$COMP_CWORD \ | ||
_SONIC_CLI_GEN_COMPLETE=complete $1 ) ) | ||
return 0 | ||
} | ||
|
||
complete -F _sonic_cli_gen_completion -o default sonic-cli-gen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
bash_completion.d/ /etc/ | ||
templates/*.j2 /usr/share/sonic/templates/ | ||
bash_completion.d/ /etc/ | ||
templates/*.j2 /usr/share/sonic/templates/ | ||
templates/sonic-cli-gen/*.j2 /usr/share/sonic/templates/sonic-cli-gen/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro cli_name(name) -%} | ||
{{ name|lower|replace("_", "-") }} | ||
{%- endmacro %} |
Oops, something went wrong.