Skip to content

Commit

Permalink
Allow config shutdown and startup operations on valid PortChannel int…
Browse files Browse the repository at this point in the history
…erface 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 <invalid-interface-name> 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.
  • Loading branch information
kirankella authored and qiluo-msft committed Mar 30, 2019
1 parent 98cdebb commit 06cd99f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit 06cd99f

Please sign in to comment.