blob: 2d3a45f63525e937dcfaf7eaa8fae2d2d9d77c6a [file] [log] [blame]
Sunil M22d293b2017-05-29 05:35:40 -05001*** Settings ***
2Resource ../lib/utils.robot
3Resource ../lib/connection_client.robot
4Resource ../lib/boot_utils.robot
5
6*** Variables ***
7# User defined path to do the cleanup.
8${CLEANUP_DIR_PATH} ${EMPTY}
9# List that holds space separated filepaths to skip from cleanup.
10${SKIP_LIST} ${EMPTY}
11
12*** Keywords ***
13
14###############################################################################
15
16Cleanup Dir
17 [Documentation] Remove leftover files in cleanup directory path.
18 [Arguments] ${cleanup_dir_path}=${CLEANUP_DIR_PATH}
19 ... ${skip_list}=${SKIP_LIST}
20
21 # Description of argument(s):
22 # cleanup_dir_path Directory path to do the cleanup.
23 # skip_list List of files to skip from cleanup.
24
25 Should Not Be Empty ${cleanup_dir_path}
26 Should Not Be Empty ${SKIP_LIST}
27 Open Connection And Log In
28 @{skip_list}= Set Variable ${skip_list.split()}
29 ${skip_list_string}= Set Variable ${EMPTY}
30 :FOR ${file} IN @{skip_list}
31 \ ${skip_list_string}= Set Variable ${skip_list_string} ! -path "${file}"
32
33 ${file_count1}= Execute Command On BMC find ${cleanup_dir_path} | wc -l
34 Set Global Variable ${file_count1}
35 Write find ${cleanup_dir_path} \\( ${skip_list_string} \\) | xargs rm
36 Write find ${cleanup_dir_path} \\( ${skip_list_string} \\) | xargs rmdir
37 ${file_count2}= Execute Command On BMC find ${cleanup_dir_path} | wc -l
38
39 Run Keyword If ${file_count2} < ${file_count1}
40 ... Reboot And Verify
41
42Reboot And Verify
43 [Documentation] Reboot BMC and verify cleanup.
44 [Arguments] ${cleanup_dir_path}=${CLEANUP_DIR_PATH}
45
46 # Description of argument(s):
47 # cleanup_dir_path Directory path to do the cleanup.
48
49 OBMC Reboot (off)
George Keishing8c59bea2017-06-27 11:12:39 -050050 # Take SSH session post BMC reboot before executing command.
51 Open Connection And Log In
Sunil M22d293b2017-05-29 05:35:40 -050052 ${file_count2}= Execute Command On BMC find ${cleanup_dir_path} | wc -l
53 Should Be True ${file_count2} < ${file_count1}