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