Use scp to upload FFDC files from OS_HOST

Redirect the OS ffdc commands in openbmc_ffdc_list.py to /tmp.

In openbmc_ffdc_methods.robot scp the output of ffdc commands.

Resolves openbmc/openbmc-test-automation#1684

Signed-off-by: Steven Sombar <ssombar@us.ibm.com>
Change-Id: Ib623da5c1e570d2237c2b282b8bbd7fff64c2c9f
diff --git a/lib/openbmc_ffdc_list.py b/lib/openbmc_ffdc_list.py
index 42d0a9a..55ab332 100755
--- a/lib/openbmc_ffdc_list.py
+++ b/lib/openbmc_ffdc_list.py
@@ -53,17 +53,18 @@
     'OS FILES':
     {
         # File Name         Command
-        'OS_msglog': 'cat /sys/firmware/opal/msglog',
-        'OS_cpufrequency': 'ppc64_cpu --frequency',
-        'OS_dmesg': 'dmesg',
-        'OS_opal_prd': 'cat /var/log/opal-prd*',
-        'OS_boot': 'cat /var/log/boot.log',
-        'OS_procinfo': 'cat /proc/cpuinfo',
-        'OS_meminfo': 'cat /proc/meminfo',
-        'OS_netstat': 'netstat -a',
-        'OS_lspci': 'lspci',
-        'OS_lscpu': 'lscpu',
-        'OS_lscfg': 'lscfg',
+        'OS_msglog': 'cat /sys/firmware/opal/msglog >/tmp/OS_msglog.txt 2>&1',
+        'OS_cpufrequency': 'ppc64_cpu --frequency '
+                           + '>/tmp/OS_cpufrequency.txt 2>&1',
+        'OS_dmesg': 'dmesg >/tmp/OS_dmesg.txt 2>&1',
+        'OS_opal_prd': 'cat /var/log/opal-prd* >/tmp/OS_opal_prd.txt 2>&1',
+        'OS_boot': 'cat /var/log/boot.log >/tmp/OS_boot.txt 2>&1',
+        'OS_procinfo': 'cat /proc/cpuinfo >/tmp/OS_procinfo.txt 2>&1',
+        'OS_meminfo': 'cat /proc/meminfo >/tmp/OS_meminfo.txt 2>&1',
+        'OS_netstat': 'netstat -a >/tmp/OS_netstat.txt 2>&1',
+        'OS_lspci': 'lspci >/tmp/OS_lspci.txt 2>&1',
+        'OS_lscpu': 'lscpu >/tmp/OS_lscpu.txt 2>&1',
+        'OS_lscfg': 'lscfg >/tmp/OS_lscfg.txt 2>&1',
     },
 }
 # Add file name and correcponding command needed for Ubuntu Linux
@@ -71,11 +72,13 @@
     'OS FILES':
     {
         # File Name         Command
-        'OS_isusb': 'lsusb -t ; lsusb -v',
-        'OS_kern': 'tail -n 50000 /var/log/kern.log',
-        'OS_authlog': 'cat /var/log/auth.log; cat /var/log/auth.log.1',
-        'OS_syslog': 'tail -n 200000 /var/log/syslog',
-        'OS_info': 'uname -a; dpkg -s opal-prd; dpkg -s ipmitool',
+        'OS_isusb': '{ lsusb -t ; lsusb -v ; } >/tmp/OS_isub.txt 2>&1',
+        'OS_kern': 'tail -n 50000 /var/log/kern.log >/tmp/OS_kern.txt 2>&1',
+        'OS_authlog': '{ cat /var/log/auth.log; cat /var/log/auth.log.1 ; } '
+                      + '>/tmp/OS_authlog.txt 2>&1',
+        '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',
     },
 }
 # Add file name and correcponding command needed for RHEL Linux
@@ -83,10 +86,12 @@
     'OS FILES':
     {
         # File Name         Command
-        'OS_rsct': '/usr/bin/ctversion -bv',
-        'OS_secure': 'cat /var/log/secure',
-        'OS_syslog': 'tail -n 200000 /var/log/messages',
-        'OS_info': 'lsb_release -a; cat /etc/redhat-release; uname -a; rpm -qa',
+        'OS_rsct': '/usr/bin/ctversion -bv >/tmp/OS_rsct.txt 2>&1',
+        'OS_secure': 'cat /var/log/secure >/tmp/OS_secure.txt 2>&1',
+        'OS_syslog': 'tail -n 200000 /var/log/messages '
+                     + '>/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',
     },
 }
 # Add file name and correcponding command needed for RHEL Linux
@@ -94,9 +99,11 @@
     'OS FILES':
     {
         # File Name         Command
-        'OS_secure': 'cat /var/log/secure',
-        'OS_syslog': 'tail -n 200000 /var/log/messages',
-        'OS_info': 'lsb_release -a; uname -a; rpm -qa',
+        'OS_secure': 'cat /var/log/secure >/tmp/OS_secure.txt 2>&1',
+        'OS_syslog': 'tail -n 200000 /var/log/messages '
+                     + '>/tmp/OS_syslog.txt 2>&1',
+        'OS_info': '{ lsb_release -a; uname -a; rpm -qa ; } '
+                   + '>/tmp/OS_info.txt 2>&1',
     },
 }
 OPENBMC_BASE = '/xyz/openbmc_project/'
diff --git a/lib/openbmc_ffdc_methods.robot b/lib/openbmc_ffdc_methods.robot
index cdd6778..5759ab7 100755
--- a/lib/openbmc_ffdc_methods.robot
+++ b/lib/openbmc_ffdc_methods.robot
@@ -315,7 +315,10 @@
     :FOR  ${cmd}  IN  @{cmd_list}
     \    ${logpath}=  Catenate  SEPARATOR=  ${LOG_PREFIX}  ${cmd[0]}.txt
     \    ${ffdc_file_sub_list}=  Execute Command and Write FFDC  ${cmd[0]}
-    ...      ${cmd[1]}  ${logpath}  target=OS
+    ...  ${cmd[1]}  ${logpath}  target=OS
+    \    # scp it to the LOG_PREFIX ffdc directory.
+    \    Log To Console  scp.Get File /tmp/${cmd[0]}.txt ${LOG_PREFIX}${cmd[0]}.txt
+    \    scp.Get File  /tmp/${cmd[0]}.txt  ${LOG_PREFIX}${cmd[0]}.txt
     \    ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}
     ...      ${ffdc_file_sub_list}
 
@@ -338,6 +341,8 @@
     \    ${logpath}=  Catenate  SEPARATOR=  ${LOG_PREFIX}  ${cmd[0]}.txt
     \    ${ffdc_file_sub_list}=  Execute Command and Write FFDC  ${cmd[0]}
     ...      ${cmd[1]}  ${logpath}  target=OS
+    \    Log To Console  scp.Get File /tmp/${cmd[0]}.txt ${LOG_PREFIX}${cmd[0]}.txt
+    \    scp.Get File  /tmp/${cmd[0]}.txt  ${LOG_PREFIX}${cmd[0]}.txt
     \    ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}
     ...      ${ffdc_file_sub_list}
 
@@ -372,6 +377,9 @@
 
     Rpvars  linux_distro
 
+    scp.Open Connection
+    ...  ${OS_HOST}  username=${OS_USERNAME}  password=${OS_PASSWORD}
+
     @{entries}=  Get FFDC OS All Distros Index
     :FOR  ${index}  IN  @{entries}
     \    ${ffdc_file_sub_list}=  Log OS All distros FFDC  ${index}
@@ -389,6 +397,10 @@
     \    ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}
     ...      ${ffdc_file_sub_list}
 
+    # Delete ffdc files still on OS and close scp.
+    OS Execute Command  rm -rf /tmp/OS_*
+    scp.Close Connection
+
     [Return]  ${ffdc_file_list}