Collect all dumps available on BMC

Change-Id: I370959d86397f5e1cb50db56d5d99c88eadd76fb
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/data/variables.py b/data/variables.py
index d3d2c13..06271fe 100755
--- a/data/variables.py
+++ b/data/variables.py
@@ -103,8 +103,7 @@
 DUMP_ENTRY_URI = REST_DUMP_URI + 'entry/'
 DUMP_DOWNLOAD_URI = "/download/dump/"
 # The path on the BMC where dumps are stored.
-DUMP_DIR_PATH = "/var/lib/phosphor-debug-collector/dumps/"
-DUMP_HB_DIR_PATH = "/var/lib/phosphor-debug-collector/hostbootdump/"
+DUMP_DIR_PATH = "/var/lib/phosphor-debug-collector/"
 
 # Boot progress variables.
 STATE_DBUS_BASE = 'xyz.openbmc_project.State.'
diff --git a/lib/dump_utils.py b/lib/dump_utils.py
index cf4a30f..d0b0108 100755
--- a/lib/dump_utils.py
+++ b/lib/dump_utils.py
@@ -48,13 +48,11 @@
     """
 
     quiet = int(gp.get_var_value(quiet, 1))
-    cmd_buf = "bash -c;dump_dir_path=" + var.DUMP_DIR_PATH + " ; " \
-              + "for dump_id in $(ls ${dump_dir_path} | sort -n) ; do " \
-              + "file_path=$(ls ${dump_dir_path}${dump_id}/* 2>/dev/null)" \
-              + " || continue ; echo ${dump_id}:${file_path} ; done"
+    cmd_buf = "find /var/lib/phosphor-debug-collector/ -maxdepth 4 -type f"
     output, stderr, rc = bsu.bmc_execute_command(cmd_buf, quiet=quiet)
 
-    return vf.key_value_outbuf_to_dict(output)
+    BuiltIn().log_to_console(output)
+    return output.split("\n")
 
 
 def valid_dump(dump_id,
@@ -120,124 +118,15 @@
     targ_dir_path = gm.add_trailing_slash(targ_dir_path)
 
     if dump_dict is None:
-        dump_dict = get_dump_dict(quiet=quiet)
+        dump_list = get_dump_dict(quiet=quiet)
 
     status, ret_values = grk.run_key("Open Connection for SCP", quiet=quiet)
 
     dump_file_list = []
-    for dump_id, source_file_path in dump_dict.items():
+    for file_path in dump_list:
         targ_file_path = targ_dir_path + targ_file_prefix \
-            + os.path.basename(source_file_path)
-        status, ret_values = grk.run_key("scp.Get File  " + source_file_path
-                                         + "  " + targ_file_path, quiet=quiet)
-        dump_file_list.append(targ_file_path)
-
-    return dump_file_list
-
-
-def get_dump_hb_dict(quiet=None):
-    r"""
-    Get dump information and return as an ordered dictionary where the keys
-    are the dump IDs and the values are the full path names of the dumps.
-
-    Example robot program call:
-
-    ${dump_dict}=  Get Dump HB Dict
-    Rprint Vars  dump_hb_dict
-
-    Example output:
-
-    dump__hb_dict:
-      [1]:
-      /var/lib/phosphor-debug-collector/hostbootdump/1/hbdump_1_1621421112.tar.gz
-
-    Description of argument(s):
-    quiet                           If quiet is set to 1, this function will
-                                    NOT write status messages to stdout.
-    """
-
-    quiet = int(gp.get_var_value(quiet, 1))
-    cmd_buf = "bash-c;dump_hb_dir_path=" + var.DUMP_HB_DIR_PATH + " ; " \
-              + "for dump_id in $(ls ${dump_hb_dir_path} | sort -n) ; do " \
-              + "file_path=$(ls ${dump_hb_dir_path}${dump_id}/* 2>/dev/null)" \
-              + " || continue ; echo ${dump_id}:${file_path} ; done"
-    output, stderr, rc = bsu.bmc_execute_command(cmd_buf, quiet=quiet)
-
-    return vf.key_value_outbuf_to_dict(output)
-
-
-def valid_dump_hb(dump_id,
-                  dump_dict=None,
-                  quiet=None):
-    r"""
-    Verify that dump_id is a valid.  If it is not valid, issue robot failure
-    message.
-
-    A dump is valid if the indicated dump_id refers to an existing dump with a
-    valid associated dump file.
-
-    Description of argument(s):
-    dump_id                         A dump ID (e.g. "1", "2", etc.)
-    dump_dict                       A dump dictionary such as the one returned
-                                    by get_dump_hb_dict.  If this value is None,
-                                    this function will call get_dump_hb_dict on
-                                    the caller's behalf.
-    quiet                           If quiet is set to 1, this function will
-                                    NOT write status messages to stdout.
-    """
-
-    if dump_dict is None:
-        dump_dict = get_dump_hb_dict(quiet=quiet)
-
-    if dump_id not in dump_dict:
-        message = "The specified dump ID was not found among the existing" \
-            + " dumps:\n"
-        message += gp.sprint_var(dump_id)
-        message += gp.sprint_var(dump_dict)
-        BuiltIn().fail(gp.sprint_error(message))
-
-    if not dump_dict[dump_id].endswith("tar.gz"):
-        message = "There is no \"tar.gz\" file associated with the given" \
-            + " dump_id:\n"
-        message += gp.sprint_var(dump_id)
-        dump_file_path = dump_dict[dump_id]
-        message += gp.sprint_var(dump_file_path)
-        BuiltIn().fail(gp.sprint_error(message))
-
-
-def scp_dumps_hb(targ_dir_path,
-                 targ_file_prefix="",
-                 dump_dict=None,
-                 quiet=None):
-    r"""
-    SCP all dumps from the BMC to the indicated directory on the local system
-    and return a list of the new files.
-
-    Description of argument(s):
-    targ_dir_path                   The path of the directory to receive the
-                                    dump files.
-    targ_file_prefix                Prefix which will be pre-pended to each
-                                    target file's name.
-    dump_dict                       A dump dictionary such as the one returned
-                                    by get_dump_dict.  If this value is None,
-                                    this function will call get_dump_dict on
-                                    the caller's behalf.
-    quiet                           If quiet is set to 1, this function will
-                                    NOT write status messages to stdout.
-    """
-
-    targ_dir_path = gm.add_trailing_slash(targ_dir_path)
-
-    if dump_dict is None:
-        dump_dict = get_dump_hb_dict(quiet=quiet)
-
-    status, ret_values = grk.run_key("Open Connection for SCP", quiet=quiet)
-
-    dump_file_list = []
-    for dump_id, source_file_path in dump_dict.items():
-        targ_file_path = targ_dir_path + targ_file_prefix \
-            + os.path.basename(source_file_path)
-        status, ret_values = grk.run_key("scp.Get File  " + source_file_path
+            + os.path.basename(file_path)
+        status, ret_values = grk.run_key("scp.Get File  " + file_path
                                          + "  " + targ_file_path, quiet=quiet)
         dump_file_list.append(targ_file_path)
 
diff --git a/lib/openbmc_ffdc_list.py b/lib/openbmc_ffdc_list.py
index 459ef4f..f6ede12 100755
--- a/lib/openbmc_ffdc_list.py
+++ b/lib/openbmc_ffdc_list.py
@@ -211,7 +211,6 @@
         'Sys Inventory Files': 'System Inventory Files',
         'Dump Log': 'Collect Dump Log',
         'Dump Files': 'SCP Dump Files',
-        'Dump HB Files': 'SCP Dump HB Files',
         'PEL Files': 'Collect PEL Log',
         'Redfish Log': 'Enumerate Redfish Resources',
         'Firmware Log': 'Enumerate Redfish Resources  '
diff --git a/lib/openbmc_ffdc_methods.robot b/lib/openbmc_ffdc_methods.robot
index ba43510..fe68c9f 100755
--- a/lib/openbmc_ffdc_methods.robot
+++ b/lib/openbmc_ffdc_methods.robot
@@ -561,15 +561,6 @@
     [Return]  ${ffdc_file_list}
 
 
-SCP Dump HB Files
-    [Documentation]  Copy all HB dump files from BMC to local system.
-
-    # Check if dumps exist
-    ${ffdc_file_list}=  Scp Dumps HB  ${FFDC_DIR_PATH}  ${FFDC_PREFIX}
-
-    [Return]  ${ffdc_file_list}
-
-
 Collect Dump Log
     [Documentation]  Collect dumps from dump entry.
     [Arguments]  ${log_prefix_path}=${LOG_PREFIX}