Fixes to SFC CSIT for neon-mri changes
[integration/test.git] / csit / libraries / OvsManager.robot
index 1c60b152a08709b89a0e8296b4b8eb492fa6a9b8..2ee870ac6f6086c47fe138af7c2f1d6de78638ac 100644 (file)
@@ -7,6 +7,8 @@ Library           Collections
 *** Variables ***
 ${SH_BR_CMD}      ovs-vsctl list Bridge
 ${SH_CNTL_CMD}    ovs-vsctl list Controller
+${SHOW_OVS_VERSION}    sudo ovs-vsctl show | grep version
+${GET_LOCAL_IP}    sudo ovs-vsctl list Open_vSwitch | grep local_ip=
 ${ovs_switch_data}    ${None}
 ${lprompt}        mininet>
 ${lcmd_prefix}    sh
@@ -228,12 +230,28 @@ Get Packet Count From Table
     [Return]    ${packetcount}
 
 Get Packet Count In Table For IP
-    [Arguments]    ${os_compute_ip}    ${table_no}    ${ip_address}
+    [Arguments]    ${os_compute_ip}    ${table_no}    ${ip_address}    ${additional_args}=${EMPTY}
     [Documentation]    Capture packetcount for IP in Table
-    ${cmd} =    BuiltIn.Set Variable    sudo ovs-ofctl dump-flows br-int -OOpenFlow13 | grep table=${table_no} | grep ${ip_address}
+    ${cmd} =    BuiltIn.Set Variable    sudo ovs-ofctl dump-flows br-int -OOpenFlow13 | grep table=${table_no} | grep ${ip_address} ${additional_args}
     ${output} =    Utils.Run Command On Remote System And Log    ${os_compute_ip}    ${cmd}
     @{output_list} =    String.Split String    ${output}    \r\n
     ${flow} =    Collections.Get From List    ${output_list}    0
     ${packetcount_list} =    String.Get Regexp Matches    ${flow}    n_packets=([0-9]+)    1
     ${count} =    Collections.Get From List    ${packetcount_list}    0
     [Return]    ${count}
+
+Check Ovs Version Is Higher Than
+    [Arguments]    ${ovs_version}    @{nodes}
+    [Documentation]    Get ovs version and verify greater than required version
+    : FOR    ${ip}    IN    @{nodes}
+    \    ${output} =    Utils.Run Command On Remote System    ${ip}    ${SHOW_OVS_VERSION}
+    \    ${version} =    String.Get Regexp Matches    ${output}    \[0-9].\[0-9]
+    \    ${result} =    BuiltIn.Convert To Number    ${version[0]}
+    \    BuiltIn.Should Be True    ${result} > ${ovs_version}
+
+Get OVS Local Ip
+    [Arguments]    ${ip}
+    [Documentation]    Get local ip of compute node ovsdb
+    ${cmd_output} =    Utils.Run Command On Remote System    ${ip}    ${GET_LOCAL_IP}
+    ${localip} =    String.Get Regexp Matches    ${cmd_output}    (\[0-9]+\.\[0-9]+\.\[0-9]+\.\[0-9]+)
+    [Return]    @{localip}[0]