2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
5 Library OperatingSystem
6 Library RequestsLibrary
9 Resource DataModels.robot
10 Resource DevstackUtils.robot
11 Resource KarafKeywords.robot
12 Resource L2GatewayOperations.robot
13 Resource ODLTools.robot
15 Resource SetupUtils.robot
16 Resource SSHKeywords.robot
17 Resource Tcpdump.robot
19 Resource ../variables/Variables.robot
20 Resource ../variables/openflowplugin/Variables.robot
21 Resource ../variables/netvirt/Variables.robot
22 Variables ../variables/netvirt/Modules.py
25 @{VALIDATION_KEYWORDS} Verify Services Verify Expected Default Tunnels Verify Expected Default Tables On Nodes
26 ${VALIDATION_FILE} /tmp/validations.txt
29 Get Tenant ID From Security Group
30 [Documentation] Returns tenant ID by reading it from existing default security-group.
31 ${output} = OpenStack CLI openstack security group show default | grep "| tenant_id" | awk '{print $4}'
34 Get Tenant ID From Network
35 [Arguments] ${network_uuid}
36 [Documentation] Returns tenant ID by reading it from existing network.
37 ${resp} = TemplatedRequests.Get_From_Uri uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/ accept=${ACCEPT_EMPTY} session=session
38 ${temp_vars} = BuiltIn.Set Variable ['network'][0]['tenant-id']
39 ${tenant_id} = Utils.Extract Value From Content ${resp} ${temp_vars}
43 [Arguments] ${network_name} ${additional_args}=${EMPTY} ${verbose}=TRUE
44 [Documentation] Create Network with openstack request.
45 ${output} = OpenStack CLI openstack network create ${network_name} ${additional_args}
48 Create Multiple Networks
49 [Arguments] @{name_of_networks}
50 [Documentation] Create required number of networks and return a list of the resulting network ids
51 ${net_list_ids} = BuiltIn.Create List @{EMPTY}
52 FOR ${net} IN @{name_of_networks}
53 ${output} = OpenStackOperations.Create Network ${net}
54 ${net_id} = Get Regexp Matches ${output} ${REGEX_UUID}
55 Collections.Append To List ${net_list_ids} ${net_id}
57 [Return] @{net_list_ids}
60 [Arguments] ${network_name} ${additional_args}=${EMPTY}
61 [Documentation] Update Network with neutron request.
62 ${output} = OpenStack CLI openstack network set ${network_name} ${additional_args}
66 [Arguments] ${network_name}
67 [Documentation] Show Network with neutron request.
68 ${output} = OpenStack CLI openstack network show ${network_name}
72 [Documentation] List networks and return output with neutron client.
73 ${output} = OpenStack CLI openstack network list
77 [Documentation] List subnets and return output with neutron client.
78 ${output} = OpenStack CLI openstack subnet list
82 [Arguments] ${network_name}
83 [Documentation] Delete Network with neutron request.
84 ${output} = OpenStack CLI openstack network delete ${network_name}
87 [Arguments] ${network_name} ${subnet_name} ${range_ip} ${additional_args}=${EMPTY}
88 [Documentation] Create SubNet for the Network with neutron request.
89 ${output} = OpenStack CLI openstack subnet create --network ${network_name} --subnet-range ${range_ip} ${subnet_name} ${additional_args}
91 Create Multiple Subnets
92 [Arguments] ${network_names} ${subnet_names} ${subnet_cidr}
93 [Documentation] Create required number of subnets for previously created networks and return subnet id
94 ${number_of_networks} = BuiltIn.Get Length ${network_names}
95 @{subnet_id_list} = BuiltIn.Create List @{EMPTY}
96 FOR ${index} IN RANGE ${number_of_networks}
97 OpenStackOperations.Create SubNet ${network_names[${index}]} ${subnet_names[${index}]} ${subnet_cidr[${index}]}
99 ${sub_list} = OpenStackOperations.List Subnets
100 FOR ${index} IN RANGE ${number_of_networks}
101 BuiltIn.Should Contain ${sub_list} ${subnet_names[${index}]}
102 ${subnet_id} = OpenStackOperations.Get Subnet Id ${subnet_names[${index}]}
103 Collections.Append To List ${subnet_id_list} ${subnet_id}
105 [Return] @{subnet_id_list}
108 [Arguments] ${subnet_name} ${additional_args}=${EMPTY}
109 [Documentation] Update subnet with openstack subnet set request.
110 ${output} = OpenStack CLI openstack subnet set ${subnet_name} ${additional_args}
114 [Arguments] ${subnet_name} ${additional_args}=${EMPTY}
115 [Documentation] Update subnet with openstack subnet unset request
116 ${output} = OpenStack CLI openstack subnet unset ${subnet_name} ${additional_args}
120 [Arguments] ${subnet_name}
121 [Documentation] Show subnet with neutron request.
122 ${output} = OpenStack CLI openstack subnet show ${subnet_name}
126 [Arguments] ${network_name} ${port_name} ${sg}=default ${additional_args}=${EMPTY} ${allowed_address_pairs}=${EMPTY}
127 [Documentation] Create Port with neutron request.
128 # if allowed_address_pairs is not empty we need to create the arguments to pass to the port create command. They are
129 # in a different format with the neutron vs openstack cli.
130 ${address_pair_length} = BuiltIn.Get Length ${allowed_address_pairs}
131 ${allowed_pairs_argv} = BuiltIn.Set Variable ${EMPTY}
132 ${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}
133 ${output} = OpenStack CLI openstack port create --network ${network_name} ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv}
136 [Arguments] ${port_name} ${additional_args}=${EMPTY}
137 [Documentation] Update port with neutron request.
138 ${output} = OpenStack CLI openstack port set ${port_name} ${additional_args}
142 [Arguments] ${port_name}
143 [Documentation] Show port with neutron request.
144 ${output} = OpenStack CLI openstack port show ${port_name}
148 [Arguments] ${port_name}
149 [Documentation] Delete Port with neutron request.
150 ${output} = OpenStack CLI openstack port delete ${port_name}
153 [Documentation] List ports and return output with neutron client.
154 ${output} = OpenStack CLI openstack port list
158 [Documentation] List VMs and return output with nova client.
159 ${output} = OpenStack CLI openstack server list --all-projects
162 Create And Associate Floating IPs
163 [Arguments] ${external_net} @{vm_list}
164 [Documentation] Create and associate floating IPs to VMs with nova request
165 ${ip_list} = BuiltIn.Create List @{EMPTY}
166 FOR ${vm} IN @{vm_list}
167 ${output} = OpenStack CLI openstack floating ip create ${external_net}
168 @{ip} = String.Get Regexp Matches ${output} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
169 ${ip_length} = BuiltIn.Get Length ${ip}
170 BuiltIn.Run Keyword If ${ip_length}>0 Collections.Append To List ${ip_list} ${ip}[0]
171 ... ELSE Collections.Append To List ${ip_list} None
172 ${vm_ip} = OpenStack CLI openstack server show ${vm} | grep "addresses" | awk '{print $4}' | cut -d"=" -f 2
173 ${port_id} = OpenStack CLI openstack port list | grep "ip_address='${vm_ip}'" | awk '{print $2}' | cut -d"=" -f 2
174 ${output} = BuiltIn.Run Keyword If '${OPENSTACK_BRANCH}' == 'stable/rocky' OpenStack CLI openstack floating ip set --port ${port_id} ${ip}[0]
175 ... ELSE OpenStack CLI openstack server add floating ip ${vm} ${ip}[0]
179 Remove Floating Ip From Vm
180 [Arguments] ${vm_name} ${fip}
181 [Documentation] Remove the Floating IP From VM Instance
182 ${vm_ip} = OpenStack CLI openstack server show ${vm_name} | grep "addresses" | awk '{print $4}' | cut -d"=" -f 2
183 ${port_id} = OpenStack CLI openstack port list | grep "ip_address='${vm_ip}'" | awk '{print $2}' | cut -d"=" -f 2
184 ${output} = BuiltIn.Run Keyword If '${OPENSTACK_BRANCH}' == 'stable/rocky' OpenStack CLI openstack floating ip unset --port ${port_id} ${fip}
185 ... ELSE OpenStack CLI openstack server remove floating ip ${vm_name} ${fip}
189 [Documentation] Delete floating ip with neutron request.
190 ${output} = OpenStack CLI openstack floating ip delete ${fip}
193 [Arguments] ${subnet}
194 [Documentation] Delete SubNet for the Network with neutron request.
195 ${output} = OpenStack CLI openstack subnet delete ${subnet}
198 [Arguments] ${vm_name}
199 [Documentation] Delete Vm instances using instance names.
200 ${output} = OpenStack CLI openstack server delete ${vm_name}
203 [Arguments] ${network_name}
204 [Documentation] Retrieve the net id for the given network name to create specific vm instance
205 ${output} = OpenStack CLI openstack network list | grep "${network_name}" | awk '{print $2}'
206 ${splitted_output} = String.Split String ${output} ${EMPTY}
207 ${net_id} = Collections.Get from List ${splitted_output} 0
211 [Arguments] ${subnet_name}
212 [Documentation] Retrieve the subnet id for the given subnet name
213 ${output} = OpenStack CLI openstack subnet show "${subnet_name}" | grep " id " | awk '{print $4}'
214 ${splitted_output} = String.Split String ${output} ${EMPTY}
215 ${subnet_id} = Collections.Get from List ${splitted_output} 0
216 [Return] ${subnet_id}
219 [Arguments] ${port_name}
220 [Documentation] Retrieve the port id for the given port name to attach specific vm instance to a particular port
221 ${output} = OpenStack CLI openstack port list | grep "${port_name}" | awk '{print $2}'
222 ${splitted_output} = String.Split String ${output} ${EMPTY}
223 ${port_id} = Collections.Get from List ${splitted_output} 0
227 [Arguments] ${portname}
228 [Documentation] Retrieve the first 10 chars of the UUID for the given port name
229 ${port_id} = OpenStackOperations.Get Port Id ${portname}
230 ${output} = String.Get Regexp Matches ${port_id} \\w{8}-\\w{2}
231 ${subport_id} = Collections.Get from List ${output} 0
232 [Return] ${subport_id}
235 [Arguments] ${router1}
236 [Documentation] Retrieve the router id for the given router name
237 ${output} = OpenStack CLI openstack router show "${router1}" |awk '/ id / {print $4}'
238 ${splitted_output} = String.Split String ${output} ${EMPTY}
239 ${router_id} = Collections.Get from List ${splitted_output} 0
240 [Return] ${router_id}
242 Get VMs OVS Port Number
243 [Arguments] ${ip_address} ${portname}
244 [Documentation] Get the port number for given portname
245 ${subportid} = OpenStackOperations.Get Sub Port Id ${portname}
246 ${vm_port_number} = OVSDB.Get Port Number ${subportid} ${ip_address}
247 [Return] ${vm_port_number}
249 Add New Image From Url
250 [Arguments] ${image_url} ${image_name}
251 [Documentation] To add new qcow2 images for testing.
252 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output wget ${image_url} -O /tmp/new_image.qcow2
253 BuiltIn.Log ${output}
254 BuiltIn.Should Be True '${rc}' == '0'
255 ${output} = OpenStack CLI openstack image create ${image_name} --file /tmp/new_image.qcow2 --disk-format qcow2 --container-format bare --public
258 [Arguments] ${flavor_name} ${ram_in_mb} ${disk_in_gb} ${ncpu}=1
259 [Documentation] To create new flavors for instance deployment and testing
260 ${output} = OpenStack CLI openstack flavor create ${flavor_name} --ram ${ram_in_mb} --disk ${disk_in_gb} --vcpus ${ncpu}
263 [Arguments] ${keyname} ${public_key_file}
264 [Documentation] To add keypairs to Openstack that can be used when ssh to instances using publickey authentication
265 ${output} = OpenStack CLI openstack keypair create ${keyname} --public-key ${public_key_file}
267 Generate And Add Keypair
268 [Arguments] ${keyname} ${keyfilename}
269 [Documentation] To generate keypair using ssh-keygen and add them to Openstack
270 ${result} = Process.Run Process ssh-keygen -b 2048 -t rsa -f ${JENKINS_WORKSPACE}/${keyfilename} -q -N "" shell=True
271 BuiltIn.Log ${result.stdout}
272 BuiltIn.Log ${result.stderr}
273 BuiltIn.Should Be True '${result.rc}' == '0'
274 OpenStackOperations.Create Keypair ${keyname} ${JENKINS_WORKSPACE}/${keyfilename}.pub
275 OpenStackOperations.Get ControlNode Connection
276 SSHLibrary.Put_File ${JENKINS_WORKSPACE}/${keyfilename} /tmp
279 [Arguments] ${net_name} ${vm_instance_names} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default ${min}=1
280 [Documentation] Create X Vm Instance with the net id of the Netowrk.
282 ${image} BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
283 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
284 FOR ${vm} IN @{vm_instance_names}
285 ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${vm} --security-group ${sg} --min ${min} --max ${max}
288 Create Vm Instance On Compute Node
289 [Arguments] ${net_name} ${vm_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
290 [Documentation] Create a VM instance on a specific compute node.
291 ${image} = BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
292 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
293 ${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}
295 Create Vm Instance With Port
296 [Arguments] ${port_name} ${vm_instance_name} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
297 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
298 ${image} = BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
299 ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --port ${port_name} --security-group ${sg} ${vm_instance_name}
301 Create Vm Instance With Ports And Key On Compute Node
302 [Arguments] ${port1_name} ${port2_name} ${vm_instance_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano
303 ... ${sg}=default ${keyname}=${EMPTY}
304 [Documentation] Create One VM instance using given ${port1_name} and ${port2_name} with keyname for ssh and also on a specific compute node
305 ${image} BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
306 ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --port ${port1_name} --port ${port2_name} ${vm_instance_name} --security-group ${sg} --availability-zone nova:${node_hostname} --key-name ${keyname}
308 Create Vm Instance With Port On Compute Node
309 [Arguments] ${port_name} ${vm_instance_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
310 [Documentation] Create One VM instance using given ${port_name} and for given ${node_hostname}
311 ${image} = BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
312 ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --port ${port_name} --security-group ${sg} --availability-zone nova:${node_hostname} ${vm_instance_name}
314 Remove Security Group From Vm Instance
315 [Arguments] ${vm_instance_name} ${security_group}
316 [Documentation] Delete the Security Group from the VM Instance.
317 ${output} = OpenStack CLI openstack server remove security group ${vm_instance_name} ${security_group}
319 Create Vm Instance With Ports On Compute Node
320 [Arguments] ${port1_name} ${port2_name} ${vm_instance_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano
322 [Documentation] Create One VM instance using given ${port1_name}, ${port2_name} and for given ${node_hostname} with no keys (cirros like)
323 ${image} = BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
324 ${port1_id} = OpenStackOperations.Get Port Id ${port1_name}
325 ${port2_id} = OpenStackOperations.Get Port Id ${port2_name}
326 ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port1_id} --nic port-id=${port2_id} --security-group ${sg} --availability-zone nova:${node_hostname} ${vm_instance_name}
328 Get Hypervisor Hostname From IP
329 [Arguments] ${hypervisor_ip}
330 [Documentation] Returns the hostname found for the given IP address if it's listed in hypervisor list. For debuggability
331 ... the full listing is logged first, then followed by a grep | cut to focus on the actual hostname to return
332 ${output} = OpenStack CLI openstack hypervisor list
333 ${hostname} = OpenStack CLI openstack hypervisor list -f value | grep "${hypervisor_ip} " | cut -d" " -f 2
337 [Documentation] Create a nano flavor
338 ${output} = OpenStack CLI openstack flavor create m1.nano --id auto --ram 64 --disk 0 --vcpus 1
341 [Arguments] ${vm_name}
342 [Documentation] Run these commands to check whether the created vm instance is active or not.
343 OpenStack CLI openstack server show ${vm_name}
344 ${output} = OpenStack CLI openstack server show ${vm_name} | grep OS-EXT-STS:vm_state
345 BuiltIn.Should Contain ${output} active
348 [Arguments] ${vm_name} ${retry}=600s ${retry_interval}=30s
349 [Documentation] Run these commands to check whether the created vm instance is active or not.
350 BuiltIn.Wait Until Keyword Succeeds ${retry} ${retry_interval} OpenStackOperations.Verify VM Is ACTIVE ${vm_name}
353 [Arguments] ${text} ${regexp} ${index}=0
354 [Documentation] Wrapper around String.Get Regexp Matches to return None if not found or the first match if found.
355 @{matches} = String.Get Regexp Matches ${text} ${regexp}
356 ${matches_length} = BuiltIn.Get Length ${matches}
357 BuiltIn.Set Suite Variable ${OS_MATCH} None
358 BuiltIn.Run Keyword If ${matches_length} > ${index} BuiltIn.Set Suite Variable ${OS_MATCH} ${matches}[${index}]
362 [Arguments] ${fail_on_none} ${vm}
363 [Documentation] Get the vm ip address and nameserver by scraping the vm's console log.
364 ... Get VM IP returns three values: [0] the vm IP, [1] the DHCP IP and [2] the vm console log.
365 ${vm_console_output} = OpenStack CLI With No Log openstack console log show ${vm}
366 ${vm_ip} = BuiltIn.Set Variable None
367 ${dhcp_ip} = BuiltIn.Set Variable None
368 ${match} = OpenStackOperations.Get Match ${vm_console_output} ${REGEX_OBTAINED}
369 ${vm_ip} = OpenStackOperations.Get Match ${match} ${REGEX_IPV4} 0
370 ${match} = OpenStackOperations.Get Match ${vm_console_output} ${REGEX_IPROUTE}
371 ${dhcp_ip} = OpenStackOperations.Get Match ${match} ${REGEX_IPV4} 1
372 BuiltIn.Run Keyword If '${fail_on_none}' == 'true' BuiltIn.Should Not Contain ${vm_ip} None
373 BuiltIn.Run Keyword If '${fail_on_none}' == 'true' BuiltIn.Should Not Contain ${dhcp_ip} None
374 [Return] ${vm_ip} ${dhcp_ip} ${vm_console_output}
376 Verify If Instance Is Arpingable From DHCP Namespace
377 [Arguments] ${net_name} ${mac} ${ip}
378 [Documentation] Get the Port IP and check the arp -a from DHCP NS to ensure that the VM's have been assigned IP's
379 OpenStackOperations.Get ControlNode Connection
380 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
381 ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} arping ${ip} -c3 ${DEFAULT_LINUX_PROMPT_STRICT} timeout=60s
382 ${mac_uppercase} = String.Convert To Upper Case ${mac}
383 BuiltIn.Should Contain ${output} [${mac_uppercase}]
385 Check If Instance Is Ready For Ssh Login Using PublicKey
386 [Arguments] ${net_name} ${vm_ip} ${user}=centos ${idfile}=/tmp/odlkey ${console}=cirros
387 [Documentation] Ensure the VM is reachable from ssh as tests would require. This keyword will use publickey authentication
388 ${output} = Execute Command on VM Instance with PublicKey Auth ${net_name} ${vm_ip} ifconfig user=${user} idfile=${idfile}
389 ... console=${console}
390 BuiltIn.Should Contain ${output} ${vm_ip}
392 Check If Instance Is Ready For Ssh Login Using Password
393 [Arguments] ${net_name} ${vm_ip} ${user}=cirros ${password}=${EMPTY} ${console}=cirros
394 [Documentation] Ensure the VM is reachable from ssh as tests would require. This keyword will use password authentication
395 ${password} BuiltIn.Set Variable If "${password}"=="${EMPTY}" ${PASSWORD_CIRROS_${OPENSTACK_BRANCH}}
396 ${output} = Execute Command on VM Instance ${net_name} ${vm_ip} ifconfig ${user} ${password}
397 ... console=${console}
398 BuiltIn.Should Contain ${output} ${vm_ip}
402 [Documentation] Get the instance IP addresses and nameserver address for the list of given vms.
403 ... First poll for the vm instance to be in the active state, then poll for the vm ip address and nameserver.
404 ... Get VM IPs returns two things: [0] a list of the ips for the vms passed to this keyword (may contain values
405 ... of None) and [1] the dhcp ip address found in the last vm checked.
406 ... TODO: there is a potential issue for a caller that passes in VMs belonging to different networks that
407 ... may have different dhcp server addresses. Not sure what TODO about that, but noting it here for reference.
408 @{vm_ips} BuiltIn.Create List @{EMPTY}
410 OpenStackOperations.Poll VM Is ACTIVE ${vm}
411 ${status} ${ips_and_console_log} BuiltIn.Run Keyword And Ignore Error BuiltIn.Wait Until Keyword Succeeds 180s 15s
412 ... OpenStackOperations.Get VM IP true ${vm}
413 # If there is trouble with Get VM IP, the status will be FAIL and the return value will be a string of what went
414 # wrong. We need to handle both the PASS and FAIL cases. In the FAIL case we know we wont have access to the
415 # console log, as it would not be returned; so we need to grab it again to log it. We also can append 'None' to
416 # the vm ip list if status is FAIL.
417 BuiltIn.Run Keyword If "${status}" == "PASS" BuiltIn.Log ${ips_and_console_log[2]}
418 BuiltIn.Run Keyword If "${status}" == "PASS" Collections.Append To List ${vm_ips} ${ips_and_console_log[0]}
419 BuiltIn.Run Keyword If "${status}" == "FAIL" Collections.Append To List ${vm_ips} None
420 ${vm_console_output} = BuiltIn.Run Keyword If "${status}" == "FAIL" OpenStack CLI openstack console log show ${vm}
421 BuiltIn.Run Keyword If "${status}" == "FAIL" BuiltIn.Log ${vm_console_output}
423 OpenStackOperations.Copy DHCP Files From Control Node
424 [Return] @{vm_ips} ${ips_and_console_log[1]}
426 Get All VM IP Addresses
427 [Arguments] ${conn_id} ${vm_name}
428 [Documentation] Show information of a given two port VM and grep for two ip address. VM name should be sent as arguments.
429 SSHLibrary.Switch Connection ${conn_id}
430 ${cmd} = BuiltIn.Set Variable openstack server show ${vm_name}
431 ${output} = OpenStackOperations.OpenStack CLI ${cmd}
432 BuiltIn.Log ${output}
433 ${address_output} = OpenStackOperations.OpenStack CLI ${cmd} | grep "addresses" | awk '{print $4$5}'
434 @{vm_ips} = String.Get Regexp Matches ${address_output} ${REGEX_IPV4}
437 Get Subnet Gateway Ip
438 [Arguments] ${subnet_name}
439 [Documentation] Show information of a subnet and grep for subnet gateway ip address
440 ${output} = OpenStackOperations.OpenStack CLI openstack subnet show ${subnet_name} | grep gateway_ip | awk '{print $4}'
441 ${splitted_output} = String.Split String ${output} ${EMPTY}
442 ${matches} = Collections.Get Matches ${splitted_output} regexp=(\\d\.)+
443 ${subnet_gateway_ip} = String.Strip String ${matches[0]} characters=','
444 [Return] ${subnet_gateway_ip}
446 Collect VM IPv6 SLAAC Addresses
447 [Arguments] ${fail_on_none} ${vm_list} ${network} ${subnet}
448 [Documentation] For each VM parse output of "openstack server show" to get its IPv6 address from Neutron DB.
449 ... Then try to connect to each VM by SSH and execute there "ip -6 a" command. This double-check allows to
450 ... obtain and compare IP info (Neutron DB vs dnsmasque/ODL DHCP) and to test L2 connectivity as well.
451 ... Returns an empty list if no IPv6 addresses found or if SSH connection fails.
452 ... Otherwise, returns a list of IPv6 addresses.
453 ${ipv6_list} = BuiltIn.Create List @{EMPTY}
454 FOR ${vm} IN @{vm_list}
455 ${output} = OpenStack CLI openstack server show ${vm} -f shell
456 ${pattern} = String.Replace String ${subnet} ::/64 (:[a-f0-9]{,4}){,4}
457 @{vm_ipv6} = String.Get Regexp Matches ${output} ${pattern}
458 ${vm_ip_length} = BuiltIn.Get Length ${vm_ipv6}[0]
459 ${ipv6_data_from_vm} = BuiltIn.Run Keyword If ${vm_ip_length}>0 OpenStackOperations.Execute Command on VM Instance ${network} ${vm_ipv6[0]}
461 @{ipv6} = String.Get Regexp Matches ${ipv6_data_from_vm} ${pattern}
462 ${ipv6_addr_list_length} BuiltIn.Get Length @{ipv6}
463 BuiltIn.Run Keyword If ${ipv6_addr_list_length}>0 Collections.Append To List ${ipv6_list} ${ipv6[0]}
464 ... ELSE Collections.Append To List ${ipv6_list} None
466 [Return] ${ipv6_list}
469 [Arguments] ${vm_instance_names}
470 [Documentation] View Console log of the created vm instances using nova show.
471 FOR ${vm} IN @{vm_instance_names}
472 ${output} = OpenStack CLI openstack server show ${vm}
473 ${output} = OpenStack CLI openstack console log show ${vm}
476 Ping Vm From DHCP Namespace
477 [Arguments] ${net_name} ${vm_ip}
478 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
479 OpenStackOperations.Get ControlNode Connection
480 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
481 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
482 BuiltIn.Should Contain ${output} 64 bytes
484 Ping From DHCP Should Not Succeed
485 [Arguments] ${net_name} ${vm_ip}
486 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
487 Return From Keyword If "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
488 OpenStackOperations.Get ControlNode Connection
489 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
490 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
491 BuiltIn.Should Not Contain ${output} 64 bytes
493 Ping Vm From Control Node
494 [Arguments] ${vm_floating_ip} ${additional_args}=${EMPTY}
495 [Documentation] Ping VM floating IP from control node
496 OpenStackOperations.Get ControlNode Connection
497 ${output} = DevstackUtils.Write Commands Until Prompt And Log ping ${additional_args} -c 3 ${vm_floating_ip} 20s
498 BuiltIn.Should Contain ${output} 64 bytes
501 [Documentation] Ping to the expected destination ip.
502 ${output} = Utils.Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
503 DevstackUtils.Write Commands Until Prompt exit
504 BuiltIn.Should Contain ${output} 200
507 [Documentation] Exit the vm instance.
508 ${output} = DevstackUtils.Write Commands Until Prompt And Log exit
510 Check If Console Is VmInstance
511 [Arguments] ${console}=cirros
512 [Documentation] Check if the session has been able to login to the VM instance
513 ${output} = Utils.Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
514 BuiltIn.Should Contain ${output} ${console}
517 [Arguments] ${console}=cirros
518 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
519 ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance ${console}
520 BuiltIn.Run Keyword If ${rcode} DevstackUtils.Write Commands Until Prompt exit
523 [Arguments] ${ip_address} ${ttl}=64 ${ping_tries}=3
524 [Documentation] Run Ping command on the IP available as argument
525 ${ethertype} = String.Get Regexp Matches ${ip_address} ${IP_REGEX}
526 ${ping} = BuiltIn.Set Variable If ${ethertype} ping ping6
527 ${cmd} = BuiltIn.Set Variable rc=0; for count in `seq 1 ${ping_tries}`; do ${ping} -W1 -t${ttl} -c5 ${ip_address}; rc=$?; if [ $rc -eq 0 ]; then break; fi; done; echo ping_rc=$rc
528 ${output} = Utils.Write Commands Until Expected Regexp ${cmd} ping_rc=\\d+ 120
529 BuiltIn.Log output: ${output}
530 BuiltIn.Should Contain ${output} 64 bytes
533 [Arguments] ${ip_address} ${ttl}=64
534 [Documentation] Run Ping command to the IP given as argument, executing 3 times and expecting NOT to see "64 bytes"
535 ${output} = Utils.Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
536 BuiltIn.Should Not Contain ${output} 64 bytes
538 Check Metadata Access
539 [Documentation] Try curl on the Metadataurl and check if it is okay
540 ${output} = Utils.Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
541 BuiltIn.Should Contain ${output} 200
543 Execute Command on VM Instance
544 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=${EMPTY} ${cmd_timeout}=30s
545 ... ${console}=cirros
546 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
547 ${password} BuiltIn.Set Variable If "${password}"=="${EMPTY}" ${PASSWORD_CIRROS_${OPENSTACK_BRANCH}}
548 OpenStackOperations.Get ControlNode Connection
549 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
550 ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${vm_ip} -o MACs=hmac-sha1 -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=password password:
551 ${output} = Utils.Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
552 ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance ${console}
553 ${output} = BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT} timeout=${cmd_timeout}
554 [Teardown] Exit From Vm Console ${console}
557 Execute Command on VM Instance With PublicKey Auth
558 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=centos ${idfile}=/tmp/odlkey ${console}=cirros
559 [Documentation] Login to the vm instance using ssh publickey in the network, executes a command inside the VM and returns the ouput.
560 OpenStackOperations.Get ControlNode Connection
561 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
562 ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh -i ${idfile} ${user}@${vm_ip} -o MACs=hmac-sha1 -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=publickey prompt=${OS_SYSTEM_PROMPT} timeout=60s
563 ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance ${console}
564 ${output} = BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
565 [Teardown] Exit From Vm Console ${console}
568 Copy File To VM Instance With PublicKey Auth
569 [Arguments] ${net_name} ${vm_ip} ${file_to_copy} ${user}=centos ${idfile}=/tmp/odlkey
570 [Documentation] Login to the vm instance using ssh publickey in the network, executes a command inside the VM and returns the ouput.
571 OpenStackOperations.Get ControlNode Connection
572 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
573 ${rc} = SSHLibrary.Execute Command sudo ip netns exec qdhcp-${net_id} scp -i ${idfile} -o MACs=hmac-sha1 -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=publickey ${file_to_copy} ${user}@${vm_ip}:/tmp/ return_stdout=False return_rc=True
574 BuiltIn.Should Be True '${rc}' == '0'
576 Test Operations From Vm Instance
577 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=${EMPTY} ${ttl}=64
578 ... ${ping_should_succeed}=True ${check_metadata}=True ${console}=cirros ${ping_tries}=3
579 [Documentation] Login to the vm instance using ssh in the network.
580 ${password} BuiltIn.Set Variable If "${password}"=="${EMPTY}" ${PASSWORD_CIRROS_${OPENSTACK_BRANCH}}
581 OpenStackOperations.Get ControlNode Connection
582 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
583 ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh -o MACs=hmac-sha1 -o ConnectTimeout=5 -o StrictHostKeyChecking=no ${user}@${src_ip} -o UserKnownHostsFile=/dev/null password: 10s
584 ${output} = Utils.Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
585 ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance ${console}
586 BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
587 BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt route -n ${OS_SYSTEM_PROMPT}
588 BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt route -A inet6 ${OS_SYSTEM_PROMPT}
589 BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
590 BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ip -f inet6 neigh show ${OS_SYSTEM_PROMPT}
591 FOR ${dest_ip} IN @{dest_ips}
592 ${string_empty} = BuiltIn.Run Keyword And Return Status Should Be Empty ${dest_ip}
593 BuiltIn.Run Keyword If ${string_empty} Continue For Loop
594 BuiltIn.Run Keyword If ${rcode} and "${ping_should_succeed}" == "True" OpenStackOperations.Check Ping ${dest_ip} ttl=${ttl} ping_tries=${ping_tries}
595 ... ELSE OpenStackOperations.Check No Ping ${dest_ip} ttl=${ttl}
597 ${ethertype} = String.Get Regexp Matches ${src_ip} ${IP_REGEX}
598 BuiltIn.Run Keyword If ${rcode} and "${check_metadata}" and ${ethertype} == "True" OpenStackOperations.Check Metadata Access
599 [Teardown] Exit From Vm Console ${console}
601 Test Netcat Operations From Vm Instance
602 [Arguments] ${net_name} ${vm_ip} ${dest_ip} ${additional_args}=${EMPTY} ${port}=12345 ${user}=cirros
603 ... ${password}=${EMPTY}
604 [Documentation] Use Netcat to test TCP/UDP connections to the controller
605 ${password} BuiltIn.Set Variable If "${password}"=="${EMPTY}" ${PASSWORD_CIRROS_${OPENSTACK_BRANCH}}
606 ${client_data} BuiltIn.Set Variable Test Client Data
607 ${server_data} BuiltIn.Set Variable Test Server Data
608 OpenStackOperations.Get ControlNode Connection
609 ${output} = DevstackUtils.Write Commands Until Prompt And Log ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
610 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo netstat -nlap | grep ${port}
611 ${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}
612 BuiltIn.Log ${output}
613 ${output} = OpenStackOperations.Execute Command on VM Instance ${net_name} ${vm_ip} sudo route -n
614 BuiltIn.Log ${output}
615 ${output} = OpenStackOperations.Execute Command on VM Instance ${net_name} ${vm_ip} sudo arp -an
616 BuiltIn.Log ${output}
617 BuiltIn.Should Match Regexp ${nc_output} ${server_data}
620 [Arguments] ${list_of_external_dst_ips} ${console}=cirros
621 [Documentation] Check reachability with other network's instances.
622 ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance ${console}
623 FOR ${dest_ip} IN @{list_of_external_dst_ips}
624 OpenStackOperations.Check Ping ${dest_ip}
628 [Arguments] ${router_name}
629 [Documentation] Create Router and Add Interface to the subnets.
630 ${output} = OpenStack CLI openstack router create ${router_name}
633 [Documentation] List Routers and return output with neutron client.
634 ${output} = OpenStack CLI openstack router list -f value
638 [Arguments] ${router_name} ${interface_name}
639 ${output} = OpenStack CLI openstack router add subnet ${router_name} ${interface_name}
641 Show Router Interface
642 [Arguments] ${router_name}
643 [Documentation] List Routers interface associated with given Router and return output with neutron client.
644 ${output} = OpenStack CLI openstack port list --router ${router_name} -f value
648 [Arguments] ${router_name} ${external_network_name} ${additional_args}=${EMPTY}
649 ${output} = OpenStack CLI openstack router set ${router_name} --external-gateway ${external_network_name} ${additional_args}
652 [Arguments] ${router_name} ${interface_name}
653 [Documentation] Remove Interface to the subnets.
654 ${output} = OpenStack CLI openstack router remove subnet ${router_name} ${interface_name}
657 [Arguments] ${router_name}
658 [Documentation] Remove external gateway from the router.
659 ${output} = OpenStack CLI openstack router unset ${router_name} --external-gateway
662 [Arguments] ${router_name} ${cmd}
663 [Documentation] Update the router with the command. Router name and command should be passed as argument.
664 ${output} = OpenStack CLI openstack router set ${router_name} ${cmd}
667 [Arguments] ${router_name} ${additional_args}=${EMPTY}
668 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
669 ${output} = OpenStack CLI openstack router show ${router_name} ${additional_args}
673 [Arguments] ${router_name}
674 [Documentation] Delete Router and Interface to the subnets.
675 ${output} = OpenStack CLI openstack router delete ${router_name}
677 Get DumpFlows And Ovsconfig
678 [Arguments] ${conn_id}
679 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
680 SSHLibrary.Switch Connection ${conn_id}
681 Utils.Write Commands Until Expected Prompt ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
682 Utils.Write Commands Until Expected Prompt ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
683 Utils.Write Commands Until Expected Prompt ip route ${DEFAULT_LINUX_PROMPT_STRICT}
684 Utils.Write Commands Until Expected Prompt arp -an ${DEFAULT_LINUX_PROMPT_STRICT}
685 ${nslist} = Utils.Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ${DEFAULT_LINUX_PROMPT_STRICT}
686 @{lines} Split To Lines ${nslist} end=-1
687 FOR ${line} IN @{lines}
688 Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
689 Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
690 Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT}
692 Utils.Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
693 Utils.Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
694 Utils.Write Commands Until Expected Prompt sudo ovs-ofctl show ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
695 Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
696 Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
697 Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
699 Get ControlNode Connection
700 SSHLibrary.Switch Connection ${OS_CNTL_CONN_ID}
701 [Return] ${OS_CNTL_CONN_ID}
704 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
705 FOR ${conn_id} IN @{OS_ALL_CONN_IDS}
706 OpenStackOperations.Get DumpFlows And Ovsconfig ${conn_id}
709 Get Test Teardown Debugs
710 [Arguments] ${test_name}=${SUITE_NAME}.${TEST_NAME} ${fail}=${FAIL_ON_EXCEPTIONS}
711 ODLTools.Get All node_ip=${HA_PROXY_IP} test_name=${test_name}
712 OpenStackOperations.Get OvsDebugInfo
713 BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${HA_PROXY_IP} ${netvirt_data_models}
714 KarafKeywords.Fail If Exceptions Found During Test ${test_name} fail=${fail}
715 FOR ${i} IN RANGE ${NUM_ODL_SYSTEM}
716 BuiltIn.Run Keyword And Ignore Error Issue_Command_On_Karaf_Console trace:transactions ${ODL_SYSTEM_${i+1}_IP}
720 Get Test Teardown Debugs test_name=${SUITE_NAME} fail=False
722 Get Test Teardown Debugs For SFC
723 [Arguments] ${test_name}=${TEST_NAME}
724 BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${HA_PROXY_IP} ${netvirt_sfc_data_models}
727 [Arguments] @{vm_indices}
728 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
729 OpenStackOperations.Get ControlNode Connection
730 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo ip netns list
731 FOR ${index} IN @{vm_indices}
732 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output nova show ${index}
733 BuiltIn.Log ${output}
735 OpenStackOperations.List Nova VMs
736 OpenStackOperations.List Routers
737 OpenStackOperations.List Networks
738 OpenStackOperations.List Subnets
739 OpenStackOperations.List Ports
740 OpenStackOperations.List Security Groups
743 [Documentation] Logging keyword to display all security groups using the openstack cli. Assumes openstack
744 ... credentials are already sourced
745 ${output} = OpenStack CLI openstack security group list
748 Neutron Security Group Show
749 [Arguments] ${SecurityGroupRuleName}
750 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
751 ${output} = OpenStack CLI openstack security group show ${SecurityGroupRuleName}
755 [Arguments] ${PortName}
756 [Documentation] Display the port configuration that belong to a given neutron port
757 ${output} = OpenStack CLI openstack port show ${PortName}
760 Neutron Security Group Create
761 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
762 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
763 OpenStackOperations.Get ControlNode Connection
764 ${output} = OpenStack CLI openstack security group create ${SecurityGroupName} ${additional_args}
765 ${sgp_id} = BuiltIn.Should Match Regexp ${output} ${REGEX_UUID}
766 [Return] ${output} ${sgp_id}
768 Neutron Security Group Update
769 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
770 [Documentation] Updating security groups
771 ${output} = OpenStack CLI openstack security group set ${SecurityGroupName} ${additional_args}
775 [Arguments] ${sg_name}
776 [Documentation] Delete Security group
777 ${output} = OpenStack CLI openstack security group delete ${sg_name}
779 Neutron Security Group Rule Create
780 [Arguments] ${Security_group_name} &{Kwargs}
781 [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]} ..."
782 BuiltIn.Run Keyword If ${Kwargs} BuiltIn.Log ${Kwargs}
783 ${description} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} description default=${None}
784 ${direction} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} direction default=${None}
785 ${ethertype} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} ethertype default=${None}
786 ${port_range_max} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} port_range_max default=${None}
787 ${port_range_min} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} port_range_min default=${None}
788 ${protocol} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} protocol default=${None}
789 ${remote_group_id} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} remote_group_id default=${None}
790 ${remote_ip_prefix} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
791 ${remote_ip} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} remote_ip default=${None}
792 ${cmd} = BuiltIn.Set Variable openstack security group rule create ${Security_group_name}
793 ${cmd} = BuiltIn.Run Keyword If '${description}'!='None' BuiltIn.Catenate ${cmd} --description ${description}
794 ... ELSE BuiltIn.Catenate ${cmd}
795 ${cmd} = BuiltIn.Run Keyword If '${direction}'!='None' BuiltIn.Catenate ${cmd} --${direction}
796 ... ELSE BuiltIn.Catenate ${cmd}
797 ${cmd} = BuiltIn.Run Keyword If '${ethertype}'!='None' BuiltIn.Catenate ${cmd} --ethertype ${ethertype}
798 ... ELSE BuiltIn.Catenate ${cmd}
799 ${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}
800 ... ELSE IF '${port_range_max}'!='None' BuiltIn.Catenate ${cmd} --dst-port ${port_range_max}
801 ... ELSE IF '${port_range_min}'!='None' BuiltIn.Catenate ${cmd} --dst-port ${port_range_min}
802 ... ELSE BuiltIn.Catenate ${cmd}
803 ${cmd} = BuiltIn.Run Keyword If '${protocol}'!='None' BuiltIn.Catenate ${cmd} --protocol ${protocol}
804 ... ELSE BuiltIn.Catenate ${cmd}
805 ${cmd} = BuiltIn.Run Keyword If '${remote_group_id}'!='None' BuiltIn.Catenate ${cmd} --remote-group ${remote_group_id}
806 ... ELSE BuiltIn.Catenate ${cmd}
807 ${cmd} = BuiltIn.Run Keyword If '${remote_ip_prefix}'!='None' BuiltIn.Catenate ${cmd} --src-ip ${remote_ip_prefix}
808 ... ELSE BuiltIn.Catenate ${cmd}
809 ${cmd} = BuiltIn.Run Keyword If '${remote_ip}'!='None' BuiltIn.Catenate ${cmd} --remote-ip ${remote_ip}
810 ... ELSE BuiltIn.Catenate ${cmd}
811 ${output} = OpenStack CLI ${cmd}
812 ${rule_id} = BuiltIn.Should Match Regexp ${output} ${REGEX_UUID}
813 [Return] ${output} ${rule_id}
815 Security Group Create Without Default Security Rules
816 [Arguments] ${sg_name} ${additional_args}=${EMPTY}
817 [Documentation] Create Neutron Security Group with no default rules, using specified name and optional arguments.
818 OpenStackOperations.Neutron Security Group Create ${sg_name} ${additional_args}
819 Delete All Security Group Rules ${sg_name}
821 Delete All Security Group Rules
822 [Arguments] ${sg_name}
823 [Documentation] Delete all security rules from a specified security group
824 ${sg_rules_output} = OpenStack CLI openstack security group rule list ${sg_name} -cID -fvalue
825 @{sg_rules} = String.Split String ${sg_rules_output} \n
826 FOR ${rule} IN @{sg_rules}
827 ${output} = OpenStack CLI openstack security group rule delete ${rule}
830 Create Allow All SecurityGroup
831 [Arguments] ${sg_name} ${ether_type}=IPv4 ${dual}=False
832 [Documentation] Allow all TCP/UDP/ICMP packets for this suite
833 OpenStackOperations.Neutron Security Group Create ${sg_name}
834 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
835 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
836 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} protocol=icmp
837 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} protocol=icmp
838 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
839 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
840 BuiltIn.Run Keyword If "${dual}"=="True" Run Keywords OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=IPv6
841 ... port_range_max=65535 port_range_min=1 protocol=tcp
842 ... AND OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=IPv6 port_range_max=65535
843 ... port_range_min=1 protocol=tcp
844 ... AND OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=IPv6 protocol=icmp
845 ... AND OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=IPv6 protocol=icmp
846 ... AND OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=IPv6 port_range_max=65535
847 ... port_range_min=1 protocol=udp
848 ... AND OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=IPv6 port_range_max=65535
849 ... port_range_min=1 protocol=udp
851 Create Neutron Port With Additional Params
852 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
853 [Documentation] Create Port With given additional parameters
854 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
855 BuiltIn.Log ${output}
856 BuiltIn.Should Be True '${rc}' == '0'
857 ${port_id} = BuiltIn.Should Match Regexp ${OUTPUT} ${REGEX_UUID}
858 [Return] ${OUTPUT} ${port_id}
862 [Documentation] Retrieve the port MacAddr for the given list of port name and return the MAC address list.
863 ${macs} BuiltIn.Create List
864 FOR ${port} IN @{ports}
865 ${mac} = OpenStackOperations.Get Port Mac ${port}
866 Collections.Append To List ${macs} ${mac}
871 [Arguments] ${port_name}
872 [Documentation] Keyword would return the IP of the ${port_name} received.
873 ${output} = OpenStack CLI openstack port list | grep "${port_name}" | awk -F\\' '{print $2}'
874 ${splitted_output} = String.Split String ${output} ${EMPTY}
875 ${port_ip} = Collections.Get from List ${splitted_output} 0
879 [Arguments] ${port_name}
880 [Documentation] Keyword would return the MAC ID of the ${port_name} received.
881 ${output} = OpenStack CLI openstack port show ${port_name} | grep mac_address | awk '{print $4}'
882 ${splitted_output} = String.Split String ${output} ${EMPTY}
883 ${port_mac} = Collections.Get from List ${splitted_output} 0
886 Get Port Mac Address From Ip
888 [Documentation] Retrieve the mac address for a port that matches any given ip.
889 ${output} = OpenStack CLI openstack port list | grep -w ${ip} | awk '{print $5}'
890 ${splitted_output} = String.Split String ${output} ${EMPTY}
891 ${mac_addr} = Collections.Get from List ${splitted_output} 0
895 [Arguments] ${bridge_name} ${intf_name} ${gw_name}
896 [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
897 ${rc} ${l2gw_output} = OperatingSystem.Run And Return Rc And Output ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name}
898 BuiltIn.Log ${l2gw_output}
899 [Return] ${l2gw_output}
902 [Arguments] ${bridge_name} ${gw_name} ${intf_name_1} ${intf_name_2}
903 [Documentation] Keyword to add {intf_name_list} to an existing L2 Gateway ${gw_name} (Using Neutron CLI).
904 ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_UPDATE} name=${bridge_name},interface_names="${intf_name_1};${intf_name_2}" ${gw_name}
906 [Return] ${l2gw_output}
908 Create L2Gateway Connection
909 [Arguments] ${gw_name} ${net_name}
910 [Documentation] Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
911 ${rc} ${l2gw_output} = OperatingSystem.Run And Return Rc And Output ${L2GW_CONN_CREATE} ${gw_name} ${net_name}
912 BuiltIn.Log ${l2gw_output}
913 BuiltIn.Should Be True '${rc}' == '0'
914 [Return] ${l2gw_output}
917 [Documentation] Keyword to return all the L2 Gateways available (Using Neutron CLI).
918 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${L2GW_GET_YAML}
919 BuiltIn.Should Be True '${rc}' == '0'
922 Get All L2Gateway Connection
923 [Documentation] Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
924 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${L2GW_GET_CONN_YAML}
925 BuiltIn.Should Be True '${rc}' == '0'
930 [Documentation] Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
931 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${L2GW_SHOW} ${gw_id}
932 BuiltIn.Log ${output}
933 BuiltIn.Should Be True '${rc}' == '0'
937 [Arguments] ${l2gw_name}
938 [Documentation] Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
939 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}'
940 BuiltIn.Log ${output}
941 BuiltIn.Should Be True '${rc}' == '0'
942 ${splitted_output} = String.Split String ${output} ${EMPTY}
943 ${l2gw_id} = Collections.Get from List ${splitted_output} 0
946 Get L2gw Connection Id
947 [Arguments] ${l2gw_name}
948 [Documentation] Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
949 ${l2gw_id} = OpenStackOperations.Get L2gw Id ${l2gw_name}
950 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}'
951 BuiltIn.Should Be True '${rc}' == '0'
952 ${splitted_output} = String.Split String ${output} ${EMPTY}
953 ${splitted_output} = String.Split String ${output} ${EMPTY}
954 ${l2gw_conn_id} = Collections.Get from List ${splitted_output} 0
955 [Return] ${l2gw_conn_id}
957 Neutron Port List Rest
958 [Documentation] Keyword to get all ports details in Neutron (Using REST).
959 ${resp} = RequestsLibrary.Get Request session ${PORT_URL}
960 BuiltIn.Log ${resp.text}
961 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
962 [Return] ${resp.text}
964 Get Neutron Port Rest
965 [Arguments] ${port_id}
966 [Documentation] Keyword to get the specific port details in Neutron (Using REST).
967 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id}
968 BuiltIn.Log ${resp.text}
969 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
970 [Return] ${resp.text}
973 [Arguments] ${port_id} ${json_data}
974 [Documentation] Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
975 BuiltIn.Log ${json_data}
976 ${resp} = RequestsLibrary.Put Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id} ${json_data}
977 BuiltIn.Log ${resp.text}
978 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
979 [Return] ${resp.text}
981 Get Neutron Network Rest
982 [Arguments] ${net_id}
983 [Documentation] Keyword to get the specific network details in Neutron (Using REST).
984 ${resp} = RequestsLibrary.Get Request session ${NETWORK_URL}/network/${net_id}
985 BuiltIn.Log ${resp.text}
986 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
987 [Return] ${resp.text}
989 Create And Configure Security Group
990 [Arguments] ${sg-name}
991 [Documentation] Create Security Group with given name, and default allow rules for TCP/UDP/ICMP protocols.
992 OpenStackOperations.Neutron Security Group Create ${sg-name}
993 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
994 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
995 OpenStackOperations.Neutron Security Group Rule Create ${sg-name} direction=ingress protocol=icmp remote_ip_prefix=0.0.0.0/0
996 OpenStackOperations.Neutron Security Group Rule Create ${sg-name} direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0
997 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
998 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
1000 Add Security Group To VM
1001 [Arguments] ${vm} ${sg}
1002 [Documentation] Add the security group provided to the given VM.
1003 ${output} = OpenStack CLI openstack server add security group ${vm} ${sg}
1005 Remove Security Group From VM
1006 [Arguments] ${vm} ${sg}
1007 [Documentation] Remove the security group provided to the given VM.
1008 OpenStackOperations.Get ControlNode Connection
1009 ${output} = OpenStack CLI openstack server remove security group ${vm} ${sg}
1011 Create SFC Flow Classifier
1012 [Arguments] ${name} ${src_ip} ${dest_ip} ${protocol} ${neutron_src_port} ${args}=${EMPTY}
1013 [Documentation] Create a flow classifier for SFC
1014 ${output} = OpenStack CLI openstack sfc flow classifier create --ethertype IPv4 --source-ip-prefix ${src_ip}/32 --destination-ip-prefix ${dest_ip}/32 --protocol ${protocol} --logical-source-port ${neutron_src_port} ${args} ${name}
1015 BuiltIn.Should Contain ${output} ${name}
1018 Delete SFC Flow Classifier
1020 [Documentation] Delete a SFC flow classifier
1021 ${output} = OpenStack CLI openstack sfc flow classifier delete ${name}
1024 Create SFC Port Pair
1025 [Arguments] ${name} ${port_in} ${port_out}
1026 [Documentation] Creates a neutron port pair for SFC
1027 ${output} = OpenStack CLI openstack sfc port pair create --ingress=${port_in} --egress=${port_out} ${name}
1028 BuiltIn.Should Contain ${output} ${name}
1031 Delete SFC Port Pair
1033 [Documentation] Delete a SFC port pair
1034 ${output} = OpenStack CLI openstack sfc port pair delete ${name}
1037 Create SFC Port Pair Group
1038 [Arguments] ${name} ${port_pair}
1039 [Documentation] Creates a port pair group with a single port pair for SFC
1040 ${output} = OpenStack CLI openstack sfc port pair group create --port-pair ${port_pair} ${name}
1041 BuiltIn.Should Contain ${output} ${name}
1044 Create SFC Port Pair Group With Two Pairs
1045 [Arguments] ${name} ${port_pair1} ${port_pair2}
1046 [Documentation] Creates a port pair group with two port pairs for SFC
1047 ${output} = OpenStack CLI openstack sfc port pair group create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name}
1048 BuiltIn.Should Contain ${output} ${name}
1051 Delete SFC Port Pair Group
1053 [Documentation] Delete a SFC port pair group
1054 OpenStackOperations.Get ControlNode Connection
1055 ${output} = OpenStack CLI openstack sfc port pair group delete ${name}
1058 Create SFC Port Chain
1059 [Arguments] ${name} ${args}=${EMPTY}
1060 [Documentation] Creates a port pair chain with two port groups and a singel classifier.
1061 ${output} = OpenStack CLI openstack sfc port chain create ${name} ${args}
1062 BuiltIn.Should Contain ${output} ${name}
1065 Update SFC Port Chain With A New Flow Classifier
1066 [Arguments] ${name} ${fc}
1067 [Documentation] Adds a Flow Classifier to a Port Chain
1068 ${output} = OpenStack CLI openstack sfc port chain set ${name} --flow-classifier ${fc}
1071 Update SFC Port Chain Removing A Flow Classifier
1072 [Arguments] ${name} ${fc}
1073 [Documentation] Adds a Flow Classifier to a Port Chain
1074 ${output} = OpenStack CLI openstack sfc port chain unset ${name} --flow-classifier ${fc}
1077 Delete SFC Port Chain
1079 [Documentation] Delete a SFC port chain
1080 ${output} = OpenStack CLI openstack sfc port chain delete ${name}
1084 [Arguments] ${vm_name}
1085 [Documentation] Reboot NOVA VM
1086 ${output} = OpenStack CLI openstack server reboot --wait ${vm_name}
1087 BuiltIn.Wait Until Keyword Succeeds 35s 10s OpenStackOperations.Verify VM Is ACTIVE ${vm_name}
1089 Remove RSA Key From KnownHosts
1090 [Arguments] ${vm_ip}
1091 [Documentation] Remove RSA
1092 OpenStackOperations.Get ControlNode Connection
1093 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo cat /root/.ssh/known_hosts 30s
1094 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ${vm_ip} 30s
1095 ${output} = DevstackUtils.Write Commands Until Prompt sudo cat "/root/.ssh/known_hosts" 30s
1097 Wait For Routes To Propogate
1098 [Arguments] ${networks} ${subnets}
1099 [Documentation] Check propagated routes
1100 OpenStackOperations.Get ControlNode Connection
1101 FOR ${INDEX} IN RANGE 0 1
1102 ${net_id} = OpenStackOperations.Get Net Id ${networks}[${INDEX}]
1103 ${is_ipv6} = String.Get Regexp Matches ${subnets}[${INDEX}] ${IP6_REGEX}
1104 ${length} = BuiltIn.Get Length ${is_ipv6}
1105 ${cmd} = BuiltIn.Set Variable If ${length} == 0 ip route ip -6 route
1106 ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ${cmd} ${DEFAULT_LINUX_PROMPT_STRICT}
1107 BuiltIn.Should Contain ${output} ${subnets}[${INDEX}]
1111 [Arguments] ${vms}=@{EMPTY} ${networks}=@{EMPTY} ${subnets}=@{EMPTY} ${ports}=@{EMPTY} ${sgs}=@{EMPTY}
1113 BuiltIn.Run Keyword And Ignore Error Delete Vm Instance ${vm}
1115 FOR ${port} IN @{ports}
1116 BuiltIn.Run Keyword And Ignore Error Delete Port ${port}
1118 FOR ${subnet} IN @{subnets}
1119 BuiltIn.Run Keyword And Ignore Error Delete SubNet ${subnet}
1121 FOR ${network} IN @{networks}
1122 BuiltIn.Run Keyword And Ignore Error Delete Network ${network}
1125 BuiltIn.Run Keyword And Ignore Error Delete SecurityGroup ${sg}
1129 [Documentation] Get a list of different OpenStack resources that might be in use.
1130 @{modules} = BuiltIn.Create List server port network subnet security group
1131 ... security group rule floating ip router
1132 FOR ${module} IN @{modules}
1133 ${output} = OpenStack CLI openstack ${module} list
1136 OpenStack CLI Get List
1138 [Documentation] Return a json list from the output of an OpenStack command.
1139 @{list} = BuiltIn.Create List
1140 ${json} = OpenStack CLI ${cmd}
1141 @{list} = RequestsLibrary.To Json ${json}
1147 [Documentation] Run the given OpenStack ${cmd} and log the output.
1148 ${result} = Process.Run Process ${cmd} shell=True
1149 BuiltIn.Log ${result.stdout}
1150 BuiltIn.Log ${result.stderr}
1151 BuiltIn.Should Be True '${result.rc}' == '0'
1152 [Return] ${result.stdout}
1154 OpenStack CLI With No Log
1156 [Documentation] Run the given OpenStack ${cmd} and do not log the output.
1157 ${result} = Process.Run Process ${cmd} shell=True
1158 BuiltIn.Should Be True '${result.rc}' == '0'
1159 [Return] ${result.stdout}
1161 OpenStack Cleanup All
1162 [Documentation] Cleanup all Openstack resources with best effort. The keyword will query for all resources
1163 ... in use and then attempt to delete them. Errors are ignored to allow the cleanup to continue.
1164 @{fips} = OpenStack CLI Get List openstack floating ip list -f json
1165 FOR ${fip} IN @{fips}
1166 BuiltIn.Run Keyword And Ignore Error Delete Floating IP ${fip['ID']}
1168 @{vms} = OpenStack CLI Get List openstack server list -f json
1170 OpenStack CLI openstack server show ${vm['ID']}
1171 BuiltIn.Run Keyword And Ignore Error Delete Vm Instance ${vm['ID']}
1173 @{routers} = OpenStack CLI Get List openstack router list -f json
1174 FOR ${router} IN @{routers}
1175 BuiltIn.Run Keyword And Ignore Error Cleanup Router ${router['ID']}
1177 @{ports} = OpenStack CLI Get List openstack port list -f json
1178 FOR ${port} IN @{ports}
1179 BuiltIn.Run Keyword And Ignore Error Delete Port ${port['ID']}
1181 @{networks} = OpenStack CLI Get List openstack network list -f json
1182 FOR ${network} IN @{networks}
1183 BuiltIn.Run Keyword And Ignore Error Delete Subnet ${network['Subnets']}
1184 BuiltIn.Run Keyword And Ignore Error Delete Network ${network['ID']}
1186 @{security_groups} = OpenStack CLI Get List openstack security group list -f json
1187 FOR ${security_group} IN @{security_groups}
1188 BuiltIn.Run Keyword If "${security_group['Name']}" != "default" BuiltIn.Run Keyword And Ignore Error Delete SecurityGroup ${security_group['ID']}
1194 [Documentation] Delete a router, but first remove any interfaces or gateways so that the delete will be successful.
1195 @{ports} = OpenStack CLI Get List openstack port list --router ${id} -f json --long
1196 FOR ${port} IN @{ports}
1197 ${subnet_id} = OpenStackOperations.Get Match ${port['Fixed IP Addresses']} ${REGEX_UUID} 0
1198 BuiltIn.Run Keyword If "${port['Device Owner']}" == "network:router_gateway" BuiltIn.Run Keyword And Ignore Error Remove Gateway ${id}
1199 BuiltIn.Run Keyword If "${port['Device Owner']}" == "network:router_interface" BuiltIn.Run Keyword And Ignore Error Remove Interface ${id} ${subnet_id}
1201 BuiltIn.Run Keyword And Ignore Error Delete Router ${id}
1203 OpenStack Suite Setup
1204 [Documentation] Wrapper teardown keyword that can be used in any suite running in an openstack environement
1205 SetupUtils.Setup_Utils_For_Setup_And_Teardown
1206 @{loggers} = BuiltIn.Create List org.apache.karaf.shell.support.ShellUtil org.apache.sshd.server.session.ServerSessionImpl
1207 Setuputils.Setup_Logging_For_Debug_Purposes_On_List_Or_All OFF ${loggers}
1208 DevstackUtils.Devstack Suite Setup
1209 @{tcpdump_port_6653_conn_ids} = OpenStackOperations.Start Packet Capture On Nodes tcpdump_port_6653 port 6653 @{OS_ALL_IPS}
1210 BuiltIn.Set Suite Variable @{tcpdump_port_6653_conn_ids}
1211 BuiltIn.Run Keyword If "${PRE_CLEAN_OPENSTACK_ALL}"=="True" OpenStack Cleanup All
1212 OpenStackOperations.Add OVS Logging On All OpenStack Nodes
1215 OpenStack Suite Teardown
1216 [Documentation] Wrapper teardown keyword that can be used in any suite running in an openstack environement
1217 ... to clean up all openstack resources. For example, all instances, networks, ports, etc will be listed and
1218 ... and deleted. As other global cleanup tasks are needed, they can be added here and the suites will all
1219 ... benefit automatically.
1220 # TODO: followup patch will add the list of vms to pass to Show Debugs
1221 # OpenStackOperations.Show Debugs @{NET_1_VMS} @{NET_2_VMS}
1222 OpenStackOperations.Get Suite Debugs
1223 OpenStack Cleanup All
1224 OpenStackOperations.Stop Packet Capture On Nodes ${tcpdump_port_6653_conn_ids}
1225 SSHLibrary.Close All Connections
1226 FOR ${i} IN RANGE ${NUM_ODL_SYSTEM}
1227 KarafKeywords.Issue Command On Karaf Console threads --list | wc -l ${ODL_SYSTEM_${i+1}_IP}
1231 [Documentation] Validate the deployment. Examples to validate are verifying default table
1232 ... flows are installed and that the tunnel mesh has been built correctly.
1233 Write To Validate File ----------------------------------------\n${SUITE_NAME}\n
1234 FOR ${keyword} IN @{VALIDATION_KEYWORDS}
1235 ${status} = Builtin.Run Keyword And Return Status ${keyword}
1236 BuiltIn.Run Keyword If "${status}" == "FAIL" or "${status}" == "False" BuiltIn.Run Keywords Write To Validate File Failed: ${keyword}
1237 ... AND BuiltIn.Fail
1238 ... ELSE Write To Validate File Passed: ${keyword}
1241 Write To Validate File
1243 [Documentation] Write the given ${msg} to ${VALIDATION_FILE}. Create the file if not present.
1244 ${status} = BuiltIn.Run Keyword And Return Status OperatingSystem.File Should Exist ${VALIDATION_FILE}
1245 BuiltIn.Run Keyword If "${status}" == "False" OperatingSystem.Create File ${VALIDATION_FILE}
1246 OperatingSystem.Append To File ${VALIDATION_FILE} ${msg}\n
1248 Copy DHCP Files From Control Node
1249 [Documentation] Copy the current DHCP files to the robot vm. The keyword must be called
1250 ... after the subnet(s) are created and before the subnet(s) are deleted.
1251 ${suite_} = BuiltIn.Evaluate """${SUITE_NAME}""".replace(" ","_").replace("/","_").replace(".","_")
1252 ${dstdir} = BuiltIn.Set Variable /tmp/qdhcp/${suite_}
1253 OperatingSystem.Create Directory ${dstdir}
1254 OpenStackOperations.Get ControlNode Connection
1255 BuiltIn.Run Keyword And Ignore Error SSHLibrary.Get Directory /opt/stack/data/neutron/dhcp ${dstdir} recursive=True
1257 Is Feature Installed
1258 [Arguments] ${features}=none
1259 FOR ${feature} IN @{features}
1260 ${status} ${output} BuiltIn.Run Keyword And Ignore Error BuiltIn.Should Contain ${CONTROLLERFEATURES} ${feature}
1261 Return From Keyword If "${status}" == "PASS" True
1265 Add OVS Logging On All OpenStack Nodes
1266 [Documentation] Add higher levels of OVS logging to all the OpenStack nodes
1267 FOR ${conn_id} IN @{OS_ALL_CONN_IDS}
1268 OVSDB.Add OVS Logging ${conn_id}
1271 Reset OVS Logging On All OpenStack Nodes
1272 [Documentation] Reset the OVS logging to all the OpenStack nodes
1273 FOR ${conn_id} IN @{OS_ALL_CONN_IDS}
1274 OVSDB.Reset OVS Logging ${conn_id}
1277 Start Packet Capture On Nodes
1278 [Arguments] ${tag} ${filter} @{ips}
1279 [Documentation] Wrapper keyword around the TcpDump packet capture that is catered to the Openstack setup.
1280 ... The caller must pass the three arguments with a variable number of ips at the end,
1281 ... but ${EMPTY} can be used for the tag and filter.
1282 ${suite_} = BuiltIn.Evaluate """${SUITE_NAME}""".replace(" ","_").replace("/","_").replace(".","_")
1283 ${tag_} = BuiltIn.Catenate SEPARATOR=__ ${tag} ${suite_}
1284 @{conn_ids} = Tcpdump.Start Packet Capture on Nodes tag=${tag_} filter=${filter} ips=${ips}
1285 [Return] @{conn_ids}
1287 Stop Packet Capture On Nodes
1288 [Arguments] ${conn_ids}=@{EMPTY}
1289 Tcpdump.Stop Packet Capture on Nodes ${conn_ids}
1292 [Arguments] ${vm_instance_name}
1293 [Documentation] Keyword for live migration of VM instance
1294 ... additional_agrs is to select particular migration(live/shared-migration/block-migration)
1295 ... if the additional_agrs is not given default migration(shared-migration) will happen
1296 ${output} = OpenStackOperations.OpenStack CLI nova live-migration ${vm_instance_name}
1298 Get Hypervisor Host Of Vm
1299 [Arguments] ${vm_name}
1300 [Documentation] Show server with neutron request.
1301 ${output} = OpenStackOperations.OpenStack CLI openstack server show -f value -c OS-EXT-SRV-ATTR:host ${vm_name}
1304 Check If Migration Is Complete
1305 [Arguments] ${vm_name}
1306 [Documentation] Show server and verify if task_state is not migrating
1307 ${output} = OpenStackOperations.OpenStack CLI openstack server show ${vm_name} | grep "OS-EXT-STS:task_state"
1308 BuiltIn.Should Not Contain ${output} migrating
1310 Modify OpenStack Configuration File
1311 [Arguments] ${conn_id} ${file_name} ${section} ${key} ${value}
1312 [Documentation] Use crudini to modify any parameter in any Openstack configuration File
1313 SSHLibrary.Switch Connection ${conn_id}
1314 ${output} ${rc} = SSHLibrary.Execute Command sudo crudini --verbose --set --inplace ${file_name} ${section} ${key} ${value} return_rc=True return_stdout=True
1315 BuiltIn.Log ${output}
1316 BuiltIn.Should Be True '${rc}' == '0'
1318 Restart DevStack Service
1319 [Arguments] ${conn_id} ${service_name}
1320 [Documentation] Restart the Openstack Service
1321 SSHLibrary.Switch Connection ${conn_id}
1322 ${output} ${rc} = SSHLibrary.Execute Command sudo systemctl restart devstack@${service_name}.service return_rc=True return_stdout=True
1323 BuiltIn.Log ${output}
1324 BuiltIn.Should Be True '${rc}' == '0'
1326 Get Network Segmentation Id
1327 [Arguments] ${network_name}
1328 [Documentation] Returns network segmentation id for the given network name.
1329 ${output} = OpenStack CLI openstack network show ${network_name} | grep segmentation_id | awk '{print $4}'
1330 @{list} = String.Split String ${output}
1334 [Documentation] Verify if the services are operational
1335 Wait Until Keyword Succeeds 60 2 ClusterManagement.Check Status Of Services Is OPERATIONAL @{NETVIRT_DIAG_SERVICES}
1337 Verify Expected Default Tunnels
1338 [Documentation] Verify if the default tunnels are created.
1339 ... SFC jobs currently fail this validation because it uses of-tunnels.
1340 ... This validation will be blocked for NEtvirt SFC jobs until support for of-tunnels
1341 ... added to odltools.
1342 ${check_feature_list} = BuiltIn.Create List odl-netvirt-sfc
1343 ${is_sfc_enabled} = OpenStackOperations.Is Feature Installed features=${check_feature_list}
1344 BuiltIn.Return From Keyword If ${is_sfc_enabled} == ${True} ${True}
1345 BuiltIn.Return From Keyword If ${OS_NODE_CNT} == ${1} ${True}
1346 ${output} = ODLTools.Analyze Tunnels test_name=${SUITE_NAME}.Suite Setup
1347 BuiltIn.Should Contain ${output} All tunnels are up
1349 Verify Expected Default Tables On Nodes
1350 [Arguments] ${node_ips}=@{OS_ALL_IPS}
1351 [Documentation] Verify if Default Table Entries are programmed on all Nodes
1352 ${resp} = RequestsLibrary.Get Request session ${RFC8040_CONFIG_NODES_API}
1353 Utils.Log Content ${resp.text}
1354 ${failed_node_list} = BuiltIn.Create List
1355 FOR ${node_ip} IN @{node_ips}
1356 ${failed_table_list} = Verify Expected Default Tables ${node_ip}
1357 ${failed_table_list_size} = BuiltIn.Get Length ${failed_table_list}
1358 BuiltIn.Run Keyword If ${failed_table_list_size} > 0 Collections.Append To List ${failed_node_list} ${node_ip}
1360 Builtin.Should Be Empty ${failed_node_list}
1362 Verify Expected Default Tables
1363 [Arguments] ${ovs_ip}
1364 [Documentation] Verify if Default Table Entries are programmed on specific Node
1365 ${flow_dump} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -OOpenFlow13
1366 BuiltIn.Log ${flow_dump}
1367 ${failed_table_list} = BuiltIn.Create List
1368 FOR ${table} IN @{DEFAULT_FLOW_TABLES}
1369 ${rc} = Builtin.Run Keyword And Return Status Builtin.Should Not Match Regexp ${flow_dump} .*table=${table}.*priority=0
1370 BuiltIn.Run Keyword If ${rc} Collections.Append To List ${failed_table_list} ${table}
1372 [Return] ${failed_table_list}
1375 [Arguments] ${project_name}
1376 [Documentation] Returns project ID for the given project name.
1377 ${project_id} = OpenStack CLI openstack project show ${project_name} -f value -c id
1378 [Return] ${project_id}
1380 Set Instance Quota For Project
1381 [Arguments] ${num_instances} ${project_id}
1382 [Documentation] Set quota for the created instances using the specific project id.
1383 ${output} = OpenStack CLI openstack quota set --instances ${num_instances} ${project_id}
1387 [Arguments] ${vpnname} ${additional_args}=${EMPTY}
1388 [Documentation] Create Bgpvpn with neutron request.
1389 ${output} = OpenStack CLI openstack bgpvpn create --name ${vpnname} ${additional_args}
1392 [Arguments] ${vpnName}
1393 [Documentation] Retrieve the bgpvpn id for the given bgpvpn name
1394 ${output} = OpenStack CLI openstack bgpvpn show ${vpnName} | grep " ID" | awk '{print $4}'
1395 ${splitted_output} = String.Split String ${output} ${EMPTY}
1396 ${vpn_id} = Collections.Get from List ${splitted_output} 0
1399 Configure_IP_On_Sub_Interface
1400 [Arguments] ${network_name} ${ip} ${vm_ip} ${mask} ${sub_interface_state}=${EMPTY} ${interface}=eth0
1401 ... ${sub_interface_number}=1
1402 [Documentation] Keyword for configuring specified IP on specified interface and the corresponding specified sub interface
1403 OpenStackOperations.Execute Command on VM Instance ${network_name} ${vm_ip} sudo ifconfig ${interface}:${sub_interface_number} ${ip} netmask ${mask} ${sub_interface_state}
1405 Verify_IP_Configured_On_Sub_Interface
1406 [Arguments] ${network_name} ${ip} ${vm_ip} ${interface}=eth0 ${sub_interface_number}=1
1407 [Documentation] Keyword for verifying specified IP on specified interface and the corresponding specified sub interface
1408 ${resp} = OpenStackOperations.Execute Command on VM Instance ${network_name} ${vm_ip} sudo ifconfig ${interface}:${sub_interface_number}
1409 BuiltIn.Should Contain ${resp} ${ip}