FFDC stand-alone script pretty prints updates
Changes:
- Few print updates.
- Added working protocol list logic.
Change-Id: Iabcf48d1644ef18011ff3d049686b273de9a4c32
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/ffdc/collect_ffdc.py b/ffdc/collect_ffdc.py
index 10f0b1c..21c67ef 100644
--- a/ffdc/collect_ffdc.py
+++ b/ffdc/collect_ffdc.py
@@ -37,7 +37,7 @@
Stand alone CLI to generate and collect FFDC from the selected target.
"""
- click.echo("\n********** FFDC Starts **********")
+ click.echo("\n********** FFDC (First Failure Data Collection) Starts **********")
if input_options_ok(remote, username, password, ffdc_config):
thisFFDC = FFDCCollector(remote, username, password, ffdc_config, location)
diff --git a/ffdc/ffdc_collector.py b/ffdc/ffdc_collector.py
index 69c14e8..3e4f788 100644
--- a/ffdc/ffdc_collector.py
+++ b/ffdc/ffdc_collector.py
@@ -22,7 +22,6 @@
"""
def __init__(self, hostname, username, password, ffdc_config, location):
-
r"""
Description of argument(s):
@@ -71,14 +70,13 @@
return run_env_ok
def target_is_pingable(self):
-
r"""
Check if target system is ping-able.
"""
response = os.system("ping -c 1 -w 2 %s 2>&1 >/dev/null" % self.hostname)
if response == 0:
- print("\n\t%s is ping-able." % self.hostname)
+ print("\n\t[Check] %s is ping-able.\t\t\t [OK]" % self.hostname)
return True
else:
print("\n>>>>>\tERROR: %s is not ping-able. FFDC collection aborted.\n" % self.hostname)
@@ -93,18 +91,22 @@
self.target_type = "OPENBMC"
def collect_ffdc(self):
-
r"""
Initiate FFDC Collection depending on requested protocol.
"""
- print("\n\n\t---- Start communicating with %s ----\n" % self.hostname)
+ print("\n\t---- Start communicating with %s ----" % self.hostname)
+ working_protocol_list = []
if self.target_is_pingable():
+ # Check supported protocol ping,ssh, redfish are working.
+ if self.ssh_to_target_system():
+ working_protocol_list.append("SSH")
# Verify top level directory exists for storage
self.validate_local_store(self.location)
self.set_target_machine_type()
- self.generate_ffdc()
+ print("\n\t---- Completed protocol pre-requisite check ----\n")
+ self.generate_ffdc(working_protocol_list)
def ssh_to_target_system(self):
r"""
@@ -117,34 +119,36 @@
self.password)
self.remoteclient.ssh_remoteclient_login()
+ print("\n\t[Check] %s SSH connection established.\t [OK]" % self.hostname)
+ return True
- def generate_ffdc(self):
-
+ def generate_ffdc(self, working_protocol_list):
r"""
Send commands in ffdc_config file to targeted system.
"""
+ print("\n\t---- Executing commands on " + self.hostname + " ----")
+ print("\n\tWorking protocol list: %s" % working_protocol_list)
with open(self.ffdc_config, 'r') as file:
ffdc_actions = yaml.load(file, Loader=yaml.FullLoader)
for machine_type in ffdc_actions.keys():
if machine_type == self.target_type:
- if (ffdc_actions[machine_type]['PROTOCOL'][0] == 'SSH'):
+ if (ffdc_actions[machine_type]['PROTOCOL'][0] in working_protocol_list):
- # Use SSH
- self.ssh_to_target_system()
-
- print("\n\tCollecting FFDC on " + self.hostname)
+ print("\n\t[Run] Executing commands on %s using %s"
+ % (self.hostname, ffdc_actions[machine_type]['PROTOCOL'][0]))
list_of_commands = ffdc_actions[machine_type]['COMMANDS']
progress_counter = 0
for command in list_of_commands:
self.remoteclient.execute_command(command)
progress_counter += 1
self.print_progress(progress_counter)
+ print("\n\t[Run] Commands execution completed \t\t [OK]")
- print("\n\n\tCopying FFDC from remote system %s \n\n" % self.hostname)
+ print("\n\n\tCopying FFDC files from remote system %s \n\n" % self.hostname)
# Get default values for scp action.
# self.location == local system for now
self.set_ffdc_defaults()
@@ -160,7 +164,6 @@
targ_file_prefix="",
file_list=None,
quiet=None):
-
r"""
SCP all files in file_dict to the indicated directory on the local system.
@@ -198,7 +201,6 @@
self.remoteclient.ssh_remoteclient_disconnect()
def set_ffdc_defaults(self):
-
r"""
Set a default value for self.ffdc_dir_path and self.ffdc_prefix.
Collected ffdc file will be stored in dir /self.location/hostname_timestr/.