Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sonic-cli-gen] first phase implementation of the SONiC CLI Auto-generation tool #1644

Merged
merged 83 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
548896a
Worked version
vadymhlushko-mlnx Apr 22, 2021
3350f27
added stub for function to determine static or dynamic YANG
vadymhlushko-mlnx Apr 23, 2021
1d1643a
_find_index_of_yang_model()
vadymhlushko-mlnx Apr 26, 2021
cd31f0d
added function to init list's for module, top, tables
vadymhlushko-mlnx Apr 26, 2021
81b803d
Added func to determine - static or list, +comments
vadymhlushko-mlnx Apr 26, 2021
ecdf8b6
Added auto compleation file
vadymhlushko-mlnx Apr 28, 2021
42779c7
Add CLI Jinja templates
stepanblyschak Apr 28, 2021
12bf0b2
Fix the generated function name is incorrect
stepanblyschak Apr 28, 2021
c8eaa66
update and enhance templates with multiple lists in container
stepanblyschak Apr 29, 2021
dd29e33
fix cli templates
stepanblyschak Apr 29, 2021
0b0a0c1
Merge branch 'master' of github.com:azure/sonic-utilities into sonic-…
stepanblyschak Apr 29, 2021
16857c4
add clear list command
stepanblyschak Apr 29, 2021
dfa3ccc
Parsing for static YANG models - sonic-flex_counter.yang, sonic-devic…
vadymhlushko-mlnx Apr 30, 2021
6b75f4b
Done refactoring for parsing 'static' YANG models
vadymhlushko-mlnx May 5, 2021
d2be52b
Added parsing for 'dynamic' YANG models, done refactoring of whole code
vadymhlushko-mlnx May 6, 2021
73a3b12
Done parser for 'grouping' BUT need to deeply test it, added function…
vadymhlushko-mlnx May 12, 2021
718f8ab
align with implementation
May 12, 2021
647537c
Merge branch 'sonic-cli-gen' of github.com:vadymhlushko-mlnx/sonic-ut…
May 12, 2021
fa6299c
generate cli from templates
May 12, 2021
9d9f66b
Table can only have 'static-objects' OR 'dynamic-objects'
vadymhlushko-mlnx May 12, 2021
38f4365
add missing " in help for option
May 12, 2021
591aced
Merge branch 'sonic-cli-gen' of github.com:vadymhlushko-mlnx/sonic-ut…
May 12, 2021
0826ac5
Added remove_keys(), get_mandatory()
vadymhlushko-mlnx May 12, 2021
069000f
fix issues
May 12, 2021
594acce
Merge branch 'sonic-cli-gen' of github.com:vadymhlushko-mlnx/sonic-ut…
May 12, 2021
1723f0f
Refactored generator.py: generate_cli_plugin(), get_cli_plugin_path()
vadymhlushko-mlnx May 13, 2021
0a78e19
Removed arguments from constructor of class CliGenerator, added funct…
vadymhlushko-mlnx May 13, 2021
30d2cb9
Added sceleton for UT, added additional check for yang_parser.py, cha…
vadymhlushko-mlnx May 14, 2021
0d371de
Refactored _init_yang_module_and_containers()
vadymhlushko-mlnx May 14, 2021
1593039
added 2 test cases
vadymhlushko-mlnx May 14, 2021
9004c1c
[sonic-cli-gen] put autogenerated plugins into plugins.auto
stepanblyschak May 17, 2021
32e27a2
[sonic-cli-gen] fix show.py.j2 template
stepanblyschak May 17, 2021
02e6d27
[sonic-cli-gen] add remove plugin method
stepanblyschak May 17, 2021
cb7fa06
refactored past test cases, added new
vadymhlushko-mlnx May 17, 2021
5737f5f
added test_dynamic_object_complex
vadymhlushko-mlnx May 17, 2021
7b167a6
[sonic-cli-gen] implement grouping in show template
stepanblyschak May 18, 2021
16e0cca
Reworked 'grouping' parser
vadymhlushko-mlnx May 18, 2021
b0fb3a9
Added 'group' to 'attrs'
vadymhlushko-mlnx May 18, 2021
e2acf73
Fixed 'grouping' parsing
vadymhlushko-mlnx May 19, 2021
3305faa
DONE. ALL UT PASSED
vadymhlushko-mlnx May 19, 2021
30e8ac9
Refactored UT
vadymhlushko-mlnx May 19, 2021
15aeb8c
Added docstrings, fixed names of variables
vadymhlushko-mlnx May 19, 2021
ea2c838
Added test_grouping_complex to the execution pipeline
vadymhlushko-mlnx May 19, 2021
f7a7ed2
Merge remote-tracking branch 'vadymh/sonic-cli-gen' into sonic-cli-gen
vadymhlushko-mlnx May 20, 2021
e18c888
Removed unused test YANG model
vadymhlushko-mlnx May 20, 2021
7bd3ec9
Fixed indentation
vadymhlushko-mlnx May 21, 2021
d5dea7f
Added sonic-cli-gen remove cmd, reworked private initializer functions
vadymhlushko-mlnx May 21, 2021
aa4af1c
Added new lines, fixed some docstrings
vadymhlushko-mlnx May 24, 2021
718a431
removed type from docstring
vadymhlushko-mlnx May 24, 2021
2907523
Added list_handler()
vadymhlushko-mlnx May 24, 2021
a005d6d
[sonic-cli-gen] address review comments
stepanblyschak May 21, 2021
aa00b61
[sonic-cli-gen] fix review comments
stepanblyschak May 24, 2021
fd931ad
Merge branch 'sonic-cli-gen' of github.com:vadymhlushko-mlnx/sonic-ut…
stepanblyschak May 24, 2021
5c4e219
Fixed comments, added list_handler() where needed
vadymhlushko-mlnx May 24, 2021
6de672c
Added logger to CliGenerator class constructor
vadymhlushko-mlnx May 24, 2021
2a2f9f2
Merge remote-tracking branch 'vadymh/sonic-cli-gen' into sonic-cli-gen
vadymhlushko-mlnx May 24, 2021
1584fe3
pep8 for generator.py
vadymhlushko-mlnx May 25, 2021
8f27d03
pep8 for the rest of files
vadymhlushko-mlnx May 25, 2021
aa6f806
pep8 for tests files, added comments to YANG models
vadymhlushko-mlnx May 25, 2021
83ce9ee
Added handler for 1 'choice' 'case'
vadymhlushko-mlnx May 25, 2021
702be74
Code style
vadymhlushko-mlnx May 25, 2021
c433a4c
Fixed review comments
vadymhlushko-mlnx May 26, 2021
94cde8e
Changed tabs to spaces
vadymhlushko-mlnx Aug 30, 2021
5fec4a7
Removed unnecessary config_db.json file
vadymhlushko-mlnx Aug 31, 2021
3cd8ad9
Added test case, added support for UT for sonic-cli-gen implementation
vadymhlushko-mlnx Sep 7, 2021
607b254
Added registering of plugins to UT
vadymhlushko-mlnx Sep 7, 2021
6816903
Fixed name
vadymhlushko-mlnx Sep 7, 2021
2aee883
Added helper.load_and_register_plugins()
vadymhlushko-mlnx Sep 8, 2021
9fea6db
Added test cases for sonic-device_metadata
vadymhlushko-mlnx Sep 9, 2021
69926ed
Added cli_autogen_common.py, added separate dir for each cli_autogen …
vadymhlushko-mlnx Sep 10, 2021
dd7ec5e
Added backup and restore func for yang models
vadymhlushko-mlnx Sep 10, 2021
eb85200
Removed if-else UT login from generator.py
vadymhlushko-mlnx Sep 10, 2021
5ccefa6
Added couple UT for device-neighbor
vadymhlushko-mlnx Sep 13, 2021
37ac0b7
Added UT for update flow
vadymhlushko-mlnx Sep 14, 2021
4402203
Fixed codestyle
vadymhlushko-mlnx Sep 14, 2021
9d07092
Fixed codestyle
vadymhlushko-mlnx Sep 14, 2021
5b6a8aa
Fixed test path variables
vadymhlushko-mlnx Sep 14, 2021
df1d329
[sonic-cli-gen] add docstrings
stepanblyschak Oct 21, 2021
9e1854f
use dict.pop() with default value
stepanblyschak Nov 1, 2021
f2677a1
if no data ion update_entry_validated() abort
stepanblyschak Nov 1, 2021
4e0ac3e
if entry config did not change avoid calling set_entry()
stepanblyschak Nov 2, 2021
6a7d7fa
pass a copy of cfg to FormatConverter.to_serialized() as it modifies …
stepanblyschak Nov 4, 2021
afc4afb
Added exception handling for j2 templates
vadymhlushko-mlnx Nov 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,7 @@ def translations():

# Load plugins and register them
helper = util_base.UtilHelper()
for plugin in helper.load_plugins(plugins):
helper.register_plugin(plugin, cli)
helper.load_and_register_plugins(plugins, cli)


if __name__ == '__main__':
Expand Down
Empty file added clear/plugins/auto/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4562,8 +4562,7 @@ def delete(ctx):

# Load plugins and register them
helper = util_base.UtilHelper()
for plugin in helper.load_plugins(plugins):
helper.register_plugin(plugin, config)
helper.load_and_register_plugins(plugins, config)


if __name__ == '__main__':
Expand Down
Empty file added config/plugins/auto/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
'acl_loader',
'clear',
'clear.plugins',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the below PR also has the same changes for some files, are we planning to consolidate the changes in one PR?

https://github.com/Azure/sonic-utilities/pull/1650/files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes from this PR was added to https://github.com/Azure/sonic-utilities/pull/1650/files in order to pass CI, once this PR will be merged, the changes will be removed from https://github.com/Azure/sonic-utilities/pull/1650/files

'clear.plugins.auto',
'config',
'config.plugins',
'config.plugins.auto',
'connect',
'consutil',
'counterpoll',
Expand All @@ -46,6 +48,7 @@
'show',
'show.interfaces',
'show.plugins',
'show.plugins.auto',
'sonic_installer',
'sonic_installer.bootloader',
'sonic_package_manager',
Expand All @@ -54,6 +57,7 @@
'undebug',
'utilities_common',
'watchdogutil',
'sonic_cli_gen',
],
package_data={
'show': ['aliases.ini'],
Expand Down Expand Up @@ -157,6 +161,7 @@
'spm = sonic_package_manager.main:cli',
'undebug = undebug.main:cli',
'watchdogutil = watchdogutil.main:watchdogutil',
'sonic-cli-gen = sonic_cli_gen.main:cli',
]
},
install_requires=[
Expand Down
3 changes: 1 addition & 2 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,8 +1473,7 @@ def ztp(status, verbose):

# Load plugins and register them
helper = util_base.UtilHelper()
for plugin in helper.load_plugins(plugins):
helper.register_plugin(plugin, cli)
helper.load_and_register_plugins(plugins, cli)


if __name__ == '__main__':
Expand Down
Empty file added show/plugins/auto/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions sonic-utilities-data/bash_completion.d/sonic-cli-gen
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;
5 changes: 3 additions & 2 deletions sonic-utilities-data/debian/install
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/
3 changes: 3 additions & 0 deletions sonic-utilities-data/templates/sonic-cli-gen/common.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% macro cli_name(name) -%}
{{ name|lower|replace("_", "-") }}
{%- endmacro %}
Loading