Add changes to BMC cleanup module

This commit adds minor changes to BMC cleanup module and moves the
keywords to a new file lib/bmc_cleanup.robot. This helps to import
lib/bmc_cleanup.robot and use these keywords wherever necessary.

Change-Id: I138548a8118a44ad33ec7789aaa55e1a333c744b
Signed-off-by: Sunil M <sunilmam@us.ibm.com>
diff --git a/lib/bmc_cleanup.robot b/lib/bmc_cleanup.robot
new file mode 100644
index 0000000..909e57a
--- /dev/null
+++ b/lib/bmc_cleanup.robot
@@ -0,0 +1,51 @@
+*** Settings ***
+Resource                ../lib/utils.robot
+Resource                ../lib/connection_client.robot
+Resource                ../lib/boot_utils.robot
+
+*** Variables ***
+# User defined path to do the cleanup.
+${CLEANUP_DIR_PATH}  ${EMPTY}
+# List that holds space separated filepaths to skip from cleanup.
+${SKIP_LIST}  ${EMPTY}
+
+*** Keywords ***
+
+###############################################################################
+
+Cleanup Dir
+    [Documentation]  Remove leftover files in cleanup directory path.
+    [Arguments]      ${cleanup_dir_path}=${CLEANUP_DIR_PATH}
+    ...              ${skip_list}=${SKIP_LIST}
+
+    # Description of argument(s):
+    # cleanup_dir_path  Directory path to do the cleanup.
+    # skip_list  List of files to skip from cleanup.
+
+    Should Not Be Empty  ${cleanup_dir_path}
+    Should Not Be Empty  ${SKIP_LIST}
+    Open Connection And Log In
+    @{skip_list}=  Set Variable  ${skip_list.split()}
+    ${skip_list_string}=  Set Variable  ${EMPTY}
+    :FOR  ${file}  IN  @{skip_list}
+    \  ${skip_list_string}=   Set Variable  ${skip_list_string} ! -path "${file}"
+
+    ${file_count1}=  Execute Command On BMC  find ${cleanup_dir_path} | wc -l
+    Set Global Variable  ${file_count1}
+    Write  find ${cleanup_dir_path} \\( ${skip_list_string} \\) | xargs rm
+    Write  find ${cleanup_dir_path} \\( ${skip_list_string} \\) | xargs rmdir
+    ${file_count2}=  Execute Command On BMC  find ${cleanup_dir_path} | wc -l
+
+    Run Keyword If  ${file_count2} < ${file_count1}
+    ...  Reboot And Verify
+
+Reboot And Verify
+    [Documentation]  Reboot BMC and verify cleanup.
+    [Arguments]      ${cleanup_dir_path}=${CLEANUP_DIR_PATH}
+
+    # Description of argument(s):
+    # cleanup_dir_path  Directory path to do the cleanup.
+
+    OBMC Reboot (off)
+    ${file_count2}=  Execute Command On BMC  find ${cleanup_dir_path} | wc -l
+    Should Be True  ${file_count2} < ${file_count1}
diff --git a/tools/cleanup_bmc.robot b/tools/cleanup_bmc.robot
index 02f0d9e..6c7c84d 100644
--- a/tools/cleanup_bmc.robot
+++ b/tools/cleanup_bmc.robot
@@ -1,51 +1,11 @@
 *** Settings ***
 Documentation  Cleanup user patches from BMC.
 
-Library    ../lib/gen_robot_keyword.py
-Resource   ../lib/utils.robot
-Resource   ../extended/obmc_boot_test_resource.robot
-
-*** Variables ***
-
-# User defined path to cleanup.
-${CLEANUP_DIR_PATH}  ${EMPTY}
-# List that holds space separated filepaths to skip from cleanup.
-${SKIP_LIST}  ${EMPTY}
-# Number of files before cleanup.
-${file_count1}
+Resource   ../lib/bmc_cleanup.robot
 
 *** Test Cases ***
 
 Cleanup User Patches
     [Documentation]  Do the cleanup in cleanup directory path.
 
-    Should Not Be Empty  ${CLEANUP_DIR_PATH}
-    Open Connection And Log In
-    Remove Files
-
-*** Keywords ***
-
-Remove Files
-    [Documentation]  Remove leftover files in cleanup directory path.
-
-    Should Not Be Empty  ${SKIP_LIST}
-    @{skip_list}=  Set Variable  ${SKIP_LIST.split()}
-    ${skip_list_string}=  Set Variable  ${EMPTY}
-    :FOR  ${file}  IN  @{skip_list}
-    \  ${skip_list_string}=   Set Variable  ${skip_list_string} ! -path "${file}"
-
-    ${file_count1}=  Execute Command On BMC  find ${CLEANUP_DIR_PATH} | wc -l
-    Set Global Variable  ${file_count1}
-    Write  find ${CLEANUP_DIR_PATH} \\( ${skip_list_string} \\) | xargs rm
-    Write  find ${CLEANUP_DIR_PATH} \\( ${skip_list_string} \\) | xargs rmdir
-    ${file_count2}=  Execute Command On BMC  find ${CLEANUP_DIR_PATH} | wc -l
-
-    Run Keyword If  ${file_count2} < ${file_count1}
-    ...  Reboot And Verify
-
-Reboot And Verify
-    [Documentation]  Reboot BMC and verify cleanup.
-
-    Run Key U  OBMC Boot Test \ OBMC Reboot (off)
-    ${file_count2}=  Execute Command On BMC  find ${CLEANUP_DIR_PATH} | wc -l
-    Should Be True  ${file_count2} < ${file_count1}
+    Cleanup Dir