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