From 06cd99f0b9d324e3b94e1391778d4722bf79d9d5 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Kella <45939429+kirankella@users.noreply.github.com> Date: Sat, 30 Mar 2019 07:00:19 +0530 Subject: [PATCH] Allow config shutdown and startup operations on valid PortChannel interface names (#474) * Avoid shutdown/startup commands on invalid interface names * sonic-utilities: Fix bug in the show command to display a specific interface status * sonic-utilities: Check for the presence of interface in port table instead of the optional alias attribute * Addressed review comment for #424 * Undone the change in intfutil file to push that fix in a seperate PR. * Corrected the error message string for 'config interface tartup/shutdown'. * [sonic-utilities] Fix to shutdown and startup on valid PortChannel interface names * [sonic-utilities] Allow shutdown/startup commands to be done using the alias names of PORTs. --- config/main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/config/main.py b/config/main.py index 5af9ddb80ea0..8486e910fe44 100755 --- a/config/main.py +++ b/config/main.py @@ -80,9 +80,9 @@ def interface_alias_to_name(interface_alias): for port_name in port_dict.keys(): if interface_alias == port_dict[port_name]['alias']: return port_name - click.echo("Invalid interface {}".format(interface_alias)) - return None + # Interface alias not in port_dict, just return interface_alias + return interface_alias def interface_name_is_valid(interface_name): @@ -91,6 +91,10 @@ def interface_name_is_valid(interface_name): config_db = ConfigDBConnector() config_db.connect() port_dict = config_db.get_table('PORT') + port_channel_dict = config_db.get_table('PORTCHANNEL') + + if get_interface_naming_mode() == "alias": + interface_name = interface_alias_to_name(interface_name) if interface_name is not None: if not port_dict: @@ -99,6 +103,10 @@ def interface_name_is_valid(interface_name): for port_name in port_dict.keys(): if interface_name == port_name: return True + if port_channel_dict: + for port_channel_name in port_channel_dict.keys(): + if interface_name == port_channel_name: + return True return False def interface_name_to_alias(interface_name):