Skip to content
Open
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
10 changes: 5 additions & 5 deletions config/inputs/io_veth_input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ netmask = 255.255.255.0
host_interfaces = "env4 env5"
host_public_ip = ""
peer_ips = "45.1.1.139 46.1.1.139"
peer_user = ""
peer_user = "root"
peer_password = ""
bond_interfaces = "env4 env5"
host_ips = "45.1.1.27 46.1.1.27"
Expand All @@ -21,7 +21,7 @@ sleep_time = 35
count = 10
EXPECTED_THROUGHPUT = 50
UPERF_SERVER_RUN = 1
TIMEOUT = "300"
TIMEOUT = 300
NETSERVER_RUN = 1
duration = 600
minimum_iterations = 1
Expand All @@ -34,10 +34,10 @@ drop_accepted = 10
nmap_download = "https://nmap.org/dist/nmap-7.80.tar.bz2"
bridge_interface = "br0"
hmc_pwd = ""
hmc_username = ""
hmc_username = "hscroot"
num_of_dlpar = 20
vios_ip = ""
vios_username = ""
vios_username = "padmin"
vios_pwd = ""
module = "ibmveth"
iteration = 20
Expand All @@ -47,7 +47,7 @@ function = 4
err = 1
htx_host_interfaces = "env4"
net_ids = '45'
htx_rpm_link = ""
htx_rpm_link = "https://rchgsa.ibm.com:7191/gsa/rchgsa/projects/h/htx/public_html/htxonly/"
hbond = False
ip_config = "True"
mtu_timeout = 30
Expand Down
3 changes: 2 additions & 1 deletion config/inputs/io_vnic_input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ count = 5
peer_user_name = root
EXPECTED_THROUGHPUT = 80
UPERF_SERVER_RUN = 1
TIMEOUT = "300"
TIMEOUT = 300
NETSERVER_RUN = 1
duration = 600
minimum_iterations = 1
Expand All @@ -57,3 +57,4 @@ run_type = 'rpm'
mtu_timeout = 30
manageSystem = ""
sriov = 'no'
htx_rpm_link = "https://rchgsa.ibm.com:7191/gsa/rchgsa/projects/h/htx/public_html/htxonly/"
39 changes: 39 additions & 0 deletions config/wrapper/pci_input.conf
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ host_public_ip = public_interface_ip
interface = interfaces:0
module = driver
macaddress = macaddress
peer_ip = peer_ip
peer_ips = peer_ips
peer_interfaces = peer_interfaces
peer_public_ip = peer_public_ip
peer_password = peer_password
host_ip = host_ip
host_ips = host_ips
netmask = netmask
netmasks = netmasks
manageSystem = manageSystem
vios_names = vios_names
vios_ip = vios_ip
device_ip = host_ip

[io_veth_fvt]
host_interfaces = interfaces:all
Expand All @@ -130,6 +143,19 @@ host_public_ip = public_interface_ip
interface = interfaces:0
module = driver
macaddress = macaddress
peer_ip = peer_ip
peer_ips = peer_ips
peer_interfaces = peer_interfaces
peer_public_ip = peer_public_ip
peer_password = peer_password
host_ip = host_ip
host_ips = host_ips
netmask = netmask
netmasks = netmasks
manageSystem = manageSystem
vios_names = vios_names
vios_ip = vios_ip
device_ip = host_ip

[io_hnv_fvt]
host_interfaces = interfaces:all
Expand All @@ -140,6 +166,19 @@ host_public_ip = public_interface_ip
interface = interfaces:0
module = driver
macaddress = macaddress
peer_ip = peer_ip
peer_ips = peer_ips
peer_interfaces = peer_interfaces
peer_public_ip = peer_public_ip
peer_password = peer_password
host_ip = host_ip
host_ips = host_ips
netmask = netmask
netmasks = netmasks
manageSystem = manageSystem
vios_names = vios_names
vios_ip = vios_ip
device_ip = host_ip

[io_ib_fvt]
interface = interfaces:0
Expand Down
115 changes: 115 additions & 0 deletions lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import re
import sys
import shlex
import shutil
import stat
import platform
Expand Down Expand Up @@ -264,3 +265,117 @@ def uninstall(self):
runcmd(cmd, ignore_status=True,
err_str="Error in removing package: %s" % package,
debug_str="Uninstalling %s" % package)



class RemoteRunner:
"""
SSH-based remote command runner using ``sshpass`` + the system ``ssh``
binary. No Python C-extension dependencies (no paramiko/bcrypt/pynacl)
are required — only the ``sshpass`` package must be installed on the
*local* machine (``yum install sshpass`` / ``apt-get install sshpass``).

Provides the same ``runcmd()`` interface as the local helper so it can be
used as a drop-in replacement for remote machines.

Usage::

runner = RemoteRunner(host='192.168.1.10', username='root', password='secret')
status, output = runner.runcmd('ip a s dev eth0')
runner.close() # no-op for this implementation, kept for API compat

Context-manager usage::

with RemoteRunner(host='192.168.1.10', username='root', password='secret') as r:
status, output = r.runcmd('lsdevinfo -c')
"""

# Common SSH options that suppress host-key prompts and banners.
_SSH_OPTS = (
"-o StrictHostKeyChecking=no "
"-o UserKnownHostsFile=/dev/null "
"-o BatchMode=no "
"-o LogLevel=ERROR"
)

def __init__(self, host, username, password, port=22, timeout=30):
"""
Store connection parameters and verify that ``sshpass`` is available.

:param host: Hostname or IP address of the remote machine.
:param username: SSH login username.
:param password: SSH login password.
:param port: SSH port (default 22).
:param timeout: Per-command connect timeout in seconds (default 30).
"""
# Verify sshpass is on PATH
chk_status, _ = subprocess.getstatusoutput("which sshpass")
if chk_status != 0:
logger.error(
"sshpass is not installed. Install it with: "
"yum install sshpass OR apt-get install sshpass"
)
sys.exit(1)

self.host = host
self.username = username
self._password = password
self.port = port
self.timeout = timeout
logger.info("RemoteRunner ready for %s@%s:%s (sshpass mode)", username, host, port)

def runcmd(self, cmd, ignore_status=False, err_str="", info_str="", debug_str=""):
"""
Run *cmd* on the remote host via ``sshpass``/``ssh``.

:param cmd: Shell command string to execute remotely.
:param ignore_status: If False (default), calls sys.exit(1) on non-zero exit.
:param err_str: Message to log at ERROR level on failure.
:param info_str: Message to log at INFO level before running.
:param debug_str: Message to log at DEBUG level before running.
:return: (status, output) tuple — identical contract to local runcmd().
"""
if info_str:
logger.info(info_str)
if debug_str:
logger.debug(debug_str)

# Build: sshpass -p <pwd> ssh <opts> -p <port> -o ConnectTimeout=<t> user@host '<cmd>'
remote_cmd = (
"sshpass -p {pwd} ssh {opts} -p {port} "
"-o ConnectTimeout={timeout} "
"{user}@{host} {quoted_cmd}"
).format(
pwd=shlex.quote(self._password),
opts=self._SSH_OPTS,
port=self.port,
timeout=self.timeout,
user=self.username,
host=self.host,
quoted_cmd=shlex.quote(cmd),
)

logger.debug("Remote(%s) running: %s", self.host, cmd)
try:
status, output = subprocess.getstatusoutput(remote_cmd)
if status != 0 and not ignore_status:
if err_str:
logger.error("%s %s", err_str, output)
sys.exit(1)
logger.debug(output)
return (status, output)
except Exception as error:
if err_str:
logger.error("%s %s", err_str, error)
sys.exit(1)

def close(self):
"""No persistent connection to close; kept for API compatibility."""
logger.debug("RemoteRunner.close() called for %s (no-op)", self.host)

def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self.close()
return False
Loading