Skip to content

Commit 06cd99f

Browse files
kirankellaqiluo-msft
authored andcommitted
Allow config shutdown and startup operations on valid PortChannel interface names (sonic-net#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 sonic-net#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.
1 parent 98cdebb commit 06cd99f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

config/main.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def interface_alias_to_name(interface_alias):
8080
for port_name in port_dict.keys():
8181
if interface_alias == port_dict[port_name]['alias']:
8282
return port_name
83-
click.echo("Invalid interface {}".format(interface_alias))
8483

85-
return None
84+
# Interface alias not in port_dict, just return interface_alias
85+
return interface_alias
8686

8787

8888
def interface_name_is_valid(interface_name):
@@ -91,6 +91,10 @@ def interface_name_is_valid(interface_name):
9191
config_db = ConfigDBConnector()
9292
config_db.connect()
9393
port_dict = config_db.get_table('PORT')
94+
port_channel_dict = config_db.get_table('PORTCHANNEL')
95+
96+
if get_interface_naming_mode() == "alias":
97+
interface_name = interface_alias_to_name(interface_name)
9498

9599
if interface_name is not None:
96100
if not port_dict:
@@ -99,6 +103,10 @@ def interface_name_is_valid(interface_name):
99103
for port_name in port_dict.keys():
100104
if interface_name == port_name:
101105
return True
106+
if port_channel_dict:
107+
for port_channel_name in port_channel_dict.keys():
108+
if interface_name == port_channel_name:
109+
return True
102110
return False
103111

104112
def interface_name_to_alias(interface_name):

0 commit comments

Comments
 (0)