Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/common/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import copy
import tempfile
import uuid
import paramiko
from io import StringIO
from ast import literal_eval
from scapy.all import sniff as scapy_sniff
Expand Down Expand Up @@ -1109,3 +1110,20 @@ def capture_and_check_packet_on_dut(
pkts_validator(scapy_sniff(offline=temp_pcap.name))
finally:
duthost.file(path=pcap_save_path, state="absent")


def duthost_ssh(duthost, sonic_username, sonic_passwords, sonic_ip):
for password in sonic_passwords:
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(sonic_ip, username=sonic_username, password=password,
allow_agent=False, look_for_keys=False, timeout=10)
return ssh
except paramiko.AuthenticationException:
continue
except Exception as e:
logging.info("Cannot access DUT {} via ssh, error: {}".format(duthost.hostname, e))
raise e
logging.info("Cannot access DUT {} via ssh, error: Password incorrect".format(duthost.hostname))
raise paramiko.AuthenticationException
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@ def creds_on_dut(duthost):
creds["console_user"] = {}
creds["console_password"] = {}

creds["ansible_altpasswords"] = []

for k, v in list(console_login_creds.items()):
creds["console_user"][k] = v["user"]
creds["console_password"][k] = v["passwd"]
Expand Down