blob: 909e57a9c55641c189b9545786c4e29059cec004 [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)
50 ${file_count2}= Execute Command On BMC find ${cleanup_dir_path} | wc -l
51 Should Be True ${file_count2} < ${file_count1}