Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / libraries / GBP / OpenFlowUtils.robot
index 721e3b697ab649ce18aa35d64178c4fe2338292d..69729ef9c1422f2c35f939cb37b4358d12a03317 100644 (file)
@@ -113,12 +113,13 @@ Find Flow in DPCTL Output
     @{lines}    Split To Lines    ${output}
     ${match_result}    Set Variable
     ${action_result}    Set Variable
-    : FOR    ${line}    IN    @{lines}
-    \    ${match}    Get Matches Part    ${line}
-    \    ${action}    Get Actions Part    ${line}
-    \    ${match_result}    Check Match    ${match}    @{flow_match_criteria}
-    \    ${action_result}    Check Match    ${action}    @{flow_action_criteria}
-    \    Run Keyword If    "${match_result}" == "TRUE" and "${action_result}" == "TRUE"    Return From Keyword    ${line}
+    FOR    ${line}    IN    @{lines}
+        ${match}    Get Matches Part    ${line}
+        ${action}    Get Actions Part    ${line}
+        ${match_result}    Check Match    ${match}    @{flow_match_criteria}
+        ${action_result}    Check Match    ${action}    @{flow_action_criteria}
+        Run Keyword If    "${match_result}" == "TRUE" and "${action_result}" == "TRUE"    Return From Keyword    ${line}
+    END
     Log    ${flow_match_criteria}
     Log    ${flow_action_criteria}
     Fail    Flow not found!
@@ -140,12 +141,13 @@ Check Match
     [Arguments]    ${string}    @{match_criteria}
     [Documentation]    Applies 'grep' on the string argument for each criterion.
     ${conditions}    Set Variable
-    : FOR    ${criterio}    IN    @{match_criteria}
-    \    ${grep_criterio}    Catenate    | grep    ${criterio}
-    \    ${conditions}    Catenate    ${conditions}    ${grep_criterio}
-    \    ${debug_output}    OperatingSystem.Run    echo "${string}" ${conditions}
-    \    Log    ${debug_output}
-    \    Run Keyword If    "${debug_output}" == "${EMPTY}"    Log    ${criterio}
+    FOR    ${criterio}    IN    @{match_criteria}
+        ${grep_criterio}    Catenate    | grep    ${criterio}
+        ${conditions}    Catenate    ${conditions}    ${grep_criterio}
+        ${debug_output}    OperatingSystem.Run    echo "${string}" ${conditions}
+        Log    ${debug_output}
+        Run Keyword If    "${debug_output}" == "${EMPTY}"    Log    ${criterio}
+    END
     ${output}    OperatingSystem.Run    echo "${string}" ${conditions}
     Log    ${output}
     Run Keyword If    "${output}" == "${EMPTY}"    Return From Keyword    FALSE
@@ -252,6 +254,14 @@ Wait For Flows On Switch
     Wait Until Keyword Succeeds    120s    20s    Count Flows On Switch    ${switch_name}
     SSHLibrary.Close Connection
 
+Show Switch Status
+    [Arguments]    ${switch_name}
+    [Documentation]    Shows status of a switch for easier debugging.
+    ${stdout}    ${stderr}    SSHLibrary.Execute Command    sudo ovs-ofctl dump-flows ${switch_name} -OOpenFlow13    return_stderr=True
+    Log    ${stdout}
+    ${stdout}    ${stderr}    SSHLibrary.Execute Command    sudo ovs-vsctl show    return_stderr=True
+    Log    ${stdout}
+
 Count Flows On Switch
     [Arguments]    ${switch_name}
     ${out}    SSHLibrary.Execute Command    printf "%d" $(($(sudo ovs-ofctl dump-flows ${switch_name} -OOpenFlow13 | wc -l)-1))