-
Notifications
You must be signed in to change notification settings - Fork 701
Multi asic platform changes for interface, portchannel commands #878
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
Conversation
This pull request introduces 7 alerts when merging 2187176daf02ef3456b8194bafe0bf64ea11185c into 8bfa3b7 - view on LGTM.com new alerts:
|
Also fix LGTM alerts |
Fixed already, thanks |
Strange ... The LGTM check didn't re-run, and now it's missing from the list of checks. |
Looks good to me. Wait for other reviewers. |
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.
Looks good to me. Wait for other reviewers.
config/main.py
Outdated
else: | ||
namespace = ns | ||
config_db = ConfigDBConnector(use_unix_socket_path=True, namespace=namespace) | ||
config_db.connect() |
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.
remove code duplication.
1822, 1862, ...
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.
Will remove code duplication, will make it functions and invoke those, thanks.
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.
Defined new function get_interface_configDB_connector() and used it to remove the code duplicated.
config/main.py
Outdated
if intf_ns is None: | ||
ctx.fail("member interface {} is invalid".format(port_name)) | ||
elif intf_ns != ctx.obj['namespace']: | ||
ctx.fail("member interface {} doesn't exist in namespace {}".format(port_name, ctx.obj['namespace'])) |
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.
code duplication as above
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.
same as above
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.
Updated the code.
config/main.py
Outdated
@@ -931,11 +964,21 @@ def hostname(new_hostname): | |||
# 'portchannel' group ('config portchannel ...') | |||
# | |||
@config.group(cls=AbbreviationGroup) | |||
@click.option('-n', '--namespace', help='Namespace name', 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.
None->DEFAULT_NAMESPACE
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.
Updated.
config/main.py
Outdated
@@ -167,11 +167,42 @@ def validate_namespace(namespace): | |||
else: | |||
return False | |||
|
|||
def interface_alias_to_name(interface_alias): | |||
# Return the namespace where an interface belongs | |||
def get_intf_namespace(port): |
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.
get_port_namespace
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.
Updated
config/main.py
Outdated
if port.startswith("PortChannel") or port.startswith("Vlan") or port.startswith("Loopback"): | ||
return None | ||
|
||
if port.startswith("Ethernet"): |
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.
get the port table, if it is in the port table then return the namespace, otherwise return non.
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.
Added a new API get_port_table_name() to get the table to be checked for the existence of the interface
config/main.py
Outdated
return DEFAULT_NAMESPACE | ||
|
||
# If it is PortChannel or Vlan interface or Loopback, user needs to input the namespace. | ||
if port.startswith("PortChannel") or port.startswith("Vlan") or port.startswith("Loopback"): |
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.
no need to hardcode all these logics.
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 idea of checking for interfaces like PortChannel, SVI interfaces here and return back "None" explicitly so that the user will have to mandatorily pass the parameter -n namespace for such interfaces.
For physical interfaces ( those starting with "Ethernet") idea was to make the -namespace parameter optional.
- If the user don't provide it, the config handler will use the namespace obtained from this get_port_namespace() API.
- If the user provides the namespace parameter, the config handler will make sure it is same as what we find from this get_port_namespace() API.
For the physical interfaces behavior could be similar to single NPU devices now .. where user need not pass the namespace as a mandatory parameter while configuring.
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.
Added a new API get_port_table_name() to get the table to be checked for the existence of the interface. Removed the earlier checks.
config/main.py
Outdated
@@ -973,6 +1016,14 @@ def portchannel_member(ctx): | |||
def add_portchannel_member(ctx, portchannel_name, port_name): | |||
"""Add member to port channel""" | |||
db = ctx.obj['db'] | |||
if sonic_device_util.is_multi_npu(): |
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.
this is logic is not straightforward.
why not just connect to the db in ns, and check if port_name is in the port_table, it will work for both single asic and multi-asic.
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 logic here is to make sure that the member interface which is getting added into the port channel is in fact present in the same namespace the user inputted with the -n namespace argument.
I have introduced this check only for the multi-asic platforms where -n namespace parameter is mandatory with these port-channel commands.
Okay but I understand the point from your comment to avoid the multi-npu check, will take care of it - thanks.
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.
I updated to use the existing function interface_name_is_valid(), as in this case we already have the details of which config db to connect to.
config/main.py
Outdated
"""VLAN-related configuration tasks""" | ||
kwargs = {} | ||
if redis_unix_socket_path: | ||
kwargs['unix_socket_path'] = redis_unix_socket_path | ||
config_db = ConfigDBConnector(**kwargs) | ||
|
||
# If multi ASIC platform, check if the namespace entered by user is valid |
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.
duplicate code. make it as a single check function.
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.
Updated.
config/main.py
Outdated
if intf_ns is None: | ||
ctx.fail("member interface {} is invalid".format(interface_name)) | ||
elif intf_ns != ctx.obj['namespace']: | ||
ctx.fail("member interface {} doesn't exist in namespace {}".format(interface_name, ctx.obj['namespace'])) |
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.
this check logic is special, just connect to ctx.obj['namespace'] and check if port is there or not, make it work for single asic too.
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.
I updated to use the existing function interface_name_is_valid(), as in this case we already have the details of which config db to connect to.
config/main.py
Outdated
@@ -1361,12 +1439,20 @@ def add_vlan_member(ctx, vid, interface_name, untagged): | |||
def del_vlan_member(ctx, vid, interface_name): | |||
"""Delete VLAN member""" | |||
log_info("'vlan member del {} {}' executing...".format(vid, interface_name)) | |||
if sonic_device_util.is_multi_npu(): |
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.
same as above.
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.
Updated.
Updates based on multi_asic and other API's in to sonic_py_common package. The build is failing now as "multi_asic" and "interface" utilities are still not updated in sonic_py_common package. |
This pull request introduces 1 alert when merging 2d2e7c9 into a15b6bf - view on LGTM.com new alerts:
|
retest this please |
retest this please |
Verified on both single-asic and multi-asic platforms.
This comment has been minimized.
This comment has been minimized.
@jleveque have updated the TODO's for the functions which we can move to py-common. Also updated the PR description with tests with the CLI commands in multi-asic device and syntax for reference. Please take a look. |
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.
LGTM. Please wait for other reviews.
…mmands ( sonic-net#878) into 201911 branch
…ceiver (#1087) * Merging the Multi asic platform changes for interface, portchannel commands ( #878) into 201911 branch * Merging the Multi asic platform changes show transceiver command (PR #1081) into 201911 branch * Updated needed in 201911 * Correcting the changes done to sfputil/main.py * Remove unused import
* 0323d5e noaOrMlnx Fix flex counters logic of converting poll interval to seconds from MS (sonic-net#878) Signed-off-by: Volodymyr Samotiy <[email protected]>
- What I did
Changes to the following config commands and scripts for Multi-ASIC devices.
- How I did it
The changes done here are based on the namespace support added in SonicDBConfig/ConfigDBConnector/SonicV2Connector classes in the PR sonic-net/sonic-py-swsssdk#63
The following are the changes introduced in this PR
(a) added a new parameter of "config_db" to the interface helper API's. This approach is better, as now we have to do this once config_db = ConfigDBConnector() in the CLI handler and the config_db instance is passed down as argument to the API.
(b) config interface, config port channel -- added the namespace option. This option is made mandatory for multi-asic platforms.
- How to verify it
Verified on a multi-ASIC devices, by running the Config commands.
Verified on single ASIC devices so that the commands works ok.
- 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)
In Multi-ASIC
In Single ASIC
Note : Even though it is present as option, the user can ignore it. Planning to hide it in the command line once we have Click 7.0 in all branches which support "hidden" keyword.