Add sosreport to OS FFDC collection
Resolves openbmc/openbmc-test-automation#1736
Signed-off-by: Steven Sombar <ssombar@us.ibm.com>
Change-Id: I9b66eb24113403bac8aefd34dc5c822818dc44f5
diff --git a/lib/openbmc_ffdc_list.py b/lib/openbmc_ffdc_list.py
index 06f7e5d..ba4647e 100755
--- a/lib/openbmc_ffdc_list.py
+++ b/lib/openbmc_ffdc_list.py
@@ -81,6 +81,8 @@
'OS_syslog': 'tail -n 200000 /var/log/syslog >/tmp/OS_syslog.txt 2>&1',
'OS_info': '{ uname -a; dpkg -s opal-prd; dpkg -s ipmitool ; } '
+ '>/tmp/OS_info.txt 2>&1',
+ 'OS_sosreport': '{ rm -rf /tmp/sosreport*FFDC* ; sosreport --batch --tmp-dir '
+ + '/tmp --ticket-number FFDC ; } >/tmp/OS_sosreport.txt 2>&1',
},
}
# Add file name and correcponding command needed for RHEL Linux
@@ -94,6 +96,8 @@
+ '>/tmp/OS_syslog.txt 2>&1',
'OS_info': '{ lsb_release -a; cat /etc/redhat-release; '
+ 'uname -a; rpm -qa ; } >/tmp/OS_info.txt 2>&1',
+ 'OS_sosreport': '{ rm -rf /tmp/sosreport*FFDC* ; sosreport --batch --tmp-dir '
+ + '/tmp --label FFDC ; } >/tmp/OS_sosreport.txt 2>&1',
},
}
# Add file name and correcponding command needed for RHEL Linux
diff --git a/lib/openbmc_ffdc_methods.robot b/lib/openbmc_ffdc_methods.robot
index 2af265f..fa2fc04 100755
--- a/lib/openbmc_ffdc_methods.robot
+++ b/lib/openbmc_ffdc_methods.robot
@@ -351,6 +351,30 @@
\ ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list}
... ${ffdc_file_sub_list}
+ # Get the name of the sosreport file.
+ ${sosreport_file_path} ${stderr} ${rc}= OS Execute Command
+ ... ls /tmp/sosreport*FFDC*tar.xz ignore_err=${True}
+ # Example: sosreport_file_path="/tmp/sosreport-myhost-FFDC-2019-08-20-pbuaqtk.tar.xz".
+
+ # Return if there is no sosreport file.
+ Return From Keyword If ${rc} != ${0} ${ffdc_file_list}
+
+ ${sosreport_dir_path} ${sosreport_file_name}= Split Path ${sosreport_file_path}
+ # Example: sosreport_dir_path="/tmp",
+ # sosreport_file_name="sosreport-myhost-FFDC-2019-08-20-pbuaqtk.tar.xz".
+
+ # Location where the sosreport file will be copied to.
+ ${local_sosreport_file_path}= Set Variable ${LOG_PREFIX}OS_${sosreport_file_name}
+
+ # Change file permissions otherwise scp will not see the file.
+ OS Execute Command chmod 644 ${sosreport_file_path}
+
+ # SCP the sosreport file from the OS.
+ Run Key U scp.Get File \ ${sosreport_file_path} \ ${local_sosreport_file_path}
+
+ # Add the file location to the ffdc_file_list.
+ Append To List ${ffdc_file_list} ${local_sosreport_file_path}
+
[Return] ${ffdc_file_list}
@@ -403,7 +427,7 @@
... ${ffdc_file_sub_list}
# Delete ffdc files still on OS and close scp.
- OS Execute Command rm -rf /tmp/OS_*
+ OS Execute Command rm -rf /tmp/OS_* /tmp/sosreport*FFDC* ignore_err=${True}
scp.Close Connection
[Return] ${ffdc_file_list}