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

[201911]SKU Creator Tool #1245

Conversation

madhanmellanox
Copy link
Contributor

- What I did
I added a new script file sonic_sku_create.py to generate a new HWSKU based on XML file or Minigraph. But, focus is on creating HWSKU based on XML file and not on the minigraph and l2 mode. I also added a unit test pyTest script sku_create_test.py in sonic-utilities-test folder to test the script in Unit Testing mode.

Motivation: To create SKU for Mellanox platforms based on XML file with Port related inputs and also through Minigraph file.
This tool also allows to split a port or unsplit ports based on configuration which modifies the port related information in port_config.ini and config_db.json

usage: sonic_sku_create.py [-h] [-v]
(-f FILE | -m [MINIGRAPH_FILE] | -j JSON_FILE | -pp PORT_SPLIT PORT_SPLIT)
[-b BASE] [-r] [-k HWSKU] [-p] [-vv]

Create a new SKU

optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-f FILE, --file FILE SKU definition from xml file. -f OR -m or -j must be provided when creating a new SKU
-m [MINIGRAPH_FILE], --minigraph_file [MINIGRAPH_FILE]
SKU definition from minigraph file. -f OR -m or -j must be provided when creating a new SKU
-j JSON_FILE, --json_file JSON_FILE
SKU definition from config_db.json file. -f OR -m OR -j must be provided when creating a new SKU
-pp PORT_SPLIT PORT_SPLIT, --port_split PORT_SPLIT PORT_SPLIT
port name and split
-b BASE, --base BASE SKU base definition
-r, --remove Remove SKU folder
-k HWSKU, --hwsku HWSKU
SKU name to be used when creating a new SKU or for L2 configuration mode
-p, --print Print port_config.ini without creating a new SKU
-vv, --verbose Verbose output

Output:
Creation of Port_config.ini file.
Modifying Port_config.ini and config_db.json based on port split and unsplit configuration.

- How I did it
I did it by adding these files which are required for new SKU generation in the forthcoming releases.

- How to verify it
I verified all the options of sonic_sku_create.py file and tested them thoroughly as well as created a test case in sku_create_test.py file to test the functionality of sonic_sku_create.py in Unit Test mode.

- Previous command output (if the output of a command-line utility has changed)
None

- New command output (if the output of a command-line utility has changed)

admin@r-qa-sw-eth-2134:/tmp$ sudo python sonic_sku_create.py -f Mellanox-SN2700-C28D10.xml
MSN2700 -  even front panel ports ( 32 ) are not allowed to split by 4
Error - Illegal split by 4
admin@r-qa-sw-eth-2134:/tmp$ sudo python sonic_sku_create.py -f Mellanox-SN2700-C28D11.xml
SKU directory: /usr/share/sonic/device/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D11/ already exists
 Please use -r flag to remove the SKU dir first
admin@r-qa-sw-eth-2134:/tmp$
admin@r-qa-sw-eth-2134:/tmp$ sudo python sonic_sku_create.py -r -f Mellanox-SN2700-C28D11.xml
You are about to permanently delete the SKU /usr/share/sonic/device/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D11/ !!
Do you want to continue (Yes/No)?Yes
SKU directory: /usr/share/sonic/device/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D11/ was removed
admin@r-qa-sw-eth-2134:/tmp$ sudo python sonic_sku_create.py  -f Mellanox-SN2700-C28D11.xml
Created a new sku (Location: /usr/share/sonic/device/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D11/)
admin@r-qa-sw-eth-2134:/tmp$
admin@r-qa-sw-eth-2134:/tmp$ sudo python sonic_sku_create.py -m ams20-0101-0623-08t0.xml
SKU directory: /usr/share/sonic/device/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/ already exists
 Please use -r flag to remove the SKU dir first
admin@r-qa-sw-eth-2134:/tmp$ sudo python sonic_sku_create.py -r -m ams20-0101-0623-08t0.xml
You are about to permanently delete the SKU /usr/share/sonic/device/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/ !!
Do you want to continue (Yes/No)?Yes
SKU directory: /usr/share/sonic/device/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/ was removed
admin@r-qa-sw-eth-2134:/tmp$ sudo python sonic_sku_create.py -m ams20-0101-0623-08t0.xml
Created a new sku (Location: /usr/share/sonic/device/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/)
admin@r-qa-sw-eth-2134:/tmp$
admin@r-qa-sw-eth-2134:/tmp$ sudo python sonic_sku_create.py -j config_db_fra.json
Created a new sku (Location: /usr/share/sonic/device/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-test/)
admin@r-qa-sw-eth-2134:/tmp$ sudo python sonic_sku_create.py -pp Ethernet0 4x25
['name', 'lanes', 'alias', 'index']
port_config.ini file does not contain all fields, Exiting...
admin@r-qa-sw-eth-2134:/tmp$
admin@r-qa-sw-eth-2134:/tmp$ sudo python sonic_sku_create.py -pp Ethernet0 4x25 -vv
ARGS:  Namespace(base=None, file=None, hwsku=None, json_file=None, minigraph_file=None, port_split=['Ethernet0', '4x25'], print=False, remove=False, verbose=True)
['name', 'lanes', 'alias', 'index', 'speed']
msn2700_specific -> Removing  ['Ethernet5', [1, 2, 3, 4], 'etp2a', '5', '50000']
msn2700_specific -> Removing  ['Ethernet6', [1, 2, 3, 4], 'etp2b', '6', '50000']
MSN2700 - Front panel port  2  should be removed due to port  1 Split by 4
Error - Illegal split by 4
admin@r-qa-sw-eth-2134:/tmp$
madhan@arc-build-server:/builds2/madhan/utilitiescloneskucreate0714/sonic-utilities/sonic-utilities-tests$ sudo pytest -v sku_create_test.py -s
==================================================================== test session starts ====================================================================
platform linux2 -- Python 2.7.6, pytest-3.0.0, py-1.5.2, pluggy-0.3.1 -- /usr/bin/python2
cachedir: .cache
rootdir: /builds2/madhan/utilitiescloneskucreate0714/sonic-utilities/sonic-utilities-tests, inifile: pytest.ini
collected 1 items

sku_create_test.py::TestSkuCreate::test_no_param Created a new sku (Location: /builds2/madhan/utilitiescloneskucreate0714/sonic-utilities/sonic-utilities-tests/sku_create_input/Mellanox-SN2700-D48C8_NEW/)

('Output file: ', '/builds2/madhan/utilitiescloneskucreate0714/sonic-utilities/sonic-utilities-tests/sku_create_input/Mellanox-SN2700-D48C8_NEW/port_config.ini', 'exists. SUCCESS!')
('Output file: ', '/builds2/madhan/utilitiescloneskucreate0714/sonic-utilities/sonic-utilities-tests/sku_create_input/Mellanox-SN2700-D48C8_NEW/port_config.ini', ' and model file: ', '/builds2/madhan/utilitiescloneskucreate0714/sonic-utilities/sonic-utilities-tests/sku_create_input/Mellanox-SN2700-D48C8/port_config.ini', 'contents are same. SUCCESS!')
PASSEDTEARDOWN


================================================================= 1 passed in 0.47 seconds ==================================================================
madhan@arc-build-server:/builds2/madhan/utilitiescloneskucreate0714/sonic-utilities/sonic-utilities-tests$

@lgtm-com
Copy link

lgtm-com bot commented Nov 16, 2020

This pull request introduces 1 alert when merging 99565ed into c0df635 - view on LGTM.com

new alerts:

  • 1 for 'input' function used in Python 2

@madhanmellanox
Copy link
Contributor Author

retest this please

@@ -0,0 +1,776 @@
#!/usr/bin/env python3
Copy link
Contributor

Choose a reason for hiding this comment

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

This script should be Python 2 compatible and the shebang should read #!/usr/bin/env python2 for 201911 branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in next commit.

@lgtm-com
Copy link

lgtm-com bot commented Nov 17, 2020

This pull request introduces 1 alert when merging a4fc991 into c0df635 - view on LGTM.com

new alerts:

  • 1 for 'input' function used in Python 2

@jleveque
Copy link
Contributor

It appears you copied over the code from the master branch after I converted it to Python 3, which explains the shebang and the LGTM alerts. This code needs to be Python 2-compatible in the 201911 branch.

@madhanmellanox
Copy link
Contributor Author

Closing this PR because I have created a similar PR with cherry pick from Master branch.
#1250

stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
 Revert "Refine getDbId() calling to fix build after swss-common change (sonic-net#1245)"

 This shoudl fix VS build.

Signed-off-by: Abhishek Dosi <[email protected]>
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
 [sonic-swsss] Fix the issue of field "next_hop_ip" not getting updated
 in state DB in ERSPAN Mirror (sonic-net#1375)
[vlanmgr] Support Jumbo Frame By Default (sonic-net#1393)
[fec] added logic that put port down before applying fec
onfiguration (sonic-net#1399)
 [fec] Get FEC mode when port is already admin down (sonic-net#1403)
 Refine getDbId() calling to fix build after swss-common change
 (sonic-net#1245)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants