Add support to log collecter CLI options for ports
Changes:
- Added CLI option for SSH port
- Fix HTTPs port for redfishtool
Tested:
Tested on sanndbox script.
Change-Id: I96e864f923a5e38552af063981decc1d26b7863f
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/ffdc/collect_ffdc.py b/ffdc/collect_ffdc.py
index 698b87b..ae0bb70 100644
--- a/ffdc/collect_ffdc.py
+++ b/ffdc/collect_ffdc.py
@@ -27,6 +27,9 @@
@click.option("-u", "--username", help="Username of the remote host.")
@click.option("-p", "--password", help="Password of the remote host.")
@click.option(
+ "-port_ssh", default=22, show_default=True, help="SSH port value."
+)
+@click.option(
"-port_https", default=443, show_default=True, help="HTTPS port value."
)
@click.option(
@@ -83,6 +86,7 @@
remote,
username,
password,
+ port_ssh,
port_https,
port_ipmi,
config,
@@ -102,12 +106,20 @@
)
if input_options_ok(
- remote, username, password, port_https, port_ipmi, config, type
+ remote,
+ username,
+ password,
+ port_ssh,
+ port_https,
+ port_ipmi,
+ config,
+ type,
):
this_ffdc = ffdc_collector(
remote,
username,
password,
+ port_ssh,
port_https,
port_ipmi,
config,
@@ -140,7 +152,7 @@
def input_options_ok(
- remote, username, password, port_https, port_ipmi, config, type
+ remote, username, password, port_ssh, port_https, port_ipmi, config, type
):
r"""
Verify script options exist via CLI options or environment variables.
diff --git a/ffdc/ffdc_collector.py b/ffdc/ffdc_collector.py
index 87cb569..f016e85 100644
--- a/ffdc/ffdc_collector.py
+++ b/ffdc/ffdc_collector.py
@@ -119,6 +119,7 @@
hostname,
username,
password,
+ port_ssh,
port_https,
port_ipmi,
ffdc_config,
@@ -135,6 +136,7 @@
hostname name/ip of the targeted (remote) system
username user on the targeted system with access to FFDC files
password password for user on targeted system
+ port_ssh SSH port value. By default 22
port_https HTTPS port value. By default 443
port_ipmi IPMI port value. By default 623
ffdc_config configuration file listing commands and files for FFDC
@@ -149,6 +151,7 @@
self.hostname = hostname
self.username = username
self.password = password
+ self.port_ssh = str(port_ssh)
self.port_https = str(port_https)
self.port_ipmi = str(port_ipmi)
self.ffdc_config = ffdc_config
@@ -348,7 +351,7 @@
"""
self.ssh_remoteclient = SSHRemoteclient(
- self.hostname, self.username, self.password
+ self.hostname, self.username, self.password, self.port_ssh
)
if self.ssh_remoteclient.ssh_remoteclient_login():
@@ -914,6 +917,8 @@
redfish_parm = (
"redfishtool -r "
+ self.hostname
+ + ":"
+ + self.port_https
+ " -S Always raw GET /redfish/v1/"
)
return self.run_tool_cmd(redfish_parm, True)
@@ -1046,6 +1051,7 @@
os.environ["hostname"] = self.hostname
os.environ["username"] = self.username
os.environ["password"] = self.password
+ os.environ["port_ssh"] = self.port_ssh
os.environ["port_https"] = self.port_https
os.environ["port_ipmi"] = self.port_ipmi
@@ -1053,6 +1059,7 @@
self.env_dict["hostname"] = self.hostname
self.env_dict["username"] = self.username
self.env_dict["password"] = self.password
+ self.env_dict["port_ssh"] = self.port_ssh
self.env_dict["port_https"] = self.port_https
self.env_dict["port_ipmi"] = self.port_ipmi
diff --git a/ffdc/ffdc_config.yaml b/ffdc/ffdc_config.yaml
index f1a9125..e89dbc7 100644
--- a/ffdc/ffdc_config.yaml
+++ b/ffdc/ffdc_config.yaml
@@ -152,7 +152,7 @@
- plugin:
- plugin_name: plugin.redfish.enumerate_request
- plugin_args:
- - ${hostname}
+ - ${hostname}:${port_https}
- ${username}
- ${password}
- /redfish/v1/
diff --git a/ffdc/lib/ssh_utility.py b/ffdc/lib/ssh_utility.py
index fb44121..17e1dea 100644
--- a/ffdc/lib/ssh_utility.py
+++ b/ffdc/lib/ssh_utility.py
@@ -22,7 +22,7 @@
for remote host command execution and scp.
"""
- def __init__(self, hostname, username, password):
+ def __init__(self, hostname, username, password, port_ssh):
r"""
Description of argument(s):
@@ -38,6 +38,7 @@
self.hostname = hostname
self.username = username
self.password = password
+ self.port_ssh = port_ssh
def ssh_remoteclient_login(self):
r"""
@@ -55,6 +56,7 @@
# Connect to the server
self.sshclient.connect(
hostname=self.hostname,
+ port=self.port_ssh,
username=self.username,
password=self.password,
banner_timeout=120,