-
Notifications
You must be signed in to change notification settings - Fork 1k
Support recovering Nexus devices via console #11264
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
Changes from 3 commits
a93402c
1e4abfa
41c1e8c
5a84c8f
23136c0
97ac5ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,9 +46,9 @@ def get_pdu_managers(sonichosts, conn_graph_facts): | |
| return pdu_managers | ||
|
|
||
|
|
||
| def posix_shell_onie(dut_console, mgmt_ip, image_url): | ||
| def posix_shell_onie(dut_console, mgmt_ip, image_url, is_nexus=False): | ||
| oldtty = termios.tcgetattr(sys.stdin) | ||
| enter_onie_flag = 0 | ||
| enter_onie_flag = True | ||
| gw_ip = list(ipaddress.ip_interface(mgmt_ip).network.hosts())[0] | ||
| try: | ||
| tty.setraw(sys.stdin.fileno()) | ||
|
|
@@ -66,20 +66,25 @@ def posix_shell_onie(dut_console, mgmt_ip, image_url): | |
|
|
||
| x = x.decode('ISO-8859-9') | ||
|
|
||
| if "GNU GRUB" in x: | ||
| enter_onie_flag += 1 | ||
| if is_nexus and "loader" in x and ">" in x: | ||
| dut_console.remote_conn.send('reboot\n') | ||
| continue | ||
|
|
||
| if "SONiC-OS-" in x and enter_onie_flag == 1: | ||
| # if "GNU GRUB" in x: | ||
| # enter_onie_flag += 1 | ||
| # continue | ||
|
|
||
| if "-OS-" in x and enter_onie_flag is True: | ||
| # Send arrow key "down" here. | ||
| dut_console.remote_conn.send(b'\x1b[B') | ||
| continue | ||
|
|
||
| if "*ONIE" in x and "Install OS" not in x: | ||
| dut_console.remote_conn.send("\n") | ||
| enter_onie_flag += 1 | ||
| enter_onie_flag = False | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you create constant for the strings like "-OS-", "*ONIE", "Install OS" and others, so that it would be clear to speculate the usage from the constant name
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
|
||
| if "ONIE: Starting ONIE Service Discovery" in x: | ||
| # "ONIE: Starting ONIE Service Discovery" | ||
| if "Discovery" in x: | ||
| # TODO: Define a function to send command here | ||
| for i in range(5): | ||
| dut_console.remote_conn.send('onie-discovery-stop\n') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| RC_SSH_SUCCESS = 0 | ||
| RC_SSH_FAILED = 1 | ||
| RC_PASSWORD_FAILED = 2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import os | ||
| import sys | ||
| from common import do_power_cycle, check_sonic_installer, posix_shell_aboot, posix_shell_onie | ||
| from constants import RC_SSH_FAILED | ||
|
|
||
| _self_dir = os.path.dirname(os.path.abspath(__file__)) | ||
| base_path = os.path.realpath(os.path.join(_self_dir, "../..")) | ||
|
|
@@ -40,9 +41,9 @@ def recover_via_console(sonichost, conn_graph_facts, localhost, mgmt_ip, image_u | |
|
|
||
| if type in ["arista"]: | ||
| posix_shell_aboot(dut_console, mgmt_ip, image_url) | ||
| # elif type in ["Cisco"]: | ||
| # return | ||
| elif type in ["mellanox", "nexus", "acs"]: | ||
| elif type in ["nexus"]: | ||
|
||
| posix_shell_onie(dut_console, mgmt_ip, image_url, is_nexus=True) | ||
| elif type in ["mellanox", "cisco", "acs"]: | ||
|
||
| posix_shell_onie(dut_console, mgmt_ip, image_url) | ||
| else: | ||
| return | ||
|
|
@@ -74,7 +75,7 @@ def recover_testbed(sonichosts, conn_graph_facts, localhost, image_url, hwsku): | |
| logger.info("Exception caught while executing cmd. Error message: {}".format(e)) | ||
| need_to_recover = True | ||
| # TODO: Define the return message like RC_SOCKET_TIMEOUT in common file | ||
| elif dut_ssh == 1: | ||
| elif dut_ssh == RC_SSH_FAILED: | ||
| # Do power cycle | ||
| need_to_recover = True | ||
| else: | ||
|
|
||
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.
if "-OS-" in x and enter_onie_flag:
Uh oh!
There was an error while loading. Please reload this page.
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 do some tests, and because of the rule of Python, we can use
bool(enter_onie_flag)or useenter_onie_flag is Truehere. Simplyenter_onie_flagwill not be considered as a boolean.