-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Refactor code 2. Support interactive_shell Signed-off-by: bingwang <[email protected]>
- Loading branch information
1 parent
65c3293
commit fca2f03
Showing
4 changed files
with
68 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1 @@ | ||
from tests.common.connections.base_console_conn import CONSOLE_SSH, CONSOLE_SSH_MENU_PORTS, CONSOLE_TELNET | ||
from telnet_console_conn import TelnetConsoleConn | ||
from ssh_console_conn import SSHConsoleConn | ||
|
||
__all__ = ["TelnetConsoleConn", "SSHConsoleConn"] | ||
|
||
ConsoleTypeMapper = { | ||
CONSOLE_TELNET: TelnetConsoleConn, | ||
CONSOLE_SSH: SSHConsoleConn, | ||
CONSOLE_SSH_MENU_PORTS: SSHConsoleConn | ||
} | ||
|
||
def ConsoleHost(console_type, | ||
console_host, | ||
console_port, | ||
sonic_username, | ||
sonic_password, | ||
console_username=None, | ||
console_password=None, | ||
timeout_s=100): | ||
if not ConsoleTypeMapper.has_key(console_type): | ||
raise ValueError("console type {} is not supported yet".format(console_type)) | ||
params = { | ||
"console_host": console_host, | ||
"console_port": console_port, | ||
"console_type": console_type, | ||
"sonic_username": sonic_username, | ||
"sonic_password": sonic_password, | ||
"console_username": console_username, | ||
"console_password": console_password, | ||
"timeout": timeout_s | ||
} | ||
return ConsoleTypeMapper[console_type](**params) | ||
|
||
__all__ = ["TelnetConsoleConn", "SSHConsoleConn", "ConsoleHost"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from base_console_conn import CONSOLE_SSH, CONSOLE_SSH_MENU_PORTS, CONSOLE_TELNET | ||
from telnet_console_conn import TelnetConsoleConn | ||
from ssh_console_conn import SSHConsoleConn | ||
|
||
ConsoleTypeMapper = { | ||
CONSOLE_TELNET: TelnetConsoleConn, | ||
CONSOLE_SSH: SSHConsoleConn, | ||
CONSOLE_SSH_MENU_PORTS: SSHConsoleConn | ||
} | ||
|
||
def ConsoleHost(console_type, | ||
console_host, | ||
console_port, | ||
sonic_username, | ||
sonic_password, | ||
console_username=None, | ||
console_password=None, | ||
timeout_s=100): | ||
if not ConsoleTypeMapper.has_key(console_type): | ||
raise ValueError("console type {} is not supported yet".format(console_type)) | ||
params = { | ||
"console_host": console_host, | ||
"console_port": console_port, | ||
"console_type": console_type, | ||
"sonic_username": sonic_username, | ||
"sonic_password": sonic_password, | ||
"console_username": console_username, | ||
"console_password": console_password, | ||
"timeout": timeout_s | ||
} | ||
return ConsoleTypeMapper[console_type](**params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters