OS FFDC for RHEL, Ubuntu, IBM POWERKVM

This commit contains the following ffdc functions:
For Ubuntu:
OS_isusb
OS_kern
OS_authlog
OS_syslog
OS_info

For RHEL:
OS_secure
OS_rsct
OS_syslog
OS_info

For IBM POWERKVM:
OS_secure
OS_syslog
OS_info

Change-Id: I2d435c3f941402ee094d7f07ae0462f4b36125ed
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/lib/openbmc_ffdc.robot b/lib/openbmc_ffdc.robot
index 1f7caff..f4d330c 100755
--- a/lib/openbmc_ffdc.robot
+++ b/lib/openbmc_ffdc.robot
@@ -18,6 +18,13 @@
 ...                │       ├── 20160909102538035251_OS_msglog
 ...                │       ├── 20160909102538035251_OS_cpufrequency
 ...                │       ├── 20160909102538035251_OS_boot
+...                │       ├── 20160909102538035251_OS_isusb
+...                │       ├── 20160909102538035251_OS_kern
+...                │       ├── 20160909102538035251_OS_authlog
+...                │       ├── 20160909102538035251_OS_syslog
+...                │       ├── 20160909102538035251_OS_info
+...                │       ├── 20160909102538035251_OS_rsct
+...                │       ├── 20160909102538035251_OS_secure
 ...                │       └── 20160909102538035251_ffdc_report.txt
 ...                └── test_history.txt
 
diff --git a/lib/openbmc_ffdc_list.py b/lib/openbmc_ffdc_list.py
index f71309a..0e36d70 100755
--- a/lib/openbmc_ffdc_list.py
+++ b/lib/openbmc_ffdc_list.py
@@ -61,6 +61,42 @@
     },
 }
 
+# Add file name and correcponding command needed for Ubuntu Linux
+FFDC_OS_UBUNTU_FILE = {
+    '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',
+    },
+}
+
+# Add file name and correcponding command needed for RHEL Linux
+FFDC_OS_RHEL_FILE = {
+    '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',
+    },
+}
+
+# Add file name and correcponding command needed for RHEL Linux
+FFDC_OS_IBM_POWERKVM_FILE = {
+    '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',
+    },
+}
+
 # Add file name and correcponding Get Request
 FFDC_GET_REQUEST = {
     'GET REQUESTS':
@@ -185,6 +221,26 @@
         """
         return FFDC_OS_ALL_DISTROS_FILE[i_type].items()
 
+    def get_ffdc_os_distro_index(self, distro):
+        r"""
+        ########################################################################
+        #   @brief    This method returns the key pair from the dictionary
+        #   @return   Index of the method dictionary
+        ########################################################################
+        """
+        distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
+        return eval(distro_file).keys()
+
+    def get_ffdc_os_distro_call(self, i_type, distro):
+        r"""
+        ########################################################################
+        #   @brief    This method returns the key pair from the dictionary
+        #   @return   List of key pair keywords
+        ########################################################################
+        """
+        distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
+        return eval(distro_file)[i_type].items()
+
     def get_strip_string(self, i_str):
         r"""
         ########################################################################
diff --git a/lib/openbmc_ffdc_methods.robot b/lib/openbmc_ffdc_methods.robot
index 9bf2b11..ac866e6 100755
--- a/lib/openbmc_ffdc_methods.robot
+++ b/lib/openbmc_ffdc_methods.robot
@@ -67,7 +67,7 @@
 
 
 Execute Command and Write FFDC
-    [Documentation]    Execute command on BMC and write to ffdc
+    [Documentation]    Execute command on BMC or OS and write to ffdc
     ...                By default to ffdc_report.txt file else to
     ...                specified file path.
     [Arguments]        ${key_index}
@@ -163,25 +163,50 @@
     \   Log FFDC Get Requests   ${index}
 
 
-Log OS FFDC
+Log OS ALL DISTROS FFDC
     [Documentation]    Create file in current FFDC log directory.
     ...                Executes OS command and write to
     ...                corresponding file name.
     [Arguments]        ${key_index}
 
-    Open Connection And Log In  host=${OS_HOST}  username=${OS_USERNAME}
-    ...   password=${OS_PASSWORD}
     @{cmd_list}=  get ffdc os all distros call  ${key_index}
     :FOR  ${cmd}  IN  @{cmd_list}
     \   ${logpath}=  Catenate  SEPARATOR=  ${LOG_PREFIX}  ${cmd[0]}
     \   Execute Command and Write FFDC  ${cmd[0]}  ${cmd[1]}   ${logpath}
 
 
+Log OS SPECIFIC DISTRO FFDC
+    [Documentation]    Create file in current FFDC log directory.
+    ...                Executes OS command and write to
+    ...                corresponding file name.
+    [Arguments]        ${key_index}  ${linux_distro}
+
+    @{cmd_list}=  get ffdc os distro call  ${key_index}  ${linux_distro}
+    :FOR  ${cmd}  IN  @{cmd_list}
+    \   ${logpath}=  Catenate  SEPARATOR=  ${LOG_PREFIX}  ${cmd[0]}
+    \   Execute Command and Write FFDC  ${cmd[0]}  ${cmd[1]}   ${logpath}
+
+
+
 OS FFDC Files
     [Documentation]    Get the command list and iterate
 
     Return From Keyword If  '${OS_HOST}' == '${EMPTY}'
     ...   No OS Host Provided
+    Open Connection And Log In  host=${OS_HOST}  username=${OS_USERNAME}
+    ...   password=${OS_PASSWORD}
+
     @{entries}=  Get ffdc os all distros index
     :FOR  ${index}  IN  @{entries}
-    \   Log OS FFDC  ${index}
+    \   Log OS ALL DISTROS FFDC  ${index}
+
+    ${linux_distro}=  Execute Command
+    ...   . /etc/os-release; echo $ID
+    ...   return_stdout=True  return_stderr=False  return_rc=False
+
+    Return From Keyword If  '${linux_distro}' == '${EMPTY}' or '${linux_distro}' == 'None'
+    ...   Could not determine Linux Distribution
+
+    @{entries}=  Get ffdc os distro index  ${linux_distro}
+    :FOR  ${index}  IN  @{entries}
+    \   Log OS SPECIFIC DISTRO FFDC  ${index}  ${linux_distro}