Add missing neutron cleanup
[integration/test.git] / csit / libraries / OpenStackOperations.robot
index 64baaacf74b63eb5c4324561d9792505873ac72e..df6e5989ba1f1d27fa66d0c78221701580b1c15f 100644 (file)
@@ -331,12 +331,12 @@ Collect VM IP Addresses
     [Return]    ${ip_list}    ${dhcp_ip}
 
 Get Match
-    [Arguments]    ${text}    ${regexp}
+    [Arguments]    ${text}    ${regexp}    ${index}=0
     [Documentation]    Wrapper around Get Regexp Matches to return None if not found or the first match if found.
     @{matches} =    String.Get Regexp Matches    ${text}    ${regexp}
     ${matches_length} =    Get Length    ${matches}
     BuiltIn.Set Test Variable    ${match}    None
-    BuiltIn.Run Keyword If    ${matches_length} > 0    BuiltIn.Set Test Variable    ${match}    @{matches}[0]
+    BuiltIn.Run Keyword If    ${matches_length} > ${index}    BuiltIn.Set Test Variable    ${match}    @{matches}[${index}]
     [Return]    ${match}
 
 Get VM IP
@@ -347,9 +347,9 @@ Get VM IP
     ${vm_ip} =    Set Variable    None
     ${dhcp_ip} =    Set Variable    None
     ${match} =    Get Match    ${vm_console_output}    ${REGEX_OBTAINED}
-    ${vm_ip} =    Get Match    ${match}    ${REGEX_IPV4}
-    ${match} =    Get Match    ${vm_console_output}    ${REGEX_NAMESERVER}
-    ${dhcp_ip} =    Get Match    ${match}    ${REGEX_IPV4}
+    ${vm_ip} =    Get Match    ${match}    ${REGEX_IPV4}    0
+    ${match} =    Get Match    ${vm_console_output}    ${REGEX_IPROUTE}
+    ${dhcp_ip} =    Get Match    ${match}    ${REGEX_IPV4}    1
     BuiltIn.Run Keyword If    '${fail_on_none}' == 'true'    Should Not Contain    ${vm_ip}    None
     BuiltIn.Run Keyword If    '${fail_on_none}' == 'true'    Should Not Contain    ${dhcp_ip}    None
     [Return]    ${vm_ip}    ${dhcp_ip}    ${vm_console_output}
@@ -1085,7 +1085,7 @@ Reboot Nova VM
     Should Not Be True    ${rc}
     Wait Until Keyword Succeeds    35s    10s    Verify VM Is ACTIVE    ${vm_name}
 
-Remove RSA Key From KnowHosts
+Remove RSA Key From KnownHosts
     [Arguments]    ${vm_ip}
     [Documentation]    Remove RSA
     ${devstack_conn_id}=    Get ControlNode Connection
@@ -1106,3 +1106,16 @@ Wait For Routes To Propogate
     \    ${cmd}=    Set Variable If    ${length} == 0    ip route    ip -6 route
     \    ${output}=    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ${cmd}    ]>
     \    Should Contain    ${output}    @{subnets}[${INDEX}]
+
+Neutron Cleanup
+    [Arguments]    ${vms}=@{EMPTY}    ${networks}=@{EMPTY}    ${subnets}=@{EMPTY}    ${ports}=@{EMPTY}    ${sgs}=@{EMPTY}
+    : FOR    ${vm}    IN    @{vms}
+    \    BuiltIn.Run Keyword And Ignore Error    Delete Vm Instance    ${vm}
+    : FOR    ${port}    IN    @{ports}
+    \    BuiltIn.Run Keyword And Ignore Error    Delete Port    ${port}
+    : FOR    ${subnet}    IN    @{subnets}
+    \    BuiltIn.Run Keyword And Ignore Error    Delete SubNet    ${subnet}
+    : FOR    ${network}    IN    @{networks}
+    \    BuiltIn.Run Keyword And Ignore Error    Delete Network    ${network}
+    : FOR    ${sg}    IN    @{sgs}
+    \    BuiltIn.Run Keyword And Ignore Error    Delete SecurityGroup    ${sg}