Add retries for HWVTEP emulator setup
[integration/test.git] / csit / libraries / L2GatewayOperations.robot
index 245912de6b7466d641de284515a1c5d85beb780c..fa17b848348314f1742ae991afe213f1433ec61f 100644 (file)
@@ -1,5 +1,5 @@
 *** Settings ***
-Documentation     L2Gateway Operations Library. This library has useful keywords for various actions on Hwvtep and Ovs connectivity. Most of the keywords expects that ovs_conn_id,ovs2_conn_id, hwvtep_conn_id, hwvtep2_conn_id and devstack_conn_id are available.
+Documentation     L2Gateway Operations Library. This library has useful keywords for various actions on Hwvtep and Ovs connectivity. Most of the keywords expects that ovs_conn_id,ovs2_conn_id, hwvtep_conn_id, hwvtep2_conn_id and OS_CNTL_CONN_ID are available.
 Library           SSHLibrary
 Library           Collections
 Library           RequestsLibrary
@@ -17,7 +17,7 @@ ${L2GW_VAR_BASE}    ${CURDIR}/../variables/l2gw
 
 *** Keywords ***
 Add Ovs Bridge Manager Controller And Verify
-    [Arguments]    ${conn_id}=${ovs_conn_id}    ${hwvtep_bridge}=${HWVTEP_BRIDGE}
+    [Arguments]    ${conn_id}=${OS_CMP1_CONN_ID}    ${hwvtep_bridge}=${HWVTEP_BRIDGE}
     [Documentation]    Keyword to set OVS manager and controller to ${ODL_IP} for the OVS IP connected in ${conn_id} and verify the entries in OVSDB NETWORK TOPOLOGY and NETSTAT results.
     ${output}=    Exec Command    ${conn_id}    ${OVS_RESTART}
     ${output}=    Exec Command    ${conn_id}    ${OVS_DEL_MGR}
@@ -59,7 +59,7 @@ Add Vtep Manager And Verify
     ${output}=    Exec Command    ${conn_id}    ${NETSTAT}
     Should Contain    ${output}    ${OVSDBPORT}
     @{list_to_check}=    Create List    ${odl_ip}
-    Utils.Check For Elements At URI    ${HWVTEP_NETWORK_TOPOLOGY}    ${list_to_check}    session
+    Wait Until Keyword Succeeds    30s    2s    Utils.Check For Elements At URI    ${HWVTEP_NETWORK_TOPOLOGY}    ${list_to_check}    session
 
 Create Verify L2Gateway
     [Arguments]    ${bridge_name}    ${intf_name}    ${gw_name}
@@ -73,10 +73,23 @@ Create Verify L2Gateway
     Utils.Check For Elements At URI    ${L2GW_LIST_REST_URL}    ${list_to_check}    session
     [Return]    ${l2gw_output}
 
+Update And Verify L2Gateway
+    [Arguments]    ${bridge_name}    ${gw_name}    ${intf_name_1}    ${intf_name_2}
+    [Documentation]    Keyword to add interface {intf_name_2} to an existing L2 Gateway ${gw_name} for bridge ${bridge_name} (Using Neutron CLI).
+    ${l2gw_output}=    OpenStackOperations.Update L2Gateway    ${bridge_name}    ${gw_name}    ${intf_name_1}    ${intf_name_2}
+    ${output}=    OpenStackOperations.Get All L2Gateway
+    Log    ${output}
+    Should Contain    ${output}    ${gw_name}
+    Should Contain    ${output}    ${intf_name_1}
+    Should Contain    ${output}    ${intf_name_2}
+    @{list_to_check}=    Create List    ${gw_name}
+    Utils.Check For Elements At URI    ${L2GW_LIST_REST_URL}    ${list_to_check}    session
+    [Return]    ${l2gw_output}
+
 Delete L2Gateway
     [Arguments]    ${gw_name}
     [Documentation]    Keyword to delete the L2 Gateway ${gw_name} received in argument.
-    ${output}=    Exec Command    ${devstack_conn_id}    ${L2GW_DELETE} ${gw_name}
+    ${output}=    Exec Command    ${OS_CNTL_CONN_ID}    ${L2GW_DELETE} ${gw_name}
     Log    ${output}
     @{list_to_check}=    Create List    ${gw_name}
     Utils.Check For Elements Not At URI    ${L2GW_LIST_REST_URL}    ${list_to_check}    session
@@ -94,11 +107,22 @@ Create Verify L2Gateway Connection
     Utils.Check For Elements At URI    ${L2GW_CONN_LIST_REST_URL}    ${list_to_check}    session
     [Return]    ${l2gw_output}
 
+Verify L2Gateway Connection
+    [Arguments]    ${gw_name}    ${net_name}
+    [Documentation]    Keyword to verify existing L2 Gateway Connection for ${gw_name} to ${net_name} $(Using Neutron CLI).
+    ${l2gw_id}=    OpenStackOperations.Get L2gw Id    ${gw_name}
+    ${output}=    OpenStackOperations.Get All L2Gateway Connection
+    Log    ${output}
+    Should Contain    ${output}    ${l2gw_id}
+    @{list_to_check}=    Create List    ${l2gw_id}
+    Utils.Check For Elements At URI    ${L2GW_CONN_LIST_REST_URL}    ${list_to_check}    session
+    [Return]    ${l2gw_output}
+
 Delete L2Gateway Connection
     [Arguments]    ${gw_name}
     [Documentation]    Delete the L2 Gateway connection existing for Gateway ${gw_name} received in argument (Using Neutron CLI).
     ${l2gw_conn_id}=    OpenStackOperations.Get L2gw Connection Id    ${gw_name}
-    ${output}=    Exec Command    ${devstack_conn_id}    ${L2GW_CONN_DELETE} ${l2gw_conn_id}
+    ${output}=    Exec Command    ${OS_CNTL_CONN_ID}    ${L2GW_CONN_DELETE} ${l2gw_conn_id}
     @{list_to_check}=    Create List    ${l2gw_conn_id}
     Utils.Check For Elements Not At URI    ${L2GW_CONN_LIST_REST_URL}    ${list_to_check}    session
     Log    ${output}
@@ -106,7 +130,7 @@ Delete L2Gateway Connection
 Update Port For Hwvtep
     [Arguments]    ${port_name}
     [Documentation]    Keyword to update the Neutron Ports for specific configuration required to connect to HWVTEP (Using REST).
-    ${port_id}=    Get Port Id    ${port_name}    ${devstack_conn_id}
+    ${port_id}=    Get Port Id    ${port_name}
     Log    ${port_id}
     ${json_data}=    Get Neutron Port Rest    ${port_id}
     Should Contain    ${json_data}    ${STR_VIF_TYPE}
@@ -182,9 +206,9 @@ Get L2gw Debug Info
     Log    ${resp.content}
     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/network-topology:network-topology/topology/hwvtep:1
     Log    ${resp.content}
-    Exec Command    ${devstack_conn_id}    cat /etc/neutron/neutron.conf
-    Exec Command    ${devstack_conn_id}    cat /etc/neutron/l2gw_plugin.ini
-    Exec Command    ${devstack_conn_id}    ps -ef | grep neutron-server
+    Exec Command    ${OS_CNTL_CONN_ID}    cat /etc/neutron/neutron.conf
+    Exec Command    ${OS_CNTL_CONN_ID}    cat /etc/neutron/l2gw_plugin.ini
+    Exec Command    ${OS_CNTL_CONN_ID}    ps -ef | grep neutron-server
 
 Start Command In Hwvtep
     [Arguments]    ${command}    ${hwvtep_ip}
@@ -226,7 +250,7 @@ Verify Ovs Tunnel
     ${output}=    Exec Command    ${conn_id}    ${OVS_SHOW}
     Log    ${output}
     Should Contain    ${output}    key="${seg_id}", remote_ip="${ovs_ip}"
-    ${output}=    Exec Command    ${ovs_conn_id}    ${OVS_SHOW}
+    ${output}=    Exec Command    ${OS_CMP1_CONN_ID}    ${OVS_SHOW}
     Log    ${output}
     Should Contain    ${output}    key=flow, local_ip="${ovs_ip}", remote_ip="${hwvtep_ip}"
 
@@ -270,3 +294,9 @@ Verify Elan Flow Entries
     Should Contain    ${flow_output}    table=52
     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=52
     Log    ${sMac_output}
+
+Cleanup L2GW Optional Resources
+    [Documentation]    Cleanup resources that are only allocated on certain combos...
+    BuiltIn.Pass_Execution_If    "skip_if_${OPENSTACK_BRANCH}" in @{TEST_TAGS}    Not supported in Ocata/Pike
+    CompareStream.Run_Keyword_If_At_Most_Nitrogen    BuiltIn.Pass_Execution    Only run on oxygen and later
+    OpenStackOperations.Delete Port    ${HWVTEP_PORT_3}