-
Notifications
You must be signed in to change notification settings - Fork 664
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
Prevent shutdown/startup commands on invalid interface names "fixes (SONiC/issues/268)" #424
Conversation
…terface status A bug in intfutil script that gets the keys object from the app-db for a specific interface Signed-off-by: kiran.kella@broadcom.com
…stead 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. Signed-off-by: kiran.kella@broadcom.com
…erface-name> startup/shutdown'.
Hi kirankella, with your changes, I have another problem. When I use the command “sudo config interface PortChannel0001 shutdown”, the terminal prompts that the interface name is invalid, as shown below: Error: Interface name is invalid. Please enter a valid interface name!! 0001 PortChannel0001 LACP(A)(Up) Ethernet108(S) So, when checking the validity of the interface name, should it also include the PORTCHANNEL table, not just in the PORT table? |
@leoli-nps You are right. We should be checking the PORTCHANNEL table as well. Raised PR #474 to fix the same. |
…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.
…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.
- What I did
Invalid interface names are pushed into the CONFIG DB though they don't have a valid alias name, due to a missing check in shutdown/startup functions.
Later show commands that check for alias names on the interfaces fail.
- How I did it
In the main.py utilities script, check if the given interface name exists in the PORT_TABLE in config db. If not, fail the shutdown/startup functions there throwing an error to the user prompting for a valid interface name.
- How to verify it
Issue shutdown or startup commands on invalid interface names, followed by show interfaces status.
- Previous command output (if the output of a command-line utility has changed)
root@sonic-testing:/home/admin# config interface Ethernet99 shutdown
root@sonic-testing:/home/admin# show interface status
Traceback (most recent call last):
File "/usr/bin/show", line 9, in
load_entry_point('sonic-utilities==1.2', 'console_scripts', 'show')()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 561, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2631, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2291, in load
return self.resolve()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2297, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/lib/python2.7/dist-packages/show/main.py", line 193, in
iface_alias_converter = InterfaceAliasConverter()
File "/usr/lib/python2.7/dist-packages/show/main.py", line 58, in init
self.port_dict[port_name]['alias']):
KeyError: 'alias'
- New command output (if the output of a command-line utility has changed)
root@sonic:/home/admin# config interface Ethernet99 shutdown
Usage: config interface shutdown [OPTIONS]
Error: Enter valid interface name!!
root@sonic:/home/admin# show interface status
Interface Lanes Speed MTU Alias Oper Admin Type
Ethernet0 13 N/A 9100 tenGigE0 down up SFP
Ethernet1 14 N/A 9100 tenGigE1 down up N/A
Ethernet2 15 N/A 9100 tenGigE2 down up SFP
....
-->