-
Notifications
You must be signed in to change notification settings - Fork 727
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
[voq] refine eos fanout function to check fanout link oper status #9128
Conversation
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
tests/common/devices/eos.py
Outdated
""" | ||
This function returns link oper as well as admin status | ||
e.g. cable not connected: | ||
Ethernet1/1 is down, line protocol is notpresent (notconnect) | ||
link is admin down(cable not present): | ||
Ethernet1/1 is administratively down, line protocol is notpresent (disabled) | ||
link is admin down(cable present): | ||
Ethernet2/1 is administratively down, line protocol is down (disabled) | ||
link is admin up&oper up: | ||
Ethernet2/1 is up, line protocol is up (connected) | ||
link is admin up&oper down: | ||
Ethernet2/1 is down, line protocol is down (notconnect) | ||
In conclusion, if 'up' found in output line, link is oper up&admin up. | ||
Link could not be admin down&oper up. | ||
This function could not tell if it's admin up&oper down | ||
""" | ||
show_int_result = self.eos_command( | ||
commands=['show interface %s' % interface_name]) | ||
return 'Up' in show_int_result['stdout_lines'][0] | ||
return 'up' in show_int_result['stdout_lines'][0].lower() | ||
|
||
def check_intf_link_oper_state(self, interface_name): | ||
""" | ||
This function returns oper state for eos fanout | ||
e.g. Et1/1 is admin up, oper down | ||
Et2/1 is admin down | ||
Et3/1 is oper up | ||
Et1/1 str2-7804-lc7-1-Ethernet0 notconnect 1102 full 100G 100GBASE-CR4 | ||
Et2/1 str2-7804-lc7-1-Ethernet4 disabled 1103 full 100G 100GBASE-CR4 | ||
Et3/1 str2-7804-lc7-1-Ethernet8 connected 1104 full 100G 100GBASE-CR4 | ||
""" | ||
show_int_result = self.eos_command(commands=['show interface status']) | ||
for output_line in show_int_result['stdout_lines'][0]: | ||
fields = output_line.split(' ') | ||
output_port = fields[0].replace('Et', 'Ethernet') | ||
if interface_name == output_port: | ||
# if link is not oper up, we consider it as oper down, it could be admin down as well | ||
if 'connected' not in fields: | ||
logging.info("Interface {} is oper down on {}".format(output_port, self.hostname)) | ||
return False | ||
return True | ||
|
||
def check_intf_link_admin_state(self, interface_name): | ||
""" | ||
This function returns admin state for eos fanout | ||
""" | ||
show_int_result = self.eos_command(commands=['show interface status']) | ||
for output_line in show_int_result['stdout_lines'][0]: | ||
fields = output_line.split(' ') | ||
output_port = fields[0].replace('Et', 'Ethernet') | ||
if interface_name == output_port: | ||
# if link is not admin down, we consider it as admin up, however, it could be oper down(notconnect) | ||
if 'disabled' in fields: | ||
logging.info("Interface {} is admin down on {}".format(output_port, self.hostname)) | ||
return False | ||
return True |
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 would caution against adding new code that tries to interpret or directly parse text output from eos commands. The approach in #9127 would be much preferred as the JSON output gives a well-defined model.
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 agree with you in the json way.
but I think it's necessary to avoid the confusion in the function name as well. if we check for 'connected' then it's checking link oper status only, this is another thing I would want to clarify in this PR
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.
Sounds good, I'll let others comment on the preferred naming here. Just wanted to give my 2c on using JSON output.
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
Thanks for incorporating the feedback and adding comments! I'll let someone with write access give you approval, but otherwise LGTM. |
thanks @slianganet
thanks @slianganet and @gechiang for the corporation! |
Cherry-pick PR to 202205: #9166 |
Description of PR
This is to fix hidden issue in #8468
It could cause failure for test_voq_nbr.py and test_lag_2.py.
eos.py: current function
check_intf_link_state
is trying to find 'Up' fromshow int <interface>
output, but it always returns false because output looks likeEthernet2/1 is up, line protocol is up (connected)
, probably differs between eos image versions. A more reliable way is to checkshow int <interface> | json
and findconnected
in output. Detail is described in code comment.Summary:
Fixes # (issue)
Type of change
Back port request
Approach
What is the motivation for this PR?
How did you do it?
How did you verify/test it?
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation