Expand HN to HOSTNAME
[integration/test.git] / csit / libraries / DaeximKeywords.robot
index e1a7fb731f3e0e6c35c72a3c1a1573aa5015e51d..65833c2fe5847cd83c89af7ac587af0d5304ea04 100644 (file)
@@ -6,7 +6,7 @@ Library           RequestsLibrary
 Resource          ClusterManagement.robot
 Resource          ../variables/daexim/DaeximVariables.robot
 Resource          ../variables/Variables.robot
-Resource          Utils.robot
+Resource          SSHKeywords.robot
 
 *** Keywords ***
 Verify Export Files
@@ -23,13 +23,26 @@ Verify Export Files
     Builtin.Log    ${opr}
     Builtin.Should Match Regexp    ${opr}    .*${EXP_OPER_FILE}
 
+Verify Export Files Not Present
+    [Arguments]    ${host_index}
+    [Documentation]    Verify if the backedup files are not present in the controller
+    ${host_index}    Builtin.Convert To Integer    ${host_index}
+    ${cfg}    ClusterManagement.Run Bash Command On Member    ls -lart ${WORKSPACE}/${BUNDLEFOLDER}/daexim/${EXP_DATA_FILE}    ${host_index}
+    Builtin.Log    ${cfg}
+    Builtin.Should Not Match Regexp    ${cfg}    .*${EXP_DATA_FILE}
+    ${mdl}    ClusterManagement.Run Bash Command On Member    ls -lart ${WORKSPACE}/${BUNDLEFOLDER}/daexim/${MODELS_FILE}    ${host_index}
+    Builtin.Log    ${mdl}
+    Builtin.Should Not Match Regexp    ${mdl}    .*${MODELS_FILE}
+    ${opr}    ClusterManagement.Run Bash Command On Member    ls -lart ${WORKSPACE}/${BUNDLEFOLDER}/daexim/${EXP_OPER_FILE}    ${host_index}
+    Builtin.Log    ${opr}
+    Builtin.Should Not Match Regexp    ${opr}    .*${EXP_OPER_FILE}
+
 Cleanup The Export Files
     [Arguments]    ${host_index}
     [Documentation]    Verify if the export directory exists and delete the files if needed
     ${host_index}    Builtin.Convert To Integer    ${host_index}
     Builtin.Run Keyword And Ignore Error    ClusterManagement.Delete_And_Check_Member_List_Or_All    ${TOPOLOGY_URL}    ${host_index}
     ${output1}    Builtin.Run Keyword and IgnoreError    ClusterManagement.Run Bash Command On Member    sudo rm -rf ${WORKSPACE}/${BUNDLEFOLDER}/daexim;clear    ${host_index}
-    # Executing the deletion without sudo prevents "sudo: no tty present and no askpass program specified" errors
     ${output2}    Builtin.Run Keyword and IgnoreError    ClusterManagement.Run Bash Command On Member    rm -rf ${WORKSPACE}/${BUNDLEFOLDER}/daexim;clear    ${host_index}
     ${output}    ClusterManagement.Run Bash Command On Member    ls -lart ${WORKSPACE}/${BUNDLEFOLDER}    ${host_index}
     Builtin.Log    ${output}
@@ -55,7 +68,7 @@ Verify Export Status Message
     [Arguments]    ${status}    ${output}
     [Documentation]    Verify export restconf response message is as expected
     Builtin.Should Match Regexp    ${output}    "status": "${status}"
-    Builtin.Run Keyword If    "${status}" == "initial" or "${status}" == "scheduled"    Verify Json Files Not Present    ${output}
+    Builtin.Run Keyword If    "${status}" == "initial" or "${status}" == "scheduled" or "${status}" == "skipped"    Verify Json Files Not Present    ${output}
     ...    ELSE    Verify Json Files Present    ${output}
 
 Verify Json Files Present
@@ -75,7 +88,7 @@ Verify Json Files Not Present
     Builtin.Log    Did not Find all Json Files
 
 Schedule Export
-    [Arguments]    ${controller_index}    ${TIME}=500    ${exclude}=${FALSE}    ${MODULE}=${EMPTY}    ${STORE}=${EMPTY}
+    [Arguments]    ${controller_index}    ${TIME}=500    ${exclude}=${FALSE}    ${MODULE}=${EMPTY}    ${STORE}=${EMPTY}    ${FLAG}=false
     [Documentation]    Schedule Export job
     ${file}    Builtin.Set Variable If    ${exclude}    ${EXPORT_EXCLUDE_FILE}    ${EXPORT_FILE}
     ${JSON1}    OperatingSystem.Get File    ${file}
@@ -107,7 +120,7 @@ Return ConnnectionID
     [Arguments]    ${system}=${ODL_SYSTEM_IP}    ${prompt}=${DEFAULT_LINUX_PROMPT}    ${prompt_timeout}=${DEFAULT_TIMEOUT}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}
     [Documentation]    Returns the connection of any host. Defaults to controller
     ${conn_id}    SSHLibrary.Open Connection    ${system}    prompt=${prompt}    timeout=${prompt_timeout}
-    Utils.Flexible SSH Login    ${user}    ${password}
+    SSHKeywords.Flexible SSH Login    ${user}    ${password}
     [Return]    ${conn_id}
 
 Cleanup Directory
@@ -194,3 +207,10 @@ Schedule Import
     Builtin.Log    ${resp}
     Builtin.Should Match Regexp    ${resp}    .*"result": ${result}
     Builtin.Run Keyword If    "${reason}" != "${EMPTY}"    Builtin.Should Match Regexp    ${response_json}    .*"reason":"${reason}
+
+Cleanup Cluster Export Files
+    [Arguments]    ${member_index_list}=${EMPTY}
+    [Documentation]    This keyword cleansup export files of a cluster
+    ${index_list} =    List_Indices_Or_All    given_list=${member_index_list}
+    : FOR    ${index}    IN    @{index_list}    # usually: 1, 2, 3.
+    \    DaeximKeywords.Cleanup The Export Files    ${index}