-
Notifications
You must be signed in to change notification settings - Fork 670
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_sku_create.py util for generating a new sku #547
base: master
Are you sure you want to change the base?
Conversation
Utility for creating a new SKU on existing image. SKU definition is provided in an xml file
Added base (-b) flag to support base sku instead of extracting it from xml. In addition updated with support to the new xml format dfinition
Swapped Speed and Alias columns. In addition added support for L2 mode
retest this please |
sonic_sku_create/sonic_sku_create.py
Outdated
parser.add_argument('-b', '--base', action='store', help='SKU base definition ', default=None) | ||
parser.add_argument('-r', '--remove', action='store_true', help='Remove SKU folder') | ||
parser.add_argument('-c', '--cmd', action='store', choices=['new_sku_only', 'l2_mode_only', 'new_sku_l2'], help='Choose action to preform (Generate a new SKU, Configure L2 mode, Both', default="new_sku_only") | ||
parser.add_argument('-l2_sku_name', '--l2_sku_name', action='store', help='SKU name to be used in the L2 configuration mode', default=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l2_sku_name [](start = 23, length = 11)
In concept, SKU is independent with L2 mode. So there is no l2_sku_name.
We already have feature to config any SKU into L2 mode https://github.com/Azure/SONiC/wiki/L2-Switch-mode#3-generate-a-configuration-for-l2-switch-mode. If your feature is the same, let's keep original method, and remove feature duplication here. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The l2_mode option in the script is just an implementation of the process described ( [https://github.com/Azure/SONiC/wiki/L2-Switch-mode#3-generate-a-configuration-for-l2-switch-mode.]).
Instead of manually doing it step by step, the script is doing everything.
Why do you want to remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As comments
sonic_sku_create/sonic_sku_create.py
Outdated
@@ -0,0 +1,329 @@ | |||
#! /usr/bin/python | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this script into /script directory?
Add it into setup.py?
Add a unit test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into scripts directory and added it to setup.py
Fixed PR comments and added few improvments
Moved script to scripts folder
Removed SKU def file from commit
added sonic_sku_create to scripts
try: | ||
platform = subprocess.check_output("sonic-cfggen -H -v DEVICE_METADATA.localhost.platform",shell=True) #self.metadata['platform'] | ||
self.platform = platform.rstrip() | ||
except KeyError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except KeyError [](start = 2, length = 15)
If this is critical, we should exit. #Closed
Fixed L2 mode configuration in case no l2_sku_name is provided
-m (minigraph) and -f (file) are mutually exclusive options to create a new SKU
Clean up
scripts/sonic_sku_create.py
Outdated
""" | ||
usage: sonic_sku_create.py [-h] [-v] [-f FILE | -m MINIGRAPH] [-b BASE] [-r] | ||
[-c {new_sku_only,l2_mode_only,new_sku_l2}] | ||
[-s SKU] [-p] [-vv] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s [](start = 29, length = 1)
Not your fault. Let's make it -k to be consistent with https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-config-engine/sonic-cfggen #Closed
scripts/sonic_sku_create.py
Outdated
self.platform = platform.rstrip() | ||
except KeyError: | ||
print ("Couldn't find platform info in CONFIG_DB DEVICE_METADATA", file=sys.stderr) | ||
exit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit [](start = 3, length = 4)
In exception cases, exit with non-zero error codes. Multiple times in this script. #Closed
changed -s flag to -k fixed exit code to non-zero added a check to ensure user can't remove the base/default SKU
Fixed l2 mode
fix -c flag
Removed the usage of "Index" information from xml sku definition file and minigraph as this is not a reilable field.
retest this please |
This pull request introduces 6 alerts when merging 503585a into d03d151 - view on LGTM.com new alerts:
|
This pull request introduces 6 alerts when merging a500e7e into b37135c - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 4a261df into b37135c - view on LGTM.com new alerts:
|
Please fix remaining LGTM error, and add unit test |
- What I did
Created a utility for generating a new SKU based on a base sku (-b) and a sku definition file (-f)
- How I did it
Copied the base sku folder and modified port_config.ini based on the sku definition
- How to verify it
Tested on Mellanox platform.
- Previous command output (if the output of a command-line utility has changed)
- New command output (if the output of a command-line utility has changed)
-->