Fail test cases on Exception in karaf.log
[integration/test.git] / csit / libraries / OpenStackOperations.robot
1 *** Settings ***
2 Documentation     Openstack library. This library is useful for tests to create network, subnet, router and vm instances
3 Library           Collections
4 Library           OperatingSystem
5 Library           RequestsLibrary
6 Library           SSHLibrary
7 Library           String
8 Resource          DataModels.robot
9 Resource          DevstackUtils.robot
10 Resource          L2GatewayOperations.robot
11 Resource          OVSDB.robot
12 Resource          SetupUtils.robot
13 Resource          SSHKeywords.robot
14 Resource          Tcpdump.robot
15 Resource          Utils.robot
16 Resource          ../variables/Variables.robot
17 Resource          ../variables/netvirt/Variables.robot
18 Variables         ../variables/netvirt/Modules.py
19 Variables         ../variables/netvirt/Exceptions_Whitelist.py
20
21 *** Keywords ***
22 Get Tenant ID From Security Group
23     [Documentation]    Returns tenant ID by reading it from existing default security-group.
24     ${output} =    OpenStack CLI    openstack security group show default | grep "| tenant_id" | awk '{print $4}'
25     [Return]    ${output}
26
27 Get Tenant ID From Network
28     [Arguments]    ${network_uuid}
29     [Documentation]    Returns tenant ID by reading it from existing network.
30     ${resp} =    TemplatedRequests.Get_From_Uri    uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/    accept=${ACCEPT_EMPTY}    session=session
31     ${tenant_id} =    Utils.Extract Value From Content    ${resp}    /network/0/tenant-id    strip
32     [Return]    ${tenant_id}
33
34 Create Network
35     [Arguments]    ${network_name}    ${additional_args}=${EMPTY}    ${verbose}=TRUE
36     [Documentation]    Create Network with neutron request.
37     ${output} =    OpenStack CLI    openstack network create ${network_name} ${additional_args}
38     [Return]    ${output}
39
40 Update Network
41     [Arguments]    ${network_name}    ${additional_args}=${EMPTY}
42     [Documentation]    Update Network with neutron request.
43     ${output} =    OpenStack CLI    openstack network set ${network_name} ${additional_args}
44     [Return]    ${output}
45
46 Show Network
47     [Arguments]    ${network_name}
48     [Documentation]    Show Network with neutron request.
49     ${output} =    OpenStack CLI    openstack network show ${network_name}
50     [Return]    ${output}
51
52 List Networks
53     [Documentation]    List networks and return output with neutron client.
54     ${output} =    OpenStack CLI    openstack network list
55     [Return]    ${output}
56
57 List Subnets
58     [Documentation]    List subnets and return output with neutron client.
59     ${output} =    OpenStack CLI    openstack subnet list
60     [Return]    ${output}
61
62 Delete Network
63     [Arguments]    ${network_name}
64     [Documentation]    Delete Network with neutron request.
65     ${output} =    OpenStack CLI    openstack network delete ${network_name}
66
67 Create SubNet
68     [Arguments]    ${network_name}    ${subnet_name}    ${range_ip}    ${additional_args}=${EMPTY}
69     [Documentation]    Create SubNet for the Network with neutron request.
70     ${output} =    OpenStack CLI    openstack subnet create --network ${network_name} --subnet-range ${range_ip} ${subnet_name} ${additional_args}
71
72 Update SubNet
73     [Arguments]    ${subnet_name}    ${additional_args}=${EMPTY}
74     [Documentation]    Update subnet with neutron request.
75     ${output} =    OpenStack CLI    openstack subnet set ${subnet_name} ${additional_args}
76     [Return]    ${output}
77
78 Show SubNet
79     [Arguments]    ${subnet_name}
80     [Documentation]    Show subnet with neutron request.
81     ${output} =    OpenStack CLI    openstack subnet show ${subnet_name}
82     [Return]    ${output}
83
84 Create Port
85     [Arguments]    ${network_name}    ${port_name}    ${sg}=default    ${additional_args}=${EMPTY}    ${allowed_address_pairs}=${EMPTY}
86     [Documentation]    Create Port with neutron request.
87     # if allowed_address_pairs is not empty we need to create the arguments to pass to the port create command. They are
88     # in a different format with the neutron vs openstack cli.
89     ${address_pair_length} =    BuiltIn.Get Length    ${allowed_address_pairs}
90     ${allowed_pairs_argv} =    BuiltIn.Set Variable    ${EMPTY}
91     ${allowed_pairs_argv} =    BuiltIn.Set Variable If    '${address_pair_length}'=='2'    --allowed-address ip-address=@{allowed_address_pairs}[0] --allowed-address ip-address=@{allowed_address_pairs}[1]    ${allowed_pairs_argv}
92     ${output} =    OpenStack CLI    openstack port create --network ${network_name} ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv}
93
94 Update Port
95     [Arguments]    ${port_name}    ${additional_args}=${EMPTY}
96     [Documentation]    Update port with neutron request.
97     ${output} =    OpenStack CLI    openstack port set ${port_name} ${additional_args}
98     [Return]    ${output}
99
100 Show Port
101     [Arguments]    ${port_name}
102     [Documentation]    Show port with neutron request.
103     ${output} =    OpenStack CLI    openstack port show ${port_name}
104     [Return]    ${output}
105
106 Delete Port
107     [Arguments]    ${port_name}
108     [Documentation]    Delete Port with neutron request.
109     ${output} =    OpenStack CLI    openstack port delete ${port_name}
110
111 List Ports
112     [Documentation]    List ports and return output with neutron client.
113     ${output} =    OpenStack CLI    openstack port list
114     [Return]    ${output}
115
116 List Nova VMs
117     [Documentation]    List VMs and return output with nova client.
118     ${output} =    OpenStack CLI    openstack server list --all-projects
119     [Return]    ${output}
120
121 Create And Associate Floating IPs
122     [Arguments]    ${external_net}    @{vm_list}
123     [Documentation]    Create and associate floating IPs to VMs with nova request
124     ${ip_list} =    BuiltIn.Create List    @{EMPTY}
125     : FOR    ${vm}    IN    @{vm_list}
126     \    ${output} =    OpenStack CLI    openstack floating ip create ${external_net}
127     \    @{ip} =    String.Get Regexp Matches    ${output}    [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
128     \    ${ip_length} =    BuiltIn.Get Length    ${ip}
129     \    BuiltIn.Run Keyword If    ${ip_length}>0    Collections.Append To List    ${ip_list}    @{ip}[0]
130     \    ...    ELSE    Collections.Append To List    ${ip_list}    None
131     \    ${output} =    OpenStack CLI    openstack server add floating ip ${vm} @{ip}[0]
132     [Return]    ${ip_list}
133
134 Delete Floating IP
135     [Arguments]    ${fip}
136     [Documentation]    Delete floating ip with neutron request.
137     ${output} =    OpenStack CLI    openstack floating ip delete ${fip}
138
139 Delete SubNet
140     [Arguments]    ${subnet}
141     [Documentation]    Delete SubNet for the Network with neutron request.
142     ${output} =    OpenStack CLI    openstack subnet delete ${subnet}
143
144 Delete Vm Instance
145     [Arguments]    ${vm_name}
146     [Documentation]    Delete Vm instances using instance names.
147     ${output} =    OpenStack CLI    openstack server delete ${vm_name}
148
149 Get Net Id
150     [Arguments]    ${network_name}
151     [Documentation]    Retrieve the net id for the given network name to create specific vm instance
152     ${output} =    OpenStack CLI    openstack network list | grep "${network_name}" | awk '{print $2}'
153     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
154     ${net_id} =    Collections.Get from List    ${splitted_output}    0
155     [Return]    ${net_id}
156
157 Get Subnet Id
158     [Arguments]    ${subnet_name}
159     [Documentation]    Retrieve the subnet id for the given subnet name
160     ${output} =    OpenStack CLI    openstack subnet show "${subnet_name}" | grep " id " | awk '{print $4}'
161     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
162     ${subnet_id} =    Collections.Get from List    ${splitted_output}    0
163     [Return]    ${subnet_id}
164
165 Get Port Id
166     [Arguments]    ${port_name}
167     [Documentation]    Retrieve the port id for the given port name to attach specific vm instance to a particular port
168     ${output} =    OpenStack CLI    openstack port list | grep "${port_name}" | awk '{print $2}'
169     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
170     ${port_id} =    Collections.Get from List    ${splitted_output}    0
171     [Return]    ${port_id}
172
173 Get Router Id
174     [Arguments]    ${router1}
175     [Documentation]    Retrieve the router id for the given router name
176     ${output} =    OpenStack CLI    openstack router show "${router1}" |awk '/ id / {print $4}'
177     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
178     ${router_id} =    Collections.Get from List    ${splitted_output}    0
179     [Return]    ${router_id}
180
181 Create Vm Instances
182     [Arguments]    ${net_name}    ${vm_instance_names}    ${image}=${EMPTY}    ${flavor}=m1.nano    ${sg}=default    ${min}=1
183     ...    ${max}=1
184     [Documentation]    Create X Vm Instance with the net id of the Netowrk.
185     ${image}    BuiltIn.Set Variable If    "${image}"=="${EMPTY}"    ${CIRROS_${OPENSTACK_BRANCH}}    ${image}
186     ${net_id} =    OpenStackOperations.Get Net Id    ${net_name}
187     : FOR    ${vm}    IN    @{vm_instance_names}
188     \    ${output} =    OpenStack CLI    openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${vm} --security-group ${sg} --min ${min} --max ${max}
189
190 Create Vm Instance On Compute Node
191     [Arguments]    ${net_name}    ${vm_name}    ${node_hostname}    ${image}=${EMPTY}    ${flavor}=m1.nano    ${sg}=default
192     [Documentation]    Create a VM instance on a specific compute node.
193     ${image} =    BuiltIn.Set Variable If    "${image}"=="${EMPTY}"    ${CIRROS_${OPENSTACK_BRANCH}}    ${image}
194     ${net_id} =    OpenStackOperations.Get Net Id    ${net_name}
195     ${output} =    OpenStack CLI    openstack server create ${vm_name} --image ${image} --flavor ${flavor} --nic net-id=${net_id} --security-group ${sg} --availability-zone nova:${node_hostname}
196
197 Create Vm Instance With Port
198     [Arguments]    ${port_name}    ${vm_instance_name}    ${image}=${EMPTY}    ${flavor}=m1.nano    ${sg}=default
199     [Documentation]    Create One VM instance using given ${port_name} and for given ${compute_node}
200     ${image} =    BuiltIn.Set Variable If    "${image}"=="${EMPTY}"    ${CIRROS_${OPENSTACK_BRANCH}}    ${image}
201     ${port_id} =    OpenStackOperations.Get Port Id    ${port_name}
202     ${output} =    OpenStack CLI    openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-group ${sg}
203
204 Create Vm Instance With Ports
205     [Arguments]    ${port_name}    ${port2_name}    ${vm_instance_name}    ${image}=${EMPTY}    ${flavor}=m1.nano    ${sg}=default
206     [Documentation]    Create One VM instance using given ${port_name} and for given ${compute_node}
207     ${image}    BuiltIn.Set Variable If    "${image}"=="${EMPTY}"    ${CIRROS_${OPENSTACK_BRANCH}}    ${image}
208     ${port_id} =    OpenStackOperations.Get Port Id    ${port_name}
209     ${port2_id} =    OpenStackOperations.Get Port Id    ${port2_name}
210     ${output} =    OpenStack CLI    openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --nic port-id=${port2_id} ${vm_instance_name} --security-group ${sg}
211
212 Create Vm Instance With Port On Compute Node
213     [Arguments]    ${port_name}    ${vm_instance_name}    ${node_hostname}    ${image}=${EMPTY}    ${flavor}=m1.nano    ${sg}=default
214     [Documentation]    Create One VM instance using given ${port_name} and for given ${compute_node}
215     ${image} =    BuiltIn.Set Variable If    "${image}"=="${EMPTY}"    ${CIRROS_${OPENSTACK_BRANCH}}    ${image}
216     ${port_id} =    OpenStackOperations.Get Port Id    ${port_name}
217     ${output} =    OpenStack CLI    openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --security-group ${sg} --availability-zone nova:${node_hostname} ${vm_instance_name}
218
219 Get Hypervisor Hostname From IP
220     [Arguments]    ${hypervisor_ip}
221     [Documentation]    Returns the hostname found for the given IP address if it's listed in hypervisor list. For debuggability
222     ...    the full listing is logged first, then followed by a grep | cut to focus on the actual hostname to return
223     ${output} =    OpenStack CLI    openstack hypervisor list
224     ${hostname} =    OpenStack CLI    openstack hypervisor list -f value | grep "${hypervisor_ip} " | cut -d" " -f 2
225     [Return]    ${hostname}
226
227 Create Nano Flavor
228     [Documentation]    Create a nano flavor
229     ${output} =    OpenStack CLI    openstack flavor create m1.nano --id auto --ram 64 --disk 0 --vcpus 1
230
231 Verify VM Is ACTIVE
232     [Arguments]    ${vm_name}
233     [Documentation]    Run these commands to check whether the created vm instance is active or not.
234     ${output} =    OpenStack CLI    openstack server show ${vm_name} | grep OS-EXT-STS:vm_state
235     BuiltIn.Should Contain    ${output}    active
236
237 Poll VM Is ACTIVE
238     [Arguments]    ${vm_name}    ${retry}=600s    ${retry_interval}=30s
239     [Documentation]    Run these commands to check whether the created vm instance is active or not.
240     BuiltIn.Wait Until Keyword Succeeds    ${retry}    ${retry_interval}    OpenStackOperations.Verify VM Is ACTIVE    ${vm_name}
241
242 Get Match
243     [Arguments]    ${text}    ${regexp}    ${index}=0
244     [Documentation]    Wrapper around String.Get Regexp Matches to return None if not found or the first match if found.
245     @{matches} =    String.Get Regexp Matches    ${text}    ${regexp}
246     ${matches_length} =    BuiltIn.Get Length    ${matches}
247     BuiltIn.Set Suite Variable    ${OS_MATCH}    None
248     BuiltIn.Run Keyword If    ${matches_length} > ${index}    BuiltIn.Set Suite Variable    ${OS_MATCH}    @{matches}[${index}]
249     [Return]    ${OS_MATCH}
250
251 Get VM IP
252     [Arguments]    ${fail_on_none}    ${vm}
253     [Documentation]    Get the vm ip address and nameserver by scraping the vm's console log.
254     ...    Get VM IP returns three values: [0] the vm IP, [1] the DHCP IP and [2] the vm console log.
255     ${vm_console_output} =    OpenStack CLI With No Log    openstack console log show ${vm}
256     ${vm_ip} =    BuiltIn.Set Variable    None
257     ${dhcp_ip} =    BuiltIn.Set Variable    None
258     ${match} =    OpenStackOperations.Get Match    ${vm_console_output}    ${REGEX_OBTAINED}
259     ${vm_ip} =    OpenStackOperations.Get Match    ${match}    ${REGEX_IPV4}    0
260     ${match} =    OpenStackOperations.Get Match    ${vm_console_output}    ${REGEX_IPROUTE}
261     ${dhcp_ip} =    OpenStackOperations.Get Match    ${match}    ${REGEX_IPV4}    1
262     BuiltIn.Run Keyword If    '${fail_on_none}' == 'true'    BuiltIn.Should Not Contain    ${vm_ip}    None
263     BuiltIn.Run Keyword If    '${fail_on_none}' == 'true'    BuiltIn.Should Not Contain    ${dhcp_ip}    None
264     [Return]    ${vm_ip}    ${dhcp_ip}    ${vm_console_output}
265
266 Get VM IPs
267     [Arguments]    @{vms}
268     [Documentation]    Get the instance IP addresses and nameserver address for the list of given vms.
269     ...    First poll for the vm instance to be in the active state, then poll for the vm ip address and nameserver.
270     ...    Get VM IPs returns two things: [0] a list of the ips for the vms passed to this keyword (may contain values
271     ...    of None) and [1] the dhcp ip address found in the last vm checked.
272     ...    TODO: there is a potential issue for a caller that passes in VMs belonging to different networks that
273     ...    may have different dhcp server addresses. Not sure what TODO about that, but noting it here for reference.
274     @{vm_ips}    BuiltIn.Create List    @{EMPTY}
275     : FOR    ${vm}    IN    @{vms}
276     \    OpenStackOperations.Poll VM Is ACTIVE    ${vm}
277     \    ${status}    ${ips_and_console_log}    BuiltIn.Run Keyword And Ignore Error    BuiltIn.Wait Until Keyword Succeeds    180s    15s
278     \    ...    OpenStackOperations.Get VM IP    true    ${vm}
279     \    # If there is trouble with Get VM IP, the status will be FAIL and the return value will be a string of what went
280     \    # wrong. We need to handle both the PASS and FAIL cases. In the FAIL case we know we wont have access to the
281     \    # console log, as it would not be returned; so we need to grab it again to log it. We also can append 'None' to
282     \    # the vm ip list if status is FAIL.
283     \    BuiltIn.Run Keyword If    "${status}" == "PASS"    BuiltIn.Log    ${ips_and_console_log[2]}
284     \    BuiltIn.Run Keyword If    "${status}" == "PASS"    Collections.Append To List    ${vm_ips}    ${ips_and_console_log[0]}
285     \    BuiltIn.Run Keyword If    "${status}" == "FAIL"    Collections.Append To List    ${vm_ips}    None
286     \    ${vm_console_output} =    BuiltIn.Run Keyword If    "${status}" == "FAIL"    OpenStack CLI    openstack console log show ${vm}
287     \    BuiltIn.Run Keyword If    "${status}" == "FAIL"    BuiltIn.Log    ${vm_console_output}
288     OpenStackOperations.Copy DHCP Files From Control Node
289     [Return]    @{vm_ips}    ${ips_and_console_log[1]}
290
291 Collect VM IPv6 SLAAC Addresses
292     [Arguments]    ${fail_on_none}    ${vm_list}    ${network}    ${subnet}
293     [Documentation]    For each VM parse output of "openstack server show" to get its IPv6 address from Neutron DB.
294     ...    Then try to connect to each VM by SSH and execute there "ip -6 a" command. This double-check allows to
295     ...    obtain and compare IP info (Neutron DB vs dnsmasque/ODL DHCP) and to test L2 connectivity as well.
296     ...    Returns an empty list if no IPv6 addresses found or if SSH connection fails.
297     ...    Otherwise, returns a list of IPv6 addresses.
298     ${ipv6_list} =    BuiltIn.Create List    @{EMPTY}
299     : FOR    ${vm}    IN    @{vm_list}
300     \    ${output} =    OpenStack CLI    openstack server show ${vm} -f shell
301     \    ${pattern} =    String.Replace String    ${subnet}    ::/64    (:[a-f0-9]{,4}){,4}
302     \    @{vm_ipv6} =    String.Get Regexp Matches    ${output}    ${pattern}
303     \    ${vm_ip_length} =    BuiltIn.Get Length    ${vm_ipv6}[0]
304     \    ${ipv6_data_from_vm} =    BuiltIn.Run Keyword If    ${vm_ip_length}>0    OpenStackOperations.Execute Command on VM Instance    ${network}    ${vm_ipv6[0]}
305     \    ...    ip -6 a
306     \    @{ipv6} =    String.Get Regexp Matches    ${ipv6_data_from_vm}    ${pattern}
307     \    ${ipv6_addr_list_length}    BuiltIn.Get Length    @{ipv6}
308     \    BuiltIn.Run Keyword If    ${ipv6_addr_list_length}>0    Collections.Append To List    ${ipv6_list}    ${ipv6[0]}
309     \    ...    ELSE    Collections.Append To List    ${ipv6_list}    None
310     [Return]    ${ipv6_list}
311
312 View Vm Console
313     [Arguments]    ${vm_instance_names}
314     [Documentation]    View Console log of the created vm instances using nova show.
315     : FOR    ${vm}    IN    @{vm_instance_names}
316     \    ${output} =    OpenStack CLI    openstack server show ${vm}
317     \    ${output} =    OpenStack CLI    openstack console log show ${vm}
318
319 Ping Vm From DHCP Namespace
320     [Arguments]    ${net_name}    ${vm_ip}
321     [Documentation]    Reach all Vm Instance with the net id of the Netowrk.
322     OpenStackOperations.Get ControlNode Connection
323     ${net_id} =    OpenStackOperations.Get Net Id    ${net_name}
324     ${output} =    DevstackUtils.Write Commands Until Prompt And Log    sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip}    20s
325     BuiltIn.Should Contain    ${output}    64 bytes
326
327 Ping From DHCP Should Not Succeed
328     [Arguments]    ${net_name}    ${vm_ip}
329     [Documentation]    Should Not Reach Vm Instance with the net id of the Netowrk.
330     Return From Keyword If    "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
331     OpenStackOperations.Get ControlNode Connection
332     ${net_id} =    OpenStackOperations.Get Net Id    ${net_name}
333     ${output} =    DevstackUtils.Write Commands Until Prompt And Log    sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip}    20s
334     BuiltIn.Should Not Contain    ${output}    64 bytes
335
336 Ping Vm From Control Node
337     [Arguments]    ${vm_floating_ip}    ${additional_args}=${EMPTY}
338     [Documentation]    Ping VM floating IP from control node
339     OpenStackOperations.Get ControlNode Connection
340     ${output} =    DevstackUtils.Write Commands Until Prompt And Log    ping ${additional_args} -c 3 ${vm_floating_ip}    20s
341     BuiltIn.Should Contain    ${output}    64 bytes
342
343 Curl Metadata Server
344     [Documentation]    Ping to the expected destination ip.
345     ${output} =    Utils.Write Commands Until Expected Prompt    curl -i http://169.254.169.254    ${OS_SYSTEM_PROMPT}
346     DevstackUtils.Write Commands Until Prompt    exit
347     BuiltIn.Should Contain    ${output}    200
348
349 Close Vm Instance
350     [Documentation]    Exit the vm instance.
351     ${output} =    DevstackUtils.Write Commands Until Prompt And Log    exit
352
353 Check If Console Is VmInstance
354     [Arguments]    ${console}=cirros
355     [Documentation]    Check if the session has been able to login to the VM instance
356     ${output} =    Utils.Write Commands Until Expected Prompt    id    ${OS_SYSTEM_PROMPT}
357     BuiltIn.Should Contain    ${output}    ${console}
358
359 Exit From Vm Console
360     [Documentation]    Check if the session has been able to login to the VM instance and exit the instance
361     ${rcode} =    BuiltIn.Run Keyword And Return Status    OpenStackOperations.Check If Console Is VmInstance    cirros
362     BuiltIn.Run Keyword If    ${rcode}    DevstackUtils.Write Commands Until Prompt    exit
363
364 Check Ping
365     [Arguments]    ${ip_address}    ${ttl}=64
366     [Documentation]    Run Ping command on the IP available as argument
367     ${ethertype} =    String.Get Regexp Matches    ${ip_address}    ${IP_REGEX}
368     ${output} =    BuiltIn.Run Keyword If    ${ethertype}    Utils.Write Commands Until Expected Prompt    ping -t ${ttl} -c 3 ${ip_address}    ${OS_SYSTEM_PROMPT}
369     ...    ELSE    Utils.Write Commands Until Expected Prompt    ping6 -t ${ttl} -c 3 ${ip_address}    ${OS_SYSTEM_PROMPT}
370     BuiltIn.Should Contain    ${output}    64 bytes
371
372 Check No Ping
373     [Arguments]    ${ip_address}    ${ttl}=64
374     [Documentation]    Run Ping command to the IP given as argument, executing 3 times and expecting NOT to see "64 bytes"
375     ${output} =    Utils.Write Commands Until Expected Prompt    ping -t ${ttl} -c 3 ${ip_address}    ${OS_SYSTEM_PROMPT}
376     BuiltIn.Should Not Contain    ${output}    64 bytes
377
378 Check Metadata Access
379     [Documentation]    Try curl on the Metadataurl and check if it is okay
380     ${output} =    Utils.Write Commands Until Expected Prompt    curl -i http://169.254.169.254    ${OS_SYSTEM_PROMPT}
381     BuiltIn.Should Contain    ${output}    200
382
383 Execute Command on VM Instance
384     [Arguments]    ${net_name}    ${vm_ip}    ${cmd}    ${user}=cirros    ${password}=cubswin:)
385     [Documentation]    Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
386     OpenStackOperations.Get ControlNode Connection
387     ${net_id} =    OpenStackOperations.Get Net Id    ${net_name}
388     ${output} =    Utils.Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ssh ${user}@${vm_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null    password:
389     ${output} =    Utils.Write Commands Until Expected Prompt    ${password}    ${OS_SYSTEM_PROMPT}
390     ${rcode} =    BuiltIn.Run Keyword And Return Status    OpenStackOperations.Check If Console Is VmInstance
391     ${output} =    BuiltIn.Run Keyword If    ${rcode}    Utils.Write Commands Until Expected Prompt    ${cmd}    ${OS_SYSTEM_PROMPT}
392     [Teardown]    Exit From Vm Console
393     [Return]    ${output}
394
395 Test Operations From Vm Instance
396     [Arguments]    ${net_name}    ${src_ip}    ${dest_ips}    ${user}=cirros    ${password}=cubswin:)    ${ttl}=64
397     ...    ${ping_should_succeed}=True    ${check_metadata}=True
398     [Documentation]    Login to the vm instance using ssh in the network.
399     OpenStackOperations.Get ControlNode Connection
400     ${net_id} =    OpenStackOperations.Get Net Id    ${net_name}
401     ${output} =    Utils.Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no ${user}@${src_ip} -o UserKnownHostsFile=/dev/null    password:
402     ${output} =    Utils.Write Commands Until Expected Prompt    ${password}    ${OS_SYSTEM_PROMPT}
403     ${rcode} =    BuiltIn.Run Keyword And Return Status    OpenStackOperations.Check If Console Is VmInstance
404     BuiltIn.Run Keyword If    ${rcode}    Utils.Write Commands Until Expected Prompt    ifconfig    ${OS_SYSTEM_PROMPT}
405     BuiltIn.Run Keyword If    ${rcode}    Utils.Write Commands Until Expected Prompt    route -n    ${OS_SYSTEM_PROMPT}
406     BuiltIn.Run Keyword If    ${rcode}    Utils.Write Commands Until Expected Prompt    route -A inet6    ${OS_SYSTEM_PROMPT}
407     BuiltIn.Run Keyword If    ${rcode}    Utils.Write Commands Until Expected Prompt    arp -an    ${OS_SYSTEM_PROMPT}
408     BuiltIn.Run Keyword If    ${rcode}    Utils.Write Commands Until Expected Prompt    ip -f inet6 neigh show    ${OS_SYSTEM_PROMPT}
409     : FOR    ${dest_ip}    IN    @{dest_ips}
410     \    ${string_empty} =    BuiltIn.Run Keyword And Return Status    Should Be Empty    ${dest_ip}
411     \    BuiltIn.Run Keyword If    ${string_empty}    Continue For Loop
412     \    BuiltIn.Run Keyword If    ${rcode} and "${ping_should_succeed}" == "True"    OpenStackOperations.Check Ping    ${dest_ip}    ttl=${ttl}
413     \    ...    ELSE    OpenStackOperations.Check No Ping    ${dest_ip}    ttl=${ttl}
414     ${ethertype} =    String.Get Regexp Matches    ${src_ip}    ${IP_REGEX}
415     BuiltIn.Run Keyword If    ${rcode} and "${check_metadata}" and ${ethertype} == "True"    OpenStackOperations.Check Metadata Access
416     [Teardown]    Exit From Vm Console
417
418 Test Netcat Operations From Vm Instance
419     [Arguments]    ${net_name}    ${vm_ip}    ${dest_ip}    ${additional_args}=${EMPTY}    ${port}=12345    ${user}=cirros
420     ...    ${password}=cubswin:)
421     [Documentation]    Use Netcat to test TCP/UDP connections to the controller
422     ${client_data}    BuiltIn.Set Variable    Test Client Data
423     ${server_data}    BuiltIn.Set Variable    Test Server Data
424     OpenStackOperations.Get ControlNode Connection
425     ${output} =    DevstackUtils.Write Commands Until Prompt And Log    ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
426     ${output} =    DevstackUtils.Write Commands Until Prompt And Log    sudo netstat -nlap | grep ${port}
427     ${nc_output} =    OpenStackOperations.Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo echo "${client_data}" | nc -v -w 5 ${additional_args} ${dest_ip} ${port}
428     BuiltIn.Log    ${output}
429     ${output} =    OpenStackOperations.Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo route -n
430     BuiltIn.Log    ${output}
431     ${output} =    OpenStackOperations.Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo arp -an
432     BuiltIn.Log    ${output}
433     BuiltIn.Should Match Regexp    ${nc_output}    ${server_data}
434
435 Ping Other Instances
436     [Arguments]    ${list_of_external_dst_ips}
437     [Documentation]    Check reachability with other network's instances.
438     ${rcode} =    BuiltIn.Run Keyword And Return Status    OpenStackOperations.Check If Console Is VmInstance
439     : FOR    ${dest_ip}    IN    @{list_of_external_dst_ips}
440     \    OpenStackOperations.Check Ping    ${dest_ip}
441
442 Create Router
443     [Arguments]    ${router_name}
444     [Documentation]    Create Router and Add Interface to the subnets.
445     ${output} =    OpenStack CLI    openstack router create ${router_name}
446
447 List Routers
448     [Documentation]    List Routers and return output with neutron client.
449     ${output} =    OpenStack CLI    openstack router list -f value
450     [Return]    ${output}
451
452 Add Router Interface
453     [Arguments]    ${router_name}    ${interface_name}
454     ${output} =    OpenStack CLI    openstack router add subnet ${router_name} ${interface_name}
455
456 Show Router Interface
457     [Arguments]    ${router_name}
458     [Documentation]    List Routers interface associated with given Router and return output with neutron client.
459     ${output} =    OpenStack CLI    openstack port list --router ${router_name} -f value
460     [Return]    ${output}
461
462 Add Router Gateway
463     [Arguments]    ${router_name}    ${external_network_name}
464     ${output} =    OpenStack CLI    openstack router set ${router_name} --external-gateway ${external_network_name}
465
466 Remove Interface
467     [Arguments]    ${router_name}    ${interface_name}
468     [Documentation]    Remove Interface to the subnets.
469     ${output} =    OpenStack CLI    openstack router remove subnet ${router_name} ${interface_name}
470
471 Remove Gateway
472     [Arguments]    ${router_name}
473     [Documentation]    Remove external gateway from the router.
474     BuiltIn.Log    openstack router unset ${router_name} --external-gateway
475
476 Update Router
477     [Arguments]    ${router_name}    ${cmd}
478     [Documentation]    Update the router with the command. Router name and command should be passed as argument.
479     ${output} =    OpenStack CLI    openstack router set ${router_name} ${cmd}
480
481 Show Router
482     [Arguments]    ${router_name}    ${options}
483     [Documentation]    Show information of a given router. Router name and optional fields should be sent as arguments.
484     ${output} =    OpenStack CLI    openstack router show ${router_name}
485
486 Delete Router
487     [Arguments]    ${router_name}
488     [Documentation]    Delete Router and Interface to the subnets.
489     ${output} =    OpenStack CLI    openstack router delete ${router_name}
490
491 Get DumpFlows And Ovsconfig
492     [Arguments]    ${conn_id}
493     [Documentation]    Get the OvsConfig and Flow entries from OVS from the Openstack Node
494     SSHLibrary.Switch Connection    ${conn_id}
495     Utils.Write Commands Until Expected Prompt    ip -o link    ${DEFAULT_LINUX_PROMPT_STRICT}
496     Utils.Write Commands Until Expected Prompt    ip -o addr    ${DEFAULT_LINUX_PROMPT_STRICT}
497     Utils.Write Commands Until Expected Prompt    ip route    ${DEFAULT_LINUX_PROMPT_STRICT}
498     Utils.Write Commands Until Expected Prompt    arp -an    ${DEFAULT_LINUX_PROMPT_STRICT}
499     ${nslist} =    Utils.Write Commands Until Expected Prompt    ip netns list | awk '{print $1}'    ${DEFAULT_LINUX_PROMPT_STRICT}
500     @{lines}    Split To Lines    ${nslist}    end=-1
501     : FOR    ${line}    IN    @{lines}
502     \    Utils.Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip -o link    ${DEFAULT_LINUX_PROMPT_STRICT}
503     \    Utils.Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip -o addr    ${DEFAULT_LINUX_PROMPT_STRICT}
504     \    Utils.Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip route    ${DEFAULT_LINUX_PROMPT_STRICT}
505     Utils.Write Commands Until Expected Prompt    sudo ovs-vsctl show    ${DEFAULT_LINUX_PROMPT_STRICT}
506     Utils.Write Commands Until Expected Prompt    sudo ovs-vsctl list Open_vSwitch    ${DEFAULT_LINUX_PROMPT_STRICT}
507     Utils.Write Commands Until Expected Prompt    sudo ovs-ofctl show br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
508     Utils.Write Commands Until Expected Prompt    sudo ovs-ofctl dump-flows br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
509     Utils.Write Commands Until Expected Prompt    sudo ovs-ofctl dump-groups br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
510     Utils.Write Commands Until Expected Prompt    sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
511
512 Get ControlNode Connection
513     SSHLibrary.Switch Connection    ${OS_CNTL_CONN_ID}
514     [Return]    ${OS_CNTL_CONN_ID}
515
516 Get OvsDebugInfo
517     [Documentation]    Get the OvsConfig and Flow entries from all Openstack nodes
518     BuiltIn.Run Keyword If    0 < ${NUM_OS_SYSTEM}    OpenStackOperations.Get DumpFlows And Ovsconfig    ${OS_CNTL_CONN_ID}
519     BuiltIn.Run Keyword If    1 < ${NUM_OS_SYSTEM}    OpenStackOperations.Get DumpFlows And Ovsconfig    ${OS_CMP1_CONN_ID}
520     BuiltIn.Run Keyword If    2 < ${NUM_OS_SYSTEM}    OpenStackOperations.Get DumpFlows And Ovsconfig    ${OS_CMP2_CONN_ID}
521
522 Get Test Teardown Debugs
523     [Arguments]    ${test_name}=${SUITE_NAME}.${TEST_NAME}
524     OpenStackOperations.Get OvsDebugInfo
525     BuiltIn.Run Keyword And Ignore Error    DataModels.Get Model Dump    ${HA_PROXY_IP}    ${netvirt_data_models}
526     KarafKeywords.Get Karaf Log Events From Test Start    ${test_name}
527     Run Keyword If    "${FAIL_ON_EXCEPTIONS}"=="True"    Fail If Exceptions Found During Test    ${test_name}    ${NETVIRT_EXCEPTIONS_WHITELIST}
528
529 Get Test Teardown Debugs For SFC
530     [Arguments]    ${test_name}=${TEST_NAME}
531     BuiltIn.Run Keyword And Ignore Error    DataModels.Get Model Dump    ${HA_PROXY_IP}    ${netvirt_sfc_data_models}
532
533 Show Debugs
534     [Arguments]    @{vm_indices}
535     [Documentation]    Run these commands for debugging, it can list state of VM instances and ip information in control node
536     OpenStackOperations.Get ControlNode Connection
537     ${output} =    DevstackUtils.Write Commands Until Prompt And Log    sudo ip netns list
538     : FOR    ${index}    IN    @{vm_indices}
539     \    ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    nova show ${index}
540     \    BuiltIn.Log    ${output}
541     OpenStackOperations.List Nova VMs
542     OpenStackOperations.List Routers
543     OpenStackOperations.List Networks
544     OpenStackOperations.List Subnets
545     OpenStackOperations.List Ports
546     OpenStackOperations.List Security Groups
547
548 List Security Groups
549     [Documentation]    Logging keyword to display all security groups using the openstack cli. Assumes openstack
550     ...    credentials are already sourced
551     ${output} =    OpenStack CLI    openstack security group list
552     [Return]    ${output}
553
554 Neutron Security Group Show
555     [Arguments]    ${SecurityGroupRuleName}
556     [Documentation]    Displays the neutron security group configurations that belongs to a given neutron security group name
557     ${output} =    OpenStack CLI    openstack security group show ${SecurityGroupRuleName}
558     [Return]    ${output}
559
560 Neutron Port Show
561     [Arguments]    ${PortName}
562     [Documentation]    Display the port configuration that belong to a given neutron port
563     ${output} =    OpenStack CLI    openstack port show ${PortName}
564     [Return]    ${output}
565
566 Neutron Security Group Create
567     [Arguments]    ${SecurityGroupName}    ${additional_args}=${EMPTY}
568     [Documentation]    Create a security group with specified name ,description & protocol value according to security group template
569     OpenStackOperations.Get ControlNode Connection
570     ${output} =    OpenStack CLI    openstack security group create ${SecurityGroupName} ${additional_args}
571     ${sgp_id} =    BuiltIn.Should Match Regexp    ${output}    ${REGEX_UUID}
572     [Return]    ${output}    ${sgp_id}
573
574 Neutron Security Group Update
575     [Arguments]    ${SecurityGroupName}    ${additional_args}=${EMPTY}
576     [Documentation]    Updating security groups
577     ${output} =    OpenStack CLI    openstack security group set ${SecurityGroupName} ${additional_args}
578     [Return]    ${output}
579
580 Delete SecurityGroup
581     [Arguments]    ${sg_name}
582     [Documentation]    Delete Security group
583     ${output} =    OpenStack CLI    openstack security group delete ${sg_name}
584
585 Neutron Security Group Rule Create
586     [Arguments]    ${Security_group_name}    &{Kwargs}
587     [Documentation]    Creates neutron security rule with Openstack CLI with or without optional params, here security group name is mandatory args, rule with optional params can be created by passing the optional args values ex: direction=${INGRESS_EGRESS}, Then these optional params are BuiltIn.Catenated with mandatory args, example of usage: "OpenStack Neutron Security Group Rule Create ${SGP_SSH} direction=${RULE_PARAMS[0]} ethertype=${RULE_PARAMS[1]} ..."
588     BuiltIn.Run Keyword If    ${Kwargs}    BuiltIn.Log    ${Kwargs}
589     ${description}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    description    default=${None}
590     ${direction}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    direction    default=${None}
591     ${ethertype}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    ethertype    default=${None}
592     ${port_range_max}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    port_range_max    default=${None}
593     ${port_range_min}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    port_range_min    default=${None}
594     ${protocol}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    protocol    default=${None}
595     ${remote_group_id}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    remote_group_id    default=${None}
596     ${remote_ip_prefix}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    remote_ip_prefix    default=${None}
597     ${cmd} =    BuiltIn.Set Variable    openstack security group rule create ${Security_group_name}
598     ${cmd} =    BuiltIn.Run Keyword If    '${description}'!='None'    BuiltIn.Catenate    ${cmd}    --description ${description}
599     ...    ELSE    BuiltIn.Catenate    ${cmd}
600     ${cmd} =    BuiltIn.Run Keyword If    '${direction}'!='None'    BuiltIn.Catenate    ${cmd}    --${direction}
601     ...    ELSE    BuiltIn.Catenate    ${cmd}
602     ${cmd} =    BuiltIn.Run Keyword If    '${ethertype}'!='None'    BuiltIn.Catenate    ${cmd}    --ethertype ${ethertype}
603     ...    ELSE    BuiltIn.Catenate    ${cmd}
604     ${cmd} =    BuiltIn.Run Keyword If    '${port_range_min}'!='None' and '${port_range_max}'!='None'    BuiltIn.Catenate    ${cmd}    --dst-port ${port_range_min}:${port_range_max}
605     ...    ELSE IF    '${port_range_max}'!='None'    BuiltIn.Catenate    ${cmd}    --dst-port ${port_range_max}
606     ...    ELSE IF    '${port_range_min}'!='None'    BuiltIn.Catenate    ${cmd}    --dst-port ${port_range_min}
607     ...    ELSE    BuiltIn.Catenate    ${cmd}
608     ${cmd} =    BuiltIn.Run Keyword If    '${protocol}'!='None'    BuiltIn.Catenate    ${cmd}    --protocol ${protocol}
609     ...    ELSE    BuiltIn.Catenate    ${cmd}
610     ${cmd} =    BuiltIn.Run Keyword If    '${remote_group_id}'!='None'    BuiltIn.Catenate    ${cmd}    --remote-group ${remote_group_id}
611     ...    ELSE    BuiltIn.Catenate    ${cmd}
612     ${cmd} =    BuiltIn.Run Keyword If    '${remote_ip_prefix}'!='None'    BuiltIn.Catenate    ${cmd}    --src-ip ${remote_ip_prefix}
613     ...    ELSE    BuiltIn.Catenate    ${cmd}
614     ${output} =    OpenStack CLI    ${cmd}
615     ${rule_id} =    BuiltIn.Should Match Regexp    ${output}    ${REGEX_UUID}
616     [Return]    ${output}    ${rule_id}
617
618 Neutron Security Group Rule Create Legacy Cli
619     [Arguments]    ${Security_group_name}    &{Kwargs}
620     [Documentation]    Creates neutron security rule with neutron request with or without optional params, here security group name is mandatory args, rule with optional params can be created by passing the optional args values ex: direction=${INGRESS_EGRESS}, Then these optional params are BuiltIn.Catenated with mandatory args, example of usage: "OpenStack Neutron Security Group Rule Create ${SGP_SSH} direction=${RULE_PARAMS[0]} ethertype=${RULE_PARAMS[1]} ..."
621     BuiltIn.Run Keyword If    ${Kwargs}    BuiltIn.Log    ${Kwargs}
622     ${description}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    description    default=${None}
623     ${direction}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    direction    default=${None}
624     ${ethertype}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    ethertype    default=${None}
625     ${port_range_max}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    port_range_max    default=${None}
626     ${port_range_min}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    port_range_min    default=${None}
627     ${protocol}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    protocol    default=${None}
628     ${remote_group_id}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    remote_group_id    default=${None}
629     ${remote_ip_prefix}    BuiltIn.Run Keyword If    ${Kwargs}    Collections.Pop From Dictionary    ${Kwargs}    remote_ip_prefix    default=${None}
630     ${cmd} =    BuiltIn.Set Variable    neutron security-group-rule-create ${Security_group_name}
631     ${cmd} =    BuiltIn.Run Keyword If    '${description}'!='None'    BuiltIn.Catenate    ${cmd}    --description ${description}
632     ...    ELSE    BuiltIn.Catenate    ${cmd}
633     ${cmd} =    BuiltIn.Run Keyword If    '${direction}'!='None'    BuiltIn.Catenate    ${cmd}    --direction ${direction}
634     ...    ELSE    BuiltIn.Catenate    ${cmd}
635     ${cmd} =    BuiltIn.Run Keyword If    '${ethertype}'!='None'    BuiltIn.Catenate    ${cmd}    --ethertype ${ethertype}
636     ...    ELSE    BuiltIn.Catenate    ${cmd}
637     ${cmd} =    BuiltIn.Run Keyword If    '${port_range_max}'!='None'    BuiltIn.Catenate    ${cmd}    --port_range_max ${port_range_max}
638     ...    ELSE    BuiltIn.Catenate    ${cmd}
639     ${cmd} =    BuiltIn.Run Keyword If    '${port_range_min}'!='None'    BuiltIn.Catenate    ${cmd}    --port_range_min ${port_range_min}
640     ...    ELSE    BuiltIn.Catenate    ${cmd}
641     ${cmd} =    BuiltIn.Run Keyword If    '${protocol}'!='None'    BuiltIn.Catenate    ${cmd}    --protocol ${protocol}
642     ...    ELSE    BuiltIn.Catenate    ${cmd}
643     ${cmd} =    BuiltIn.Run Keyword If    '${remote_group_id}'!='None'    BuiltIn.Catenate    ${cmd}    --remote_group_id ${remote_group_id}
644     ...    ELSE    BuiltIn.Catenate    ${cmd}
645     ${cmd} =    BuiltIn.Run Keyword If    '${remote_ip_prefix}'!='None'    BuiltIn.Catenate    ${cmd}    --remote_ip_prefix ${remote_ip_prefix}
646     ...    ELSE    BuiltIn.Catenate    ${cmd}
647     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${cmd}
648     ${rule_id} =    BuiltIn.Should Match Regexp    ${output}    ${REGEX_UUID}
649     BuiltIn.Log    ${rule_id}
650     BuiltIn.Should Be True    '${rc}' == '0'
651     [Return]    ${output}    ${rule_id}
652
653 Security Group Create Without Default Security Rules
654     [Arguments]    ${sg_name}    ${additional_args}=${EMPTY}
655     [Documentation]    Create Neutron Security Group with no default rules, using specified name and optional arguments.
656     OpenStackOperations.Neutron Security Group Create    ${sg_name}    ${additional_args}
657     Delete All Security Group Rules    ${sg_name}
658
659 Delete All Security Group Rules
660     [Arguments]    ${sg_name}
661     [Documentation]    Delete all security rules from a specified security group
662     ${sg_rules_output} =    OpenStack CLI    openstack security group rule list ${sg_name} -cID -fvalue
663     @{sg_rules} =    String.Split String    ${sg_rules_output}    \n
664     : FOR    ${rule}    IN    @{sg_rules}
665     \    ${output} =    OpenStack CLI    openstack security group rule delete ${rule}
666
667 Create Allow All SecurityGroup
668     [Arguments]    ${sg_name}    ${ether_type}=IPv4
669     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
670     OpenStackOperations.Neutron Security Group Create    ${sg_name}
671     OpenStackOperations.Neutron Security Group Rule Create    ${sg_name}    direction=ingress    ethertype=${ether_type}    port_range_max=65535    port_range_min=1    protocol=tcp
672     OpenStackOperations.Neutron Security Group Rule Create    ${sg_name}    direction=egress    ethertype=${ether_type}    port_range_max=65535    port_range_min=1    protocol=tcp
673     OpenStackOperations.Neutron Security Group Rule Create    ${sg_name}    direction=ingress    ethertype=${ether_type}    protocol=icmp
674     OpenStackOperations.Neutron Security Group Rule Create    ${sg_name}    direction=egress    ethertype=${ether_type}    protocol=icmp
675     OpenStackOperations.Neutron Security Group Rule Create    ${sg_name}    direction=ingress    ethertype=${ether_type}    port_range_max=65535    port_range_min=1    protocol=udp
676     OpenStackOperations.Neutron Security Group Rule Create    ${sg_name}    direction=egress    ethertype=${ether_type}    port_range_max=65535    port_range_min=1    protocol=udp
677
678 Create Neutron Port With Additional Params
679     [Arguments]    ${network_name}    ${port_name}    ${additional_args}=${EMPTY}
680     [Documentation]    Create Port With given additional parameters
681     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
682     BuiltIn.Log    ${output}
683     BuiltIn.Should Be True    '${rc}' == '0'
684     ${port_id} =    BuiltIn.Should Match Regexp    ${OUTPUT}    ${REGEX_UUID}
685     [Return]    ${OUTPUT}    ${port_id}
686
687 Get Ports MacAddr
688     [Arguments]    ${ports}
689     [Documentation]    Retrieve the port MacAddr for the given list of port name and return the MAC address list.
690     ${macs}    BuiltIn.Create List
691     : FOR    ${port}    IN    @{ports}
692     \    ${mac} =    OpenStackOperations.Get Port Mac    ${port}
693     \    Collections.Append To List    ${macs}    ${mac}
694     [Return]    ${macs}
695
696 Get Port Ip
697     [Arguments]    ${port_name}
698     [Documentation]    Keyword would return the IP of the ${port_name} received.
699     ${output} =    OpenStack CLI    openstack port list | grep "${port_name}" | awk -F\\' '{print $2}'
700     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
701     ${port_ip} =    Collections.Get from List    ${splitted_output}    0
702     [Return]    ${port_ip}
703
704 Get Port Mac
705     [Arguments]    ${port_name}
706     [Documentation]    Keyword would return the MAC ID of the ${port_name} received.
707     ${output} =    OpenStack CLI    openstack port show ${port_name} | grep mac_address | awk '{print $4}'
708     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
709     ${port_mac} =    Collections.Get from List    ${splitted_output}    0
710     [Return]    ${port_mac}
711
712 Create L2Gateway
713     [Arguments]    ${bridge_name}    ${intf_name}    ${gw_name}
714     [Documentation]    Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
715     ${rc}    ${l2gw_output} =    OperatingSystem.Run And Return Rc And Output    ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name}
716     BuiltIn.Log    ${l2gw_output}
717     [Return]    ${l2gw_output}
718
719 Update L2Gateway
720     [Arguments]    ${bridge_name}    ${gw_name}    ${intf_name_1}    ${intf_name_2}
721     [Documentation]    Keyword to add {intf_name_list} to an existing L2 Gateway ${gw_name} (Using Neutron CLI).
722     ${rc}    ${l2gw_output}=    Run And Return Rc And Output    ${L2GW_UPDATE} name=${bridge_name},interface_names="${intf_name_1};${intf_name_2}" ${gw_name}
723     Log    ${l2gw_output}
724     [Return]    ${l2gw_output}
725
726 Create L2Gateway Connection
727     [Arguments]    ${gw_name}    ${net_name}
728     [Documentation]    Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
729     ${rc}    ${l2gw_output} =    OperatingSystem.Run And Return Rc And Output    ${L2GW_CONN_CREATE} ${gw_name} ${net_name}
730     BuiltIn.Log    ${l2gw_output}
731     BuiltIn.Should Be True    '${rc}' == '0'
732     [Return]    ${l2gw_output}
733
734 Get All L2Gateway
735     [Documentation]    Keyword to return all the L2 Gateways available (Using Neutron CLI).
736     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${L2GW_GET_YAML}
737     BuiltIn.Should Be True    '${rc}' == '0'
738     [Return]    ${output}
739
740 Get All L2Gateway Connection
741     [Documentation]    Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
742     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${L2GW_GET_CONN_YAML}
743     BuiltIn.Should Be True    '${rc}' == '0'
744     [Return]    ${output}
745
746 Get L2Gateway
747     [Arguments]    ${gw_id}
748     [Documentation]    Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
749     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${L2GW_SHOW} ${gw_id}
750     BuiltIn.Log    ${output}
751     BuiltIn.Should Be True    '${rc}' == '0'
752     [Return]    ${output}
753
754 Get L2gw Id
755     [Arguments]    ${l2gw_name}
756     [Documentation]    Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
757     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}'
758     BuiltIn.Log    ${output}
759     BuiltIn.Should Be True    '${rc}' == '0'
760     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
761     ${l2gw_id} =    Collections.Get from List    ${splitted_output}    0
762     [Return]    ${l2gw_id}
763
764 Get L2gw Connection Id
765     [Arguments]    ${l2gw_name}
766     [Documentation]    Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
767     ${l2gw_id} =    OpenStackOperations.Get L2gw Id    ${l2gw_name}
768     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}'
769     BuiltIn.Should Be True    '${rc}' == '0'
770     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
771     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
772     ${l2gw_conn_id} =    Collections.Get from List    ${splitted_output}    0
773     [Return]    ${l2gw_conn_id}
774
775 Neutron Port List Rest
776     [Documentation]    Keyword to get all ports details in Neutron (Using REST).
777     ${resp} =    RequestsLibrary.Get Request    session    ${PORT_URL}
778     BuiltIn.Log    ${resp.content}
779     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
780     [Return]    ${resp.content}
781
782 Get Neutron Port Rest
783     [Arguments]    ${port_id}
784     [Documentation]    Keyword to get the specific port details in Neutron (Using REST).
785     ${resp} =    RequestsLibrary.Get Request    session    ${CONFIG_API}/${GET_PORT_URL}/${port_id}
786     BuiltIn.Log    ${resp.content}
787     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
788     [Return]    ${resp.content}
789
790 Update Port Rest
791     [Arguments]    ${port_id}    ${json_data}
792     [Documentation]    Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
793     BuiltIn.Log    ${json_data}
794     ${resp} =    RequestsLibrary.Put Request    session    ${CONFIG_API}/${GET_PORT_URL}/${port_id}    ${json_data}
795     BuiltIn.Log    ${resp.content}
796     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
797     [Return]    ${resp.content}
798
799 Create And Configure Security Group
800     [Arguments]    ${sg-name}
801     [Documentation]    Create Security Group with given name, and default allow rules for TCP/UDP/ICMP protocols.
802     OpenStackOperations.Neutron Security Group Create    ${sg-name}
803     OpenStackOperations.Neutron Security Group Rule Create    ${sg-name}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
804     OpenStackOperations.Neutron Security Group Rule Create    ${sg-name}    direction=egress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
805     OpenStackOperations.Neutron Security Group Rule Create    ${sg-name}    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
806     OpenStackOperations.Neutron Security Group Rule Create    ${sg-name}    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
807     OpenStackOperations.Neutron Security Group Rule Create    ${sg-name}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
808     OpenStackOperations.Neutron Security Group Rule Create    ${sg-name}    direction=egress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
809
810 Add Security Group To VM
811     [Arguments]    ${vm}    ${sg}
812     [Documentation]    Add the security group provided to the given VM.
813     ${output} =    OpenStack CLI    openstack server add security group ${vm} ${sg}
814
815 Remove Security Group From VM
816     [Arguments]    ${vm}    ${sg}
817     [Documentation]    Remove the security group provided to the given VM.
818     OpenStackOperations.Get ControlNode Connection
819     ${output} =    OpenStack CLI    openstack server remove security group ${vm} ${sg}
820
821 Create SFC Flow Classifier
822     [Arguments]    ${name}    ${src_ip}    ${dest_ip}    ${protocol}    ${dest_port}    ${neutron_src_port}
823     [Documentation]    Create a flow classifier for SFC
824     ${output} =    OpenStack CLI    openstack sfc flow classifier create --ethertype IPv4 --source-ip-prefix ${src_ip}/32 --destination-ip-prefix ${dest_ip}/32 --protocol ${protocol} --destination-port ${dest_port}:${dest_port} --logical-source-port ${neutron_src_port} ${name}
825     BuiltIn.Should Contain    ${output}    ${name}
826     [Return]    ${output}
827
828 Delete SFC Flow Classifier
829     [Arguments]    ${name}
830     [Documentation]    Delete a SFC flow classifier
831     OpenStackOperations.Get ControlNode Connection
832     ${output} =    OpenStack CLI    openstack sfc flow classifier delete ${name}
833     [Return]    ${output}
834
835 Create SFC Port Pair
836     [Arguments]    ${name}    ${port_in}    ${port_out}
837     [Documentation]    Creates a neutron port pair for SFC
838     OpenStackOperations.Get ControlNode Connection
839     ${output} =    OpenStack CLI    openstack sfc port pair create --ingress=${port_in} --egress=${port_out} ${name}
840     BuiltIn.Should Contain    ${output}    ${name}
841     [Return]    ${output}
842
843 Delete SFC Port Pair
844     [Arguments]    ${name}
845     [Documentation]    Delete a SFC port pair
846     ${output} =    OpenStack CLI    openstack sfc port pair delete ${name}
847     [Return]    ${output}
848
849 Create SFC Port Pair Group
850     [Arguments]    ${name}    ${port_pair}
851     [Documentation]    Creates a port pair group with a single port pair for SFC
852     ${output} =    OpenStack CLI    openstack sfc port pair group create --port-pair ${port_pair} ${name}
853     BuiltIn.Should Contain    ${output}    ${name}
854     [Return]    ${output}
855
856 Create SFC Port Pair Group With Two Pairs
857     [Arguments]    ${name}    ${port_pair1}    ${port_pair2}
858     [Documentation]    Creates a port pair group with two port pairs for SFC
859     ${output} =    OpenStack CLI    openstack sfc port pair group create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name}
860     BuiltIn.Should Contain    ${output}    ${name}
861     [Return]    ${output}
862
863 Delete SFC Port Pair Group
864     [Arguments]    ${name}
865     [Documentation]    Delete a SFC port pair group
866     OpenStackOperations.Get ControlNode Connection
867     ${output} =    OpenStack CLI    openstack sfc port pair group delete ${name}
868     [Return]    ${output}
869
870 Create SFC Port Chain
871     [Arguments]    ${name}    ${pg1}    ${pg2}    ${fc}
872     [Documentation]    Creates a port pair chain with two port groups and a singel classifier.
873     ${output} =    OpenStack CLI    openstack sfc port chain create --port-pair-group ${pg1} --port-pair-group ${pg2} --flow-classifier ${fc} ${name}
874     BuiltIn.Should Contain    ${output}    ${name}
875     [Return]    ${output}
876
877 Delete SFC Port Chain
878     [Arguments]    ${name}
879     [Documentation]    Delete a SFC port chain
880     ${output} =    OpenStack CLI    openstack sfc port chain delete ${name}
881     [Return]    ${output}
882
883 Reboot Nova VM
884     [Arguments]    ${vm_name}
885     [Documentation]    Reboot NOVA VM
886     ${output} =    OpenStack CLI    openstack server reboot --wait ${vm_name}
887     BuiltIn.Wait Until Keyword Succeeds    35s    10s    OpenStackOperations.Verify VM Is ACTIVE    ${vm_name}
888
889 Remove RSA Key From KnownHosts
890     [Arguments]    ${vm_ip}
891     [Documentation]    Remove RSA
892     OpenStackOperations.Get ControlNode Connection
893     ${output} =    DevstackUtils.Write Commands Until Prompt And Log    sudo cat /root/.ssh/known_hosts    30s
894     ${output} =    DevstackUtils.Write Commands Until Prompt And Log    sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ${vm_ip}    30s
895     ${output} =    DevstackUtils.Write Commands Until Prompt    sudo cat "/root/.ssh/known_hosts"    30s
896
897 Wait For Routes To Propogate
898     [Arguments]    ${networks}    ${subnets}
899     [Documentation]    Check propagated routes
900     OpenStackOperations.Get ControlNode Connection
901     : FOR    ${INDEX}    IN RANGE    0    1
902     \    ${net_id} =    OpenStackOperations.Get Net Id    @{networks}[${INDEX}]
903     \    ${is_ipv6} =    String.Get Regexp Matches    @{subnets}[${INDEX}]    ${IP6_REGEX}
904     \    ${length} =    BuiltIn.Get Length    ${is_ipv6}
905     \    ${cmd} =    BuiltIn.Set Variable If    ${length} == 0    ip route    ip -6 route
906     \    ${output} =    Utils.Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ${cmd}    ]>
907     \    BuiltIn.Should Contain    ${output}    @{subnets}[${INDEX}]
908
909 Neutron Cleanup
910     [Arguments]    ${vms}=@{EMPTY}    ${networks}=@{EMPTY}    ${subnets}=@{EMPTY}    ${ports}=@{EMPTY}    ${sgs}=@{EMPTY}
911     : FOR    ${vm}    IN    @{vms}
912     \    BuiltIn.Run Keyword And Ignore Error    Delete Vm Instance    ${vm}
913     : FOR    ${port}    IN    @{ports}
914     \    BuiltIn.Run Keyword And Ignore Error    Delete Port    ${port}
915     : FOR    ${subnet}    IN    @{subnets}
916     \    BuiltIn.Run Keyword And Ignore Error    Delete SubNet    ${subnet}
917     : FOR    ${network}    IN    @{networks}
918     \    BuiltIn.Run Keyword And Ignore Error    Delete Network    ${network}
919     : FOR    ${sg}    IN    @{sgs}
920     \    BuiltIn.Run Keyword And Ignore Error    Delete SecurityGroup    ${sg}
921
922 OpenStack List All
923     [Documentation]    Get a list of different OpenStack resources that might be in use.
924     @{modules} =    BuiltIn.Create List    server    port    network    subnet    security group
925     ...    security group rule
926     BuiltIn.Run Keyword If    "${ODL_ENABLE_L3_FWD}"=="yes"    Collections.Append To List    ${modules}    floating ip    router
927     : FOR    ${module}    IN    @{modules}
928     \    ${output} =    OpenStack CLI    openstack ${module} list
929
930 OpenStack CLI Get List
931     [Arguments]    ${cmd}
932     [Documentation]    Return a json list from the output of an OpenStack command.
933     @{list} =    BuiltIn.Create List
934     ${json} =    OpenStack CLI    ${cmd}
935     @{list} =    RequestsLibrary.To Json    ${json}
936     BuiltIn.Log    ${list}
937     [Return]    @{list}
938
939 OpenStack CLI
940     [Arguments]    ${cmd}
941     [Documentation]    Run the given OpenStack ${cmd} and log the output.
942     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${cmd}
943     BuiltIn.Log    ${output}
944     BuiltIn.Should Be True    '${rc}' == '0'
945     [Return]    ${output}
946
947 OpenStack CLI With No Log
948     [Arguments]    ${cmd}
949     [Documentation]    Run the given OpenStack ${cmd} and do not log the output.
950     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${cmd}
951     BuiltIn.Should Be True    '${rc}' == '0'
952     [Return]    ${output}
953
954 OpenStack Cleanup All
955     [Documentation]    Cleanup all Openstack resources with best effort. The keyword will query for all resources
956     ...    in use and then attempt to delete them. Errors are ignored to allow the cleanup to continue.
957     @{fips} =    BuiltIn.Run Keyword If    "${ODL_ENABLE_L3_FWD}"=="yes"    OpenStack CLI Get List    openstack floating ip list -f json
958     ...    ELSE    BuiltIn.Create List    @{EMPTY}
959     : FOR    ${fip}    IN    @{fips}
960     \    BuiltIn.Run Keyword And Ignore Error    Delete Floating IP    ${fip['ID']}
961     @{vms} =    OpenStack CLI Get List    openstack server list -f json
962     : FOR    ${vm}    IN    @{vms}
963     \    BuiltIn.Run Keyword And Ignore Error    Delete Vm Instance    ${vm['ID']}
964     @{routers} =    BuiltIn.Run Keyword If    "${ODL_ENABLE_L3_FWD}"=="yes"    OpenStack CLI Get List    openstack router list -f json
965     ...    ELSE    BuiltIn.Create List    @{EMPTY}
966     : FOR    ${router}    IN    @{routers}
967     \    BuiltIn.Run Keyword And Ignore Error    Cleanup Router    ${router['ID']}
968     @{ports} =    OpenStack CLI Get List    openstack port list -f json
969     : FOR    ${port}    IN    @{ports}
970     \    BuiltIn.Run Keyword And Ignore Error    Delete Port    ${port['ID']}
971     @{networks} =    OpenStack CLI Get List    openstack network list -f json
972     : FOR    ${network}    IN    @{networks}
973     \    BuiltIn.Run Keyword And Ignore Error    Delete Subnet    ${network['Subnets']}
974     \    BuiltIn.Run Keyword And Ignore Error    Delete Network    ${network['ID']}
975     @{security_groups} =    OpenStack CLI Get List    openstack security group list -f json
976     : FOR    ${security_group}    IN    @{security_groups}
977     \    BuiltIn.Run Keyword If    "${security_group['Name']}" != "default"    BuiltIn.Run Keyword And Ignore Error    Delete SecurityGroup    ${security_group['ID']}
978     OpenStack List All
979
980 Cleanup Router
981     [Arguments]    ${id}
982     [Documentation]    Delete a router, but first remove any interfaces or gateways so that the delete will be successful.
983     @{ports} =    OpenStack CLI Get List    openstack port list --router ${id} -f json --long
984     : FOR    ${port}    IN    @{ports}
985     \    ${subnet_id} =    OpenStackOperations.Get Match    ${port['Fixed IP Addresses']}    ${REGEX_UUID}    0
986     \    BuiltIn.Run Keyword If    "${port['Device Owner']}" == "network:router_gateway"    BuiltIn.Run Keyword And Ignore Error    Remove Gateway    ${id}
987     \    BuiltIn.Run Keyword If    "${port['Device Owner']}" == "network:router_interface"    BuiltIn.Run Keyword And Ignore Error    Remove Interface    ${id}    ${subnet_id}
988     BuiltIn.Run Keyword And Ignore Error    Delete Router    ${id}
989
990 OpenStack Suite Setup
991     [Documentation]    Wrapper teardown keyword that can be used in any suite running in an openstack environement
992     SetupUtils.Setup_Utils_For_Setup_And_Teardown
993     DevstackUtils.Devstack Suite Setup
994     @{tcpdump_port_6653_conn_ids} =    OpenStackOperations.Start Packet Capture On Nodes    tcpdump_port_6653    port 6653    @{OS_ALL_IPS}
995     BuiltIn.Set Suite Variable    @{tcpdump_port_6653_conn_ids}
996     BuiltIn.Run Keyword If    "${PRE_CLEAN_OPENSTACK_ALL}"=="True"    OpenStack Cleanup All
997     OpenStackOperations.Add OVS Logging On All OpenStack Nodes
998
999 OpenStack Suite Teardown
1000     [Documentation]    Wrapper teardown keyword that can be used in any suite running in an openstack environement
1001     ...    to clean up all openstack resources. For example, all instances, networks, ports, etc will be listed and
1002     ...    and deleted. As other global cleanup tasks are needed, they can be added here and the suites will all
1003     ...    benefit automatically.
1004     OpenStack Cleanup All
1005     OpenStackOperations.Stop Packet Capture On Nodes    ${tcpdump_port_6653_conn_ids}
1006     SSHLibrary.Close All Connections
1007
1008 Copy DHCP Files From Control Node
1009     [Documentation]    Copy the current DHCP files to the robot vm. The keyword must be called
1010     ...    after the subnet(s) are created and before the subnet(s) are deleted.
1011     ${suite_} =    BuiltIn.Evaluate    """${SUITE_NAME}""".replace(" ","_").replace("/","_").replace(".","_")
1012     ${dstdir} =    BuiltIn.Set Variable    /tmp/qdhcp/${suite_}
1013     OperatingSystem.Create Directory    ${dstdir}
1014     OpenStackOperations.Get ControlNode Connection
1015     BuiltIn.Run Keyword And Ignore Error    SSHLibrary.Get Directory    /opt/stack/data/neutron/dhcp    ${dstdir}    recursive=True
1016
1017 Is Feature Installed
1018     [Arguments]    ${features}=none
1019     : FOR    ${feature}    IN    @{features}
1020     \    ${status}    ${output}    BuiltIn.Run Keyword And Ignore Error    BuiltIn.Should Contain    ${CONTROLLERFEATURES}    ${feature}
1021     \    Return From Keyword If    "${status}" == "PASS"    True
1022     [Return]    False
1023
1024 Add OVS Logging On All OpenStack Nodes
1025     [Documentation]    Add higher levels of OVS logging to all the OpenStack nodes
1026     BuiltIn.Run Keyword If    0 < ${NUM_OS_SYSTEM}    OVSDB.Add OVS Logging    ${OS_CNTL_CONN_ID}
1027     BuiltIn.Run Keyword If    1 < ${NUM_OS_SYSTEM}    OVSDB.Add OVS Logging    ${OS_CMP1_CONN_ID}
1028     BuiltIn.Run Keyword If    2 < ${NUM_OS_SYSTEM}    OVSDB.Add OVS Logging    ${OS_CMP2_CONN_ID}
1029
1030 Reset OVS Logging On All OpenStack Nodes
1031     [Documentation]    Reset the OVS logging to all the OpenStack nodes
1032     BuiltIn.Run Keyword If    0 < ${NUM_OS_SYSTEM}    OVSDB.Reset OVS Logging    ${OS_CNTL_CONN_ID}
1033     BuiltIn.Run Keyword If    1 < ${NUM_OS_SYSTEM}    OVSDB.Reset OVS Logging    ${OS_CMP1_CONN_ID}
1034     BuiltIn.Run Keyword If    2 < ${NUM_OS_SYSTEM}    OVSDB.Reset OVS Logging    ${OS_CMP2_CONN_ID}
1035
1036 Start Packet Capture On Nodes
1037     [Arguments]    ${tag}    ${filter}    @{ips}
1038     [Documentation]    Wrapper keyword around the TcpDump packet capture that is catered to the Openstack setup.
1039     ...    The caller must pass the three arguments with a variable number of ips at the end,
1040     ...    but ${EMPTY} can be used for the tag and filter.
1041     ${suite_} =    BuiltIn.Evaluate    """${SUITE_NAME}""".replace(" ","_").replace("/","_").replace(".","_")
1042     ${tag_} =    BuiltIn.Catenate    SEPARATOR=__    ${tag}    ${suite_}
1043     @{conn_ids} =    Tcpdump.Start Packet Capture on Nodes    tag=${tag_}    filter=${filter}    ips=${ips}
1044     [Return]    @{conn_ids}
1045
1046 Stop Packet Capture On Nodes
1047     [Arguments]    ${conn_ids}=@{EMPTY}
1048     Tcpdump.Stop Packet Capture on Nodes    ${conn_ids}