summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/base_vyostest_shim.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-06-12 21:13:55 +0200
committerChristian Breunig <christian@breunig.cc>2023-06-21 23:17:27 +0200
commit7fa7aa4d4b2d4736037ec912111b4f3048dfa217 (patch)
treeaa96c5d7883c14fa9453ea08cad75303a3a71470 /smoketest/scripts/cli/base_vyostest_shim.py
parent2128dc0ddf6b921f440067d7b862f30d9fad0cb2 (diff)
downloadvyos-1x-7fa7aa4d4b2d4736037ec912111b4f3048dfa217.tar.gz
vyos-1x-7fa7aa4d4b2d4736037ec912111b4f3048dfa217.zip
smoketest: move SSH login functionality to base class
Diffstat (limited to 'smoketest/scripts/cli/base_vyostest_shim.py')
-rw-r--r--smoketest/scripts/cli/base_vyostest_shim.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/base_vyostest_shim.py b/smoketest/scripts/cli/base_vyostest_shim.py
index 7cfb53045..d56a8eb33 100644
--- a/smoketest/scripts/cli/base_vyostest_shim.py
+++ b/smoketest/scripts/cli/base_vyostest_shim.py
@@ -14,6 +14,7 @@
import os
import unittest
+import paramiko
from time import sleep
from typing import Type
@@ -87,6 +88,19 @@ class VyOSUnitTestSHIM:
pprint.pprint(out)
return out
+ def ssh_send_cmd(command, username, password, hostname='localhost'):
+ """ SSH command execution helper """
+ # Try to login via SSH
+ ssh_client = paramiko.SSHClient()
+ ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+ ssh_client.connect(hostname=hostname, username=username, password=password)
+ print(host, username, password)
+ _, stdout, stderr = ssh_client.exec_command(command)
+ output = stdout.read().decode().strip()
+ error = stderr.read().decode().strip()
+ ssh_client.close()
+ return output, error
+
# standard construction; typing suggestion: https://stackoverflow.com/a/70292317
def ignore_warning(warning: Type[Warning]):
import warnings