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/netvirt/Variables.robot
21 Variables ../variables/netvirt/Modules.py
24 Get Tenant ID From Security Group
25 [Documentation] Returns tenant ID by reading it from existing default security-group.
26 ${output} = OpenStack CLI openstack security group show default | grep "| tenant_id" | awk '{print $4}'
29 Get Tenant ID From Network
30 [Arguments] ${network_uuid}
31 [Documentation] Returns tenant ID by reading it from existing network.
32 ${resp} = TemplatedRequests.Get_From_Uri uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/ accept=${ACCEPT_EMPTY} session=session
33 ${tenant_id} = Utils.Extract Value From Content ${resp} /network/0/tenant-id strip
37 [Arguments] ${network_name} ${additional_args}=${EMPTY} ${verbose}=TRUE
38 [Documentation] Create Network with openstack request.
39 ${output} = OpenStack CLI openstack network create ${network_name} ${additional_args}
43 [Arguments] ${network_name} ${additional_args}=${EMPTY}
44 [Documentation] Update Network with neutron request.
45 ${output} = OpenStack CLI openstack network set ${network_name} ${additional_args}
49 [Arguments] ${network_name}
50 [Documentation] Show Network with neutron request.
51 ${output} = OpenStack CLI openstack network show ${network_name}
55 [Documentation] List networks and return output with neutron client.
56 ${output} = OpenStack CLI openstack network list
60 [Documentation] List subnets and return output with neutron client.
61 ${output} = OpenStack CLI openstack subnet list
65 [Arguments] ${network_name}
66 [Documentation] Delete Network with neutron request.
67 ${output} = OpenStack CLI openstack network delete ${network_name}
70 [Arguments] ${network_name} ${subnet_name} ${range_ip} ${additional_args}=${EMPTY}
71 [Documentation] Create SubNet for the Network with neutron request.
72 ${output} = OpenStack CLI openstack subnet create --network ${network_name} --subnet-range ${range_ip} ${subnet_name} ${additional_args}
75 [Arguments] ${subnet_name} ${additional_args}=${EMPTY}
76 [Documentation] Update subnet with openstack subnet set request.
77 ${output} = OpenStack CLI openstack subnet set ${subnet_name} ${additional_args}
81 [Arguments] ${subnet_name} ${additional_args}=${EMPTY}
82 [Documentation] Update subnet with openstack subnet unset request
83 ${output} = OpenStack CLI openstack subnet unset ${subnet_name} ${additional_args}
87 [Arguments] ${subnet_name}
88 [Documentation] Show subnet with neutron request.
89 ${output} = OpenStack CLI openstack subnet show ${subnet_name}
93 [Arguments] ${network_name} ${port_name} ${sg}=default ${additional_args}=${EMPTY} ${allowed_address_pairs}=${EMPTY}
94 [Documentation] Create Port with neutron request.
95 # if allowed_address_pairs is not empty we need to create the arguments to pass to the port create command. They are
96 # in a different format with the neutron vs openstack cli.
97 ${address_pair_length} = BuiltIn.Get Length ${allowed_address_pairs}
98 ${allowed_pairs_argv} = BuiltIn.Set Variable ${EMPTY}
99 ${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}
100 ${output} = OpenStack CLI openstack port create --network ${network_name} ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv}
103 [Arguments] ${port_name} ${additional_args}=${EMPTY}
104 [Documentation] Update port with neutron request.
105 ${output} = OpenStack CLI openstack port set ${port_name} ${additional_args}
109 [Arguments] ${port_name}
110 [Documentation] Show port with neutron request.
111 ${output} = OpenStack CLI openstack port show ${port_name}
115 [Arguments] ${port_name}
116 [Documentation] Delete Port with neutron request.
117 ${output} = OpenStack CLI openstack port delete ${port_name}
120 [Documentation] List ports and return output with neutron client.
121 ${output} = OpenStack CLI openstack port list
125 [Documentation] List VMs and return output with nova client.
126 ${output} = OpenStack CLI openstack server list --all-projects
129 Create And Associate Floating IPs
130 [Arguments] ${external_net} @{vm_list}
131 [Documentation] Create and associate floating IPs to VMs with nova request
132 ${ip_list} = BuiltIn.Create List @{EMPTY}
133 : FOR ${vm} IN @{vm_list}
134 \ ${output} = OpenStack CLI openstack floating ip create ${external_net}
135 \ @{ip} = String.Get Regexp Matches ${output} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
136 \ ${ip_length} = BuiltIn.Get Length ${ip}
137 \ BuiltIn.Run Keyword If ${ip_length}>0 Collections.Append To List ${ip_list} @{ip}[0]
138 \ ... ELSE Collections.Append To List ${ip_list} None
139 \ ${output} = OpenStack CLI openstack server add floating ip ${vm} @{ip}[0]
142 Remove Floating Ip From Vm
143 [Arguments] ${vm_name} ${fip}
144 [Documentation] Remove the Floating IP From VM Instance
145 ${output} = OpenStack CLI openstack server remove floating ip ${vm_name} ${fip}
149 [Documentation] Delete floating ip with neutron request.
150 ${output} = OpenStack CLI openstack floating ip delete ${fip}
153 [Arguments] ${subnet}
154 [Documentation] Delete SubNet for the Network with neutron request.
155 ${output} = OpenStack CLI openstack subnet delete ${subnet}
158 [Arguments] ${vm_name}
159 [Documentation] Delete Vm instances using instance names.
160 ${output} = OpenStack CLI openstack server delete ${vm_name}
163 [Arguments] ${network_name}
164 [Documentation] Retrieve the net id for the given network name to create specific vm instance
165 ${output} = OpenStack CLI openstack network list | grep "${network_name}" | awk '{print $2}'
166 ${splitted_output} = String.Split String ${output} ${EMPTY}
167 ${net_id} = Collections.Get from List ${splitted_output} 0
171 [Arguments] ${subnet_name}
172 [Documentation] Retrieve the subnet id for the given subnet name
173 ${output} = OpenStack CLI openstack subnet show "${subnet_name}" | grep " id " | awk '{print $4}'
174 ${splitted_output} = String.Split String ${output} ${EMPTY}
175 ${subnet_id} = Collections.Get from List ${splitted_output} 0
176 [Return] ${subnet_id}
179 [Arguments] ${port_name}
180 [Documentation] Retrieve the port id for the given port name to attach specific vm instance to a particular port
181 ${output} = OpenStack CLI openstack port list | grep "${port_name}" | awk '{print $2}'
182 ${splitted_output} = String.Split String ${output} ${EMPTY}
183 ${port_id} = Collections.Get from List ${splitted_output} 0
187 [Arguments] ${portname}
188 [Documentation] Retrieve the first 10 chars of the UUID for the given port name
189 ${port_id} = OpenStackOperations.Get Port Id ${portname}
190 ${output} = String.Get Regexp Matches ${port_id} \\w{8}-\\w{2}
191 ${subport_id} = Collections.Get from List ${output} 0
192 [Return] ${subport_id}
195 [Arguments] ${router1}
196 [Documentation] Retrieve the router id for the given router name
197 ${output} = OpenStack CLI openstack router show "${router1}" |awk '/ id / {print $4}'
198 ${splitted_output} = String.Split String ${output} ${EMPTY}
199 ${router_id} = Collections.Get from List ${splitted_output} 0
200 [Return] ${router_id}
202 Add New Image From Url
203 [Arguments] ${image_url} ${image_name}
204 [Documentation] To add new qcow2 images for testing.
205 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output wget ${image_url} -O /tmp/new_image.qcow2
206 BuiltIn.Log ${output}
207 BuiltIn.Should Be True '${rc}' == '0'
208 ${output} = OpenStack CLI openstack image create ${image_name} --file /tmp/new_image.qcow2 --disk-format qcow2 --container-format bare --public
211 [Arguments] ${flavor_name} ${ram_in_mb} ${disk_in_gb} ${ncpu}=1
212 [Documentation] To create new flavors for instance deployment and testing
213 ${output} = OpenStack CLI openstack flavor create ${flavor_name} --ram ${ram_in_mb} --disk ${disk_in_gb} --vcpus ${ncpu}
216 [Arguments] ${keyname} ${public_key_file}
217 [Documentation] To add keypairs to Openstack that can be used when ssh to instances using publickey authentication
218 ${output} = OpenStack CLI openstack keypair create ${keyname} --public-key ${public_key_file}
220 Generate And Add Keypair
221 [Arguments] ${keyname} ${keyfilename}
222 [Documentation] To generate keypair using ssh-keygen and add them to Openstack
223 ${result} = Process.Run Process ssh-keygen -b 2048 -t rsa -f ${JENKINS_WORKSPACE}/${keyfilename} -q -N "" shell=True
224 BuiltIn.Log ${result.stdout}
225 BuiltIn.Log ${result.stderr}
226 BuiltIn.Should Be True '${result.rc}' == '0'
227 OpenStackOperations.Create Keypair ${keyname} ${JENKINS_WORKSPACE}/${keyfilename}.pub
228 OpenStackOperations.Get ControlNode Connection
229 SSHLibrary.Put_File ${JENKINS_WORKSPACE}/${keyfilename} /tmp
232 [Arguments] ${net_name} ${vm_instance_names} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default ${min}=1
233 [Documentation] Create X Vm Instance with the net id of the Netowrk.
235 ${image} BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
236 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
237 : FOR ${vm} IN @{vm_instance_names}
238 \ ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${vm} --security-group ${sg} --min ${min} --max ${max}
240 Create Vm Instance On Compute Node
241 [Arguments] ${net_name} ${vm_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
242 [Documentation] Create a VM instance on a specific compute node.
243 ${image} = BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
244 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
245 ${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}
247 Create Vm Instance With Port
248 [Arguments] ${port_name} ${vm_instance_name} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
249 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
250 ${image} = BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
251 ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --port ${port_name} --security-group ${sg} ${vm_instance_name}
253 Create Vm Instance With Ports And Key On Compute Node
254 [Arguments] ${port1_name} ${port2_name} ${vm_instance_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano
255 ... ${sg}=default ${keyname}=${EMPTY}
256 [Documentation] Create One VM instance using given ${port1_name} and ${port2_name} with keyname for ssh and also on a specific compute node
257 ${image} BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
258 ${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}
260 Create Vm Instance With Port On Compute Node
261 [Arguments] ${port_name} ${vm_instance_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
262 [Documentation] Create One VM instance using given ${port_name} and for given ${node_hostname}
263 ${image} = BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
264 ${output} = OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --port ${port_name} --security-group ${sg} --availability-zone nova:${node_hostname} ${vm_instance_name}
266 Remove Security Group From Vm Instance
267 [Arguments] ${vm_instance_name} ${security_group}
268 [Documentation] Delete the Security Group from the VM Instance.
269 ${output} = OpenStack CLI openstack server remove security group ${vm_instance_name} ${security_group}
271 Create Vm Instance With Ports On Compute Node
272 [Arguments] ${port1_name} ${port2_name} ${vm_instance_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano
274 [Documentation] Create One VM instance using given ${port1_name}, ${port2_name} and for given ${node_hostname} with no keys (cirros like)
275 ${image} = BuiltIn.Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
276 ${port1_id} = OpenStackOperations.Get Port Id ${port1_name}
277 ${port2_id} = OpenStackOperations.Get Port Id ${port2_name}
278 ${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}
280 Get Hypervisor Hostname From IP
281 [Arguments] ${hypervisor_ip}
282 [Documentation] Returns the hostname found for the given IP address if it's listed in hypervisor list. For debuggability
283 ... the full listing is logged first, then followed by a grep | cut to focus on the actual hostname to return
284 ${output} = OpenStack CLI openstack hypervisor list
285 ${hostname} = OpenStack CLI openstack hypervisor list -f value | grep "${hypervisor_ip} " | cut -d" " -f 2
289 [Documentation] Create a nano flavor
290 ${output} = OpenStack CLI openstack flavor create m1.nano --id auto --ram 64 --disk 0 --vcpus 1
293 [Arguments] ${vm_name}
294 [Documentation] Run these commands to check whether the created vm instance is active or not.
295 ${output} = OpenStack CLI openstack server show ${vm_name} | grep OS-EXT-STS:vm_state
296 BuiltIn.Should Contain ${output} active
299 [Arguments] ${vm_name} ${retry}=600s ${retry_interval}=30s
300 [Documentation] Run these commands to check whether the created vm instance is active or not.
301 BuiltIn.Wait Until Keyword Succeeds ${retry} ${retry_interval} OpenStackOperations.Verify VM Is ACTIVE ${vm_name}
304 [Arguments] ${text} ${regexp} ${index}=0
305 [Documentation] Wrapper around String.Get Regexp Matches to return None if not found or the first match if found.
306 @{matches} = String.Get Regexp Matches ${text} ${regexp}
307 ${matches_length} = BuiltIn.Get Length ${matches}
308 BuiltIn.Set Suite Variable ${OS_MATCH} None
309 BuiltIn.Run Keyword If ${matches_length} > ${index} BuiltIn.Set Suite Variable ${OS_MATCH} @{matches}[${index}]
313 [Arguments] ${fail_on_none} ${vm}
314 [Documentation] Get the vm ip address and nameserver by scraping the vm's console log.
315 ... Get VM IP returns three values: [0] the vm IP, [1] the DHCP IP and [2] the vm console log.
316 ${vm_console_output} = OpenStack CLI With No Log openstack console log show ${vm}
317 ${vm_ip} = BuiltIn.Set Variable None
318 ${dhcp_ip} = BuiltIn.Set Variable None
319 ${match} = OpenStackOperations.Get Match ${vm_console_output} ${REGEX_OBTAINED}
320 ${vm_ip} = OpenStackOperations.Get Match ${match} ${REGEX_IPV4} 0
321 ${match} = OpenStackOperations.Get Match ${vm_console_output} ${REGEX_IPROUTE}
322 ${dhcp_ip} = OpenStackOperations.Get Match ${match} ${REGEX_IPV4} 1
323 BuiltIn.Run Keyword If '${fail_on_none}' == 'true' BuiltIn.Should Not Contain ${vm_ip} None
324 BuiltIn.Run Keyword If '${fail_on_none}' == 'true' BuiltIn.Should Not Contain ${dhcp_ip} None
325 [Return] ${vm_ip} ${dhcp_ip} ${vm_console_output}
327 Verify If Instance Is Arpingable From DHCP Namespace
328 [Arguments] ${net_name} ${mac} ${ip}
329 [Documentation] Get the Port IP and check the arp -a from DHCP NS to ensure that the VM's have been assigned IP's
330 OpenStackOperations.Get ControlNode Connection
331 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
332 ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} arping ${ip} -c3 ${DEFAULT_LINUX_PROMPT_STRICT} timeout=60s
333 ${mac_uppercase} = String.Convert To Upper Case ${mac}
334 BuiltIn.Should Contain ${output} [${mac_uppercase}]
336 Check If Instance Is Ready For Ssh Login Using PublicKey
337 [Arguments] ${net_name} ${vm_ip} ${user}=centos ${idfile}=/tmp/odlkey ${console}=cirros
338 [Documentation] Ensure the VM is reachable from ssh as tests would require. This keyword will use publickey authentication
339 ${output} = Execute Command on VM Instance with PublicKey Auth ${net_name} ${vm_ip} ifconfig user=${user} idfile=${idfile}
340 ... console=${console}
341 BuiltIn.Should Contain ${output} ${vm_ip}
343 Check If Instance Is Ready For Ssh Login Using Password
344 [Arguments] ${net_name} ${vm_ip} ${user}=cirros ${console}=cirros
345 [Documentation] Ensure the VM is reachable from ssh as tests would require. This keyword will use password authentication
346 ${output} = Execute Command on VM Instance ${net_name} ${vm_ip} ifconfig console=${console}
347 BuiltIn.Should Contain ${output} ${vm_ip}
351 [Documentation] Get the instance IP addresses and nameserver address for the list of given vms.
352 ... First poll for the vm instance to be in the active state, then poll for the vm ip address and nameserver.
353 ... Get VM IPs returns two things: [0] a list of the ips for the vms passed to this keyword (may contain values
354 ... of None) and [1] the dhcp ip address found in the last vm checked.
355 ... TODO: there is a potential issue for a caller that passes in VMs belonging to different networks that
356 ... may have different dhcp server addresses. Not sure what TODO about that, but noting it here for reference.
357 @{vm_ips} BuiltIn.Create List @{EMPTY}
358 : FOR ${vm} IN @{vms}
359 \ OpenStackOperations.Poll VM Is ACTIVE ${vm}
360 \ ${status} ${ips_and_console_log} BuiltIn.Run Keyword And Ignore Error BuiltIn.Wait Until Keyword Succeeds 180s 15s
361 \ ... OpenStackOperations.Get VM IP true ${vm}
362 \ # If there is trouble with Get VM IP, the status will be FAIL and the return value will be a string of what went
363 \ # wrong. We need to handle both the PASS and FAIL cases. In the FAIL case we know we wont have access to the
364 \ # console log, as it would not be returned; so we need to grab it again to log it. We also can append 'None' to
365 \ # the vm ip list if status is FAIL.
366 \ BuiltIn.Run Keyword If "${status}" == "PASS" BuiltIn.Log ${ips_and_console_log[2]}
367 \ BuiltIn.Run Keyword If "${status}" == "PASS" Collections.Append To List ${vm_ips} ${ips_and_console_log[0]}
368 \ BuiltIn.Run Keyword If "${status}" == "FAIL" Collections.Append To List ${vm_ips} None
369 \ ${vm_console_output} = BuiltIn.Run Keyword If "${status}" == "FAIL" OpenStack CLI openstack console log show ${vm}
370 \ BuiltIn.Run Keyword If "${status}" == "FAIL" BuiltIn.Log ${vm_console_output}
371 OpenStackOperations.Copy DHCP Files From Control Node
372 [Return] @{vm_ips} ${ips_and_console_log[1]}
374 Get Subnet Gateway Ip
375 [Arguments] ${subnet_name}
376 [Documentation] Show information of a subnet and grep for subnet gateway ip address
377 ${output} = OpenStackOperations.OpenStack CLI openstack subnet show ${subnet_name} | grep gateway_ip | awk '{print $4}'
378 ${splitted_output} = String.Split String ${output} ${EMPTY}
379 ${matches} = Collections.Get Matches ${splitted_output} regexp=(\\d\.)+
380 ${subnet_gateway_ip} = String.Strip String ${matches[0]} characters=','
381 [Return] ${subnet_gateway_ip}
383 Collect VM IPv6 SLAAC Addresses
384 [Arguments] ${fail_on_none} ${vm_list} ${network} ${subnet}
385 [Documentation] For each VM parse output of "openstack server show" to get its IPv6 address from Neutron DB.
386 ... Then try to connect to each VM by SSH and execute there "ip -6 a" command. This double-check allows to
387 ... obtain and compare IP info (Neutron DB vs dnsmasque/ODL DHCP) and to test L2 connectivity as well.
388 ... Returns an empty list if no IPv6 addresses found or if SSH connection fails.
389 ... Otherwise, returns a list of IPv6 addresses.
390 ${ipv6_list} = BuiltIn.Create List @{EMPTY}
391 : FOR ${vm} IN @{vm_list}
392 \ ${output} = OpenStack CLI openstack server show ${vm} -f shell
393 \ ${pattern} = String.Replace String ${subnet} ::/64 (:[a-f0-9]{,4}){,4}
394 \ @{vm_ipv6} = String.Get Regexp Matches ${output} ${pattern}
395 \ ${vm_ip_length} = BuiltIn.Get Length ${vm_ipv6}[0]
396 \ ${ipv6_data_from_vm} = BuiltIn.Run Keyword If ${vm_ip_length}>0 OpenStackOperations.Execute Command on VM Instance ${network} ${vm_ipv6[0]}
398 \ @{ipv6} = String.Get Regexp Matches ${ipv6_data_from_vm} ${pattern}
399 \ ${ipv6_addr_list_length} BuiltIn.Get Length @{ipv6}
400 \ BuiltIn.Run Keyword If ${ipv6_addr_list_length}>0 Collections.Append To List ${ipv6_list} ${ipv6[0]}
401 \ ... ELSE Collections.Append To List ${ipv6_list} None
402 [Return] ${ipv6_list}
405 [Arguments] ${vm_instance_names}
406 [Documentation] View Console log of the created vm instances using nova show.
407 : FOR ${vm} IN @{vm_instance_names}
408 \ ${output} = OpenStack CLI openstack server show ${vm}
409 \ ${output} = OpenStack CLI openstack console log show ${vm}
411 Ping Vm From DHCP Namespace
412 [Arguments] ${net_name} ${vm_ip}
413 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
414 OpenStackOperations.Get ControlNode Connection
415 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
416 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
417 BuiltIn.Should Contain ${output} 64 bytes
419 Ping From DHCP Should Not Succeed
420 [Arguments] ${net_name} ${vm_ip}
421 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
422 Return From Keyword If "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
423 OpenStackOperations.Get ControlNode Connection
424 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
425 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
426 BuiltIn.Should Not Contain ${output} 64 bytes
428 Ping Vm From Control Node
429 [Arguments] ${vm_floating_ip} ${additional_args}=${EMPTY}
430 [Documentation] Ping VM floating IP from control node
431 OpenStackOperations.Get ControlNode Connection
432 ${output} = DevstackUtils.Write Commands Until Prompt And Log ping ${additional_args} -c 3 ${vm_floating_ip} 20s
433 BuiltIn.Should Contain ${output} 64 bytes
436 [Documentation] Ping to the expected destination ip.
437 ${output} = Utils.Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
438 DevstackUtils.Write Commands Until Prompt exit
439 BuiltIn.Should Contain ${output} 200
442 [Documentation] Exit the vm instance.
443 ${output} = DevstackUtils.Write Commands Until Prompt And Log exit
445 Check If Console Is VmInstance
446 [Arguments] ${console}=cirros
447 [Documentation] Check if the session has been able to login to the VM instance
448 ${output} = Utils.Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
449 BuiltIn.Should Contain ${output} ${console}
452 [Arguments] ${console}=cirros
453 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
454 ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance ${console}
455 BuiltIn.Run Keyword If ${rcode} DevstackUtils.Write Commands Until Prompt exit
458 [Arguments] ${ip_address} ${ttl}=64
459 [Documentation] Run Ping command on the IP available as argument
460 ${ethertype} = String.Get Regexp Matches ${ip_address} ${IP_REGEX}
461 ${output} = BuiltIn.Run Keyword If ${ethertype} Utils.Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
462 ... ELSE Utils.Write Commands Until Expected Prompt ping6 -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
463 BuiltIn.Should Contain ${output} 64 bytes
466 [Arguments] ${ip_address} ${ttl}=64
467 [Documentation] Run Ping command to the IP given as argument, executing 3 times and expecting NOT to see "64 bytes"
468 ${output} = Utils.Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
469 BuiltIn.Should Not Contain ${output} 64 bytes
471 Check Metadata Access
472 [Documentation] Try curl on the Metadataurl and check if it is okay
473 ${output} = Utils.Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
474 BuiltIn.Should Contain ${output} 200
476 Execute Command on VM Instance
477 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:) ${cmd_timeout}=30s
478 ... ${console}=cirros
479 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
480 OpenStackOperations.Get ControlNode Connection
481 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
482 ${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:
483 ${output} = Utils.Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
484 ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance ${console}
485 ${output} = BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT} timeout=${cmd_timeout}
486 [Teardown] Exit From Vm Console ${console}
489 Execute Command on VM Instance With PublicKey Auth
490 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=centos ${idfile}=/tmp/odlkey ${console}=cirros
491 [Documentation] Login to the vm instance using ssh publickey in the network, executes a command inside the VM and returns the ouput.
492 OpenStackOperations.Get ControlNode Connection
493 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
494 ${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
495 ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance ${console}
496 ${output} = BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
497 [Teardown] Exit From Vm Console ${console}
500 Copy File To VM Instance With PublicKey Auth
501 [Arguments] ${net_name} ${vm_ip} ${file_to_copy} ${user}=centos ${idfile}=/tmp/odlkey
502 [Documentation] Login to the vm instance using ssh publickey in the network, executes a command inside the VM and returns the ouput.
503 OpenStackOperations.Get ControlNode Connection
504 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
505 ${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
506 BuiltIn.Should Be True '${rc}' == '0'
508 Test Operations From Vm Instance
509 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:) ${ttl}=64
510 ... ${ping_should_succeed}=True ${check_metadata}=True ${console}=cirros
511 [Documentation] Login to the vm instance using ssh in the network.
512 OpenStackOperations.Get ControlNode Connection
513 ${net_id} = OpenStackOperations.Get Net Id ${net_name}
514 ${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
515 ${output} = Utils.Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
516 ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance ${console}
517 BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
518 BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt route -n ${OS_SYSTEM_PROMPT}
519 BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt route -A inet6 ${OS_SYSTEM_PROMPT}
520 BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
521 BuiltIn.Run Keyword If ${rcode} Utils.Write Commands Until Expected Prompt ip -f inet6 neigh show ${OS_SYSTEM_PROMPT}
522 : FOR ${dest_ip} IN @{dest_ips}
523 \ ${string_empty} = BuiltIn.Run Keyword And Return Status Should Be Empty ${dest_ip}
524 \ BuiltIn.Run Keyword If ${string_empty} Continue For Loop
525 \ BuiltIn.Run Keyword If ${rcode} and "${ping_should_succeed}" == "True" OpenStackOperations.Check Ping ${dest_ip} ttl=${ttl}
526 \ ... ELSE OpenStackOperations.Check No Ping ${dest_ip} ttl=${ttl}
527 ${ethertype} = String.Get Regexp Matches ${src_ip} ${IP_REGEX}
528 BuiltIn.Run Keyword If ${rcode} and "${check_metadata}" and ${ethertype} == "True" OpenStackOperations.Check Metadata Access
529 [Teardown] Exit From Vm Console ${console}
531 Test Netcat Operations From Vm Instance
532 [Arguments] ${net_name} ${vm_ip} ${dest_ip} ${additional_args}=${EMPTY} ${port}=12345 ${user}=cirros
533 ... ${password}=cubswin:)
534 [Documentation] Use Netcat to test TCP/UDP connections to the controller
535 ${client_data} BuiltIn.Set Variable Test Client Data
536 ${server_data} BuiltIn.Set Variable Test Server Data
537 OpenStackOperations.Get ControlNode Connection
538 ${output} = DevstackUtils.Write Commands Until Prompt And Log ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
539 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo netstat -nlap | grep ${port}
540 ${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}
541 BuiltIn.Log ${output}
542 ${output} = OpenStackOperations.Execute Command on VM Instance ${net_name} ${vm_ip} sudo route -n
543 BuiltIn.Log ${output}
544 ${output} = OpenStackOperations.Execute Command on VM Instance ${net_name} ${vm_ip} sudo arp -an
545 BuiltIn.Log ${output}
546 BuiltIn.Should Match Regexp ${nc_output} ${server_data}
549 [Arguments] ${list_of_external_dst_ips} ${console}=cirros
550 [Documentation] Check reachability with other network's instances.
551 ${rcode} = BuiltIn.Run Keyword And Return Status OpenStackOperations.Check If Console Is VmInstance ${console}
552 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
553 \ OpenStackOperations.Check Ping ${dest_ip}
556 [Arguments] ${router_name}
557 [Documentation] Create Router and Add Interface to the subnets.
558 ${output} = OpenStack CLI openstack router create ${router_name}
561 [Documentation] List Routers and return output with neutron client.
562 ${output} = OpenStack CLI openstack router list -f value
566 [Arguments] ${router_name} ${interface_name}
567 ${output} = OpenStack CLI openstack router add subnet ${router_name} ${interface_name}
569 Show Router Interface
570 [Arguments] ${router_name}
571 [Documentation] List Routers interface associated with given Router and return output with neutron client.
572 ${output} = OpenStack CLI openstack port list --router ${router_name} -f value
576 [Arguments] ${router_name} ${external_network_name} ${additional_args}=${EMPTY}
577 ${output} = OpenStack CLI openstack router set ${router_name} --external-gateway ${external_network_name} ${additional_args}
580 [Arguments] ${router_name} ${interface_name}
581 [Documentation] Remove Interface to the subnets.
582 ${output} = OpenStack CLI openstack router remove subnet ${router_name} ${interface_name}
585 [Arguments] ${router_name}
586 [Documentation] Remove external gateway from the router.
587 ${output} = OpenStack CLI openstack router unset ${router_name} --external-gateway
590 [Arguments] ${router_name} ${cmd}
591 [Documentation] Update the router with the command. Router name and command should be passed as argument.
592 ${output} = OpenStack CLI openstack router set ${router_name} ${cmd}
595 [Arguments] ${router_name} ${additional_args}=${EMPTY}
596 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
597 ${output} = OpenStack CLI openstack router show ${router_name} ${additional_args}
601 [Arguments] ${router_name}
602 [Documentation] Delete Router and Interface to the subnets.
603 ${output} = OpenStack CLI openstack router delete ${router_name}
605 Get DumpFlows And Ovsconfig
606 [Arguments] ${conn_id}
607 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
608 SSHLibrary.Switch Connection ${conn_id}
609 Utils.Write Commands Until Expected Prompt ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
610 Utils.Write Commands Until Expected Prompt ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
611 Utils.Write Commands Until Expected Prompt ip route ${DEFAULT_LINUX_PROMPT_STRICT}
612 Utils.Write Commands Until Expected Prompt arp -an ${DEFAULT_LINUX_PROMPT_STRICT}
613 ${nslist} = Utils.Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ${DEFAULT_LINUX_PROMPT_STRICT}
614 @{lines} Split To Lines ${nslist} end=-1
615 : FOR ${line} IN @{lines}
616 \ Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
617 \ Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
618 \ Utils.Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT}
619 Utils.Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
620 Utils.Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
621 Utils.Write Commands Until Expected Prompt sudo ovs-ofctl show ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
622 Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
623 Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
624 Utils.Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats ${INTEGRATION_BRIDGE} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
626 Get ControlNode Connection
627 SSHLibrary.Switch Connection ${OS_CNTL_CONN_ID}
628 [Return] ${OS_CNTL_CONN_ID}
631 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
632 : FOR ${conn_id} IN @{OS_ALL_CONN_IDS}
633 \ OpenStackOperations.Get DumpFlows And Ovsconfig ${conn_id}
635 Get Test Teardown Debugs
636 [Arguments] ${test_name}=${SUITE_NAME}.${TEST_NAME} ${fail}=${FAIL_ON_EXCEPTIONS}
637 ODLTools.Get All node_ip=${HA_PROXY_IP} test_name=${test_name}
638 OpenStackOperations.Get OvsDebugInfo
639 BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${HA_PROXY_IP} ${netvirt_data_models}
640 KarafKeywords.Fail If Exceptions Found During Test ${test_name} fail=${fail}
643 Get Test Teardown Debugs test_name=${SUITE_NAME} fail=False
645 Get Test Teardown Debugs For SFC
646 [Arguments] ${test_name}=${TEST_NAME}
647 BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${HA_PROXY_IP} ${netvirt_sfc_data_models}
650 [Arguments] @{vm_indices}
651 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
652 OpenStackOperations.Get ControlNode Connection
653 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo ip netns list
654 : FOR ${index} IN @{vm_indices}
655 \ ${rc} ${output} = OperatingSystem.Run And Return Rc And Output nova show ${index}
656 \ BuiltIn.Log ${output}
657 OpenStackOperations.List Nova VMs
658 OpenStackOperations.List Routers
659 OpenStackOperations.List Networks
660 OpenStackOperations.List Subnets
661 OpenStackOperations.List Ports
662 OpenStackOperations.List Security Groups
665 [Documentation] Logging keyword to display all security groups using the openstack cli. Assumes openstack
666 ... credentials are already sourced
667 ${output} = OpenStack CLI openstack security group list
670 Neutron Security Group Show
671 [Arguments] ${SecurityGroupRuleName}
672 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
673 ${output} = OpenStack CLI openstack security group show ${SecurityGroupRuleName}
677 [Arguments] ${PortName}
678 [Documentation] Display the port configuration that belong to a given neutron port
679 ${output} = OpenStack CLI openstack port show ${PortName}
682 Neutron Security Group Create
683 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
684 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
685 OpenStackOperations.Get ControlNode Connection
686 ${output} = OpenStack CLI openstack security group create ${SecurityGroupName} ${additional_args}
687 ${sgp_id} = BuiltIn.Should Match Regexp ${output} ${REGEX_UUID}
688 [Return] ${output} ${sgp_id}
690 Neutron Security Group Update
691 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
692 [Documentation] Updating security groups
693 ${output} = OpenStack CLI openstack security group set ${SecurityGroupName} ${additional_args}
697 [Arguments] ${sg_name}
698 [Documentation] Delete Security group
699 ${output} = OpenStack CLI openstack security group delete ${sg_name}
701 Neutron Security Group Rule Create
702 [Arguments] ${Security_group_name} &{Kwargs}
703 [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]} ..."
704 BuiltIn.Run Keyword If ${Kwargs} BuiltIn.Log ${Kwargs}
705 ${description} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} description default=${None}
706 ${direction} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} direction default=${None}
707 ${ethertype} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} ethertype default=${None}
708 ${port_range_max} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} port_range_max default=${None}
709 ${port_range_min} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} port_range_min default=${None}
710 ${protocol} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} protocol default=${None}
711 ${remote_group_id} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} remote_group_id default=${None}
712 ${remote_ip_prefix} BuiltIn.Run Keyword If ${Kwargs} Collections.Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
713 ${cmd} = BuiltIn.Set Variable openstack security group rule create ${Security_group_name}
714 ${cmd} = BuiltIn.Run Keyword If '${description}'!='None' BuiltIn.Catenate ${cmd} --description ${description}
715 ... ELSE BuiltIn.Catenate ${cmd}
716 ${cmd} = BuiltIn.Run Keyword If '${direction}'!='None' BuiltIn.Catenate ${cmd} --${direction}
717 ... ELSE BuiltIn.Catenate ${cmd}
718 ${cmd} = BuiltIn.Run Keyword If '${ethertype}'!='None' BuiltIn.Catenate ${cmd} --ethertype ${ethertype}
719 ... ELSE BuiltIn.Catenate ${cmd}
720 ${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}
721 ... ELSE IF '${port_range_max}'!='None' BuiltIn.Catenate ${cmd} --dst-port ${port_range_max}
722 ... ELSE IF '${port_range_min}'!='None' BuiltIn.Catenate ${cmd} --dst-port ${port_range_min}
723 ... ELSE BuiltIn.Catenate ${cmd}
724 ${cmd} = BuiltIn.Run Keyword If '${protocol}'!='None' BuiltIn.Catenate ${cmd} --protocol ${protocol}
725 ... ELSE BuiltIn.Catenate ${cmd}
726 ${cmd} = BuiltIn.Run Keyword If '${remote_group_id}'!='None' BuiltIn.Catenate ${cmd} --remote-group ${remote_group_id}
727 ... ELSE BuiltIn.Catenate ${cmd}
728 ${cmd} = BuiltIn.Run Keyword If '${remote_ip_prefix}'!='None' BuiltIn.Catenate ${cmd} --src-ip ${remote_ip_prefix}
729 ... ELSE BuiltIn.Catenate ${cmd}
730 ${output} = OpenStack CLI ${cmd}
731 ${rule_id} = BuiltIn.Should Match Regexp ${output} ${REGEX_UUID}
732 [Return] ${output} ${rule_id}
734 Security Group Create Without Default Security Rules
735 [Arguments] ${sg_name} ${additional_args}=${EMPTY}
736 [Documentation] Create Neutron Security Group with no default rules, using specified name and optional arguments.
737 OpenStackOperations.Neutron Security Group Create ${sg_name} ${additional_args}
738 Delete All Security Group Rules ${sg_name}
740 Delete All Security Group Rules
741 [Arguments] ${sg_name}
742 [Documentation] Delete all security rules from a specified security group
743 ${sg_rules_output} = OpenStack CLI openstack security group rule list ${sg_name} -cID -fvalue
744 @{sg_rules} = String.Split String ${sg_rules_output} \n
745 : FOR ${rule} IN @{sg_rules}
746 \ ${output} = OpenStack CLI openstack security group rule delete ${rule}
748 Create Allow All SecurityGroup
749 [Arguments] ${sg_name} ${ether_type}=IPv4 ${dual}=False
750 [Documentation] Allow all TCP/UDP/ICMP packets for this suite
751 OpenStackOperations.Neutron Security Group Create ${sg_name}
752 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
753 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
754 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} protocol=icmp
755 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} protocol=icmp
756 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
757 OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
758 BuiltIn.Run Keyword If "${dual}"=="True" Run Keywords OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=IPv6
759 ... port_range_max=65535 port_range_min=1 protocol=tcp
760 ... AND OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=IPv6 port_range_max=65535
761 ... port_range_min=1 protocol=tcp
762 ... AND OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=IPv6 protocol=icmp
763 ... AND OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=IPv6 protocol=icmp
764 ... AND OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=IPv6 port_range_max=65535
765 ... port_range_min=1 protocol=udp
766 ... AND OpenStackOperations.Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=IPv6 port_range_max=65535
767 ... port_range_min=1 protocol=udp
769 Create Neutron Port With Additional Params
770 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
771 [Documentation] Create Port With given additional parameters
772 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
773 BuiltIn.Log ${output}
774 BuiltIn.Should Be True '${rc}' == '0'
775 ${port_id} = BuiltIn.Should Match Regexp ${OUTPUT} ${REGEX_UUID}
776 [Return] ${OUTPUT} ${port_id}
780 [Documentation] Retrieve the port MacAddr for the given list of port name and return the MAC address list.
781 ${macs} BuiltIn.Create List
782 : FOR ${port} IN @{ports}
783 \ ${mac} = OpenStackOperations.Get Port Mac ${port}
784 \ Collections.Append To List ${macs} ${mac}
788 [Arguments] ${port_name}
789 [Documentation] Keyword would return the IP of the ${port_name} received.
790 ${output} = OpenStack CLI openstack port list | grep "${port_name}" | awk -F\\' '{print $2}'
791 ${splitted_output} = String.Split String ${output} ${EMPTY}
792 ${port_ip} = Collections.Get from List ${splitted_output} 0
796 [Arguments] ${port_name}
797 [Documentation] Keyword would return the MAC ID of the ${port_name} received.
798 ${output} = OpenStack CLI openstack port show ${port_name} | grep mac_address | awk '{print $4}'
799 ${splitted_output} = String.Split String ${output} ${EMPTY}
800 ${port_mac} = Collections.Get from List ${splitted_output} 0
803 Get Port Mac Address From Ip
805 [Documentation] Retrieve the mac address for a port that matches any given ip.
806 ${output} = OpenStack CLI openstack port list | grep -w ${ip} | awk '{print $5}'
807 ${splitted_output} = String.Split String ${output} ${EMPTY}
808 ${mac_addr} = Collections.Get from List ${splitted_output} 0
812 [Arguments] ${bridge_name} ${intf_name} ${gw_name}
813 [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
814 ${rc} ${l2gw_output} = OperatingSystem.Run And Return Rc And Output ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name}
815 BuiltIn.Log ${l2gw_output}
816 [Return] ${l2gw_output}
819 [Arguments] ${bridge_name} ${gw_name} ${intf_name_1} ${intf_name_2}
820 [Documentation] Keyword to add {intf_name_list} to an existing L2 Gateway ${gw_name} (Using Neutron CLI).
821 ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_UPDATE} name=${bridge_name},interface_names="${intf_name_1};${intf_name_2}" ${gw_name}
823 [Return] ${l2gw_output}
825 Create L2Gateway Connection
826 [Arguments] ${gw_name} ${net_name}
827 [Documentation] Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
828 ${rc} ${l2gw_output} = OperatingSystem.Run And Return Rc And Output ${L2GW_CONN_CREATE} ${gw_name} ${net_name}
829 BuiltIn.Log ${l2gw_output}
830 BuiltIn.Should Be True '${rc}' == '0'
831 [Return] ${l2gw_output}
834 [Documentation] Keyword to return all the L2 Gateways available (Using Neutron CLI).
835 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${L2GW_GET_YAML}
836 BuiltIn.Should Be True '${rc}' == '0'
839 Get All L2Gateway Connection
840 [Documentation] Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
841 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${L2GW_GET_CONN_YAML}
842 BuiltIn.Should Be True '${rc}' == '0'
847 [Documentation] Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
848 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${L2GW_SHOW} ${gw_id}
849 BuiltIn.Log ${output}
850 BuiltIn.Should Be True '${rc}' == '0'
854 [Arguments] ${l2gw_name}
855 [Documentation] Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
856 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}'
857 BuiltIn.Log ${output}
858 BuiltIn.Should Be True '${rc}' == '0'
859 ${splitted_output} = String.Split String ${output} ${EMPTY}
860 ${l2gw_id} = Collections.Get from List ${splitted_output} 0
863 Get L2gw Connection Id
864 [Arguments] ${l2gw_name}
865 [Documentation] Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
866 ${l2gw_id} = OpenStackOperations.Get L2gw Id ${l2gw_name}
867 ${rc} ${output} = OperatingSystem.Run And Return Rc And Output ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}'
868 BuiltIn.Should Be True '${rc}' == '0'
869 ${splitted_output} = String.Split String ${output} ${EMPTY}
870 ${splitted_output} = String.Split String ${output} ${EMPTY}
871 ${l2gw_conn_id} = Collections.Get from List ${splitted_output} 0
872 [Return] ${l2gw_conn_id}
874 Neutron Port List Rest
875 [Documentation] Keyword to get all ports details in Neutron (Using REST).
876 ${resp} = RequestsLibrary.Get Request session ${PORT_URL}
877 BuiltIn.Log ${resp.content}
878 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
879 [Return] ${resp.content}
881 Get Neutron Port Rest
882 [Arguments] ${port_id}
883 [Documentation] Keyword to get the specific port details in Neutron (Using REST).
884 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id}
885 BuiltIn.Log ${resp.content}
886 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
887 [Return] ${resp.content}
890 [Arguments] ${port_id} ${json_data}
891 [Documentation] Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
892 BuiltIn.Log ${json_data}
893 ${resp} = RequestsLibrary.Put Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id} ${json_data}
894 BuiltIn.Log ${resp.content}
895 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
896 [Return] ${resp.content}
898 Get Neutron Network Rest
899 [Arguments] ${net_id}
900 [Documentation] Keyword to get the specific network details in Neutron (Using REST).
901 ${resp} = RequestsLibrary.Get Request session ${NETWORK_URL}/network/${net_id}
902 BuiltIn.Log ${resp.content}
903 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
904 [Return] ${resp.content}
906 Create And Configure Security Group
907 [Arguments] ${sg-name}
908 [Documentation] Create Security Group with given name, and default allow rules for TCP/UDP/ICMP protocols.
909 OpenStackOperations.Neutron Security Group Create ${sg-name}
910 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
911 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
912 OpenStackOperations.Neutron Security Group Rule Create ${sg-name} direction=ingress protocol=icmp remote_ip_prefix=0.0.0.0/0
913 OpenStackOperations.Neutron Security Group Rule Create ${sg-name} direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0
914 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
915 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
917 Add Security Group To VM
918 [Arguments] ${vm} ${sg}
919 [Documentation] Add the security group provided to the given VM.
920 ${output} = OpenStack CLI openstack server add security group ${vm} ${sg}
922 Remove Security Group From VM
923 [Arguments] ${vm} ${sg}
924 [Documentation] Remove the security group provided to the given VM.
925 OpenStackOperations.Get ControlNode Connection
926 ${output} = OpenStack CLI openstack server remove security group ${vm} ${sg}
928 Create SFC Flow Classifier
929 [Arguments] ${name} ${src_ip} ${dest_ip} ${protocol} ${neutron_src_port} ${args}=${EMPTY}
930 [Documentation] Create a flow classifier for SFC
931 ${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}
932 BuiltIn.Should Contain ${output} ${name}
935 Delete SFC Flow Classifier
937 [Documentation] Delete a SFC flow classifier
938 ${output} = OpenStack CLI openstack sfc flow classifier delete ${name}
942 [Arguments] ${name} ${port_in} ${port_out}
943 [Documentation] Creates a neutron port pair for SFC
944 ${output} = OpenStack CLI openstack sfc port pair create --ingress=${port_in} --egress=${port_out} ${name}
945 BuiltIn.Should Contain ${output} ${name}
950 [Documentation] Delete a SFC port pair
951 ${output} = OpenStack CLI openstack sfc port pair delete ${name}
954 Create SFC Port Pair Group
955 [Arguments] ${name} ${port_pair}
956 [Documentation] Creates a port pair group with a single port pair for SFC
957 ${output} = OpenStack CLI openstack sfc port pair group create --port-pair ${port_pair} ${name}
958 BuiltIn.Should Contain ${output} ${name}
961 Create SFC Port Pair Group With Two Pairs
962 [Arguments] ${name} ${port_pair1} ${port_pair2}
963 [Documentation] Creates a port pair group with two port pairs for SFC
964 ${output} = OpenStack CLI openstack sfc port pair group create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name}
965 BuiltIn.Should Contain ${output} ${name}
968 Delete SFC Port Pair Group
970 [Documentation] Delete a SFC port pair group
971 OpenStackOperations.Get ControlNode Connection
972 ${output} = OpenStack CLI openstack sfc port pair group delete ${name}
975 Create SFC Port Chain
976 [Arguments] ${name} ${args}=${EMPTY}
977 [Documentation] Creates a port pair chain with two port groups and a singel classifier.
978 ${output} = OpenStack CLI openstack sfc port chain create ${name} ${args}
979 BuiltIn.Should Contain ${output} ${name}
982 Update SFC Port Chain With A New Flow Classifier
983 [Arguments] ${name} ${fc}
984 [Documentation] Adds a Flow Classifier to a Port Chain
985 ${output} = OpenStack CLI openstack sfc port chain set ${name} --flow-classifier ${fc}
988 Update SFC Port Chain Removing A Flow Classifier
989 [Arguments] ${name} ${fc}
990 [Documentation] Adds a Flow Classifier to a Port Chain
991 ${output} = OpenStack CLI openstack sfc port chain unset ${name} --flow-classifier ${fc}
994 Delete SFC Port Chain
996 [Documentation] Delete a SFC port chain
997 ${output} = OpenStack CLI openstack sfc port chain delete ${name}
1001 [Arguments] ${vm_name}
1002 [Documentation] Reboot NOVA VM
1003 ${output} = OpenStack CLI openstack server reboot --wait ${vm_name}
1004 BuiltIn.Wait Until Keyword Succeeds 35s 10s OpenStackOperations.Verify VM Is ACTIVE ${vm_name}
1006 Remove RSA Key From KnownHosts
1007 [Arguments] ${vm_ip}
1008 [Documentation] Remove RSA
1009 OpenStackOperations.Get ControlNode Connection
1010 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo cat /root/.ssh/known_hosts 30s
1011 ${output} = DevstackUtils.Write Commands Until Prompt And Log sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ${vm_ip} 30s
1012 ${output} = DevstackUtils.Write Commands Until Prompt sudo cat "/root/.ssh/known_hosts" 30s
1014 Wait For Routes To Propogate
1015 [Arguments] ${networks} ${subnets}
1016 [Documentation] Check propagated routes
1017 OpenStackOperations.Get ControlNode Connection
1018 : FOR ${INDEX} IN RANGE 0 1
1019 \ ${net_id} = OpenStackOperations.Get Net Id @{networks}[${INDEX}]
1020 \ ${is_ipv6} = String.Get Regexp Matches @{subnets}[${INDEX}] ${IP6_REGEX}
1021 \ ${length} = BuiltIn.Get Length ${is_ipv6}
1022 \ ${cmd} = BuiltIn.Set Variable If ${length} == 0 ip route ip -6 route
1023 \ ${output} = Utils.Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ${cmd} ${DEFAULT_LINUX_PROMPT_STRICT}
1024 \ BuiltIn.Should Contain ${output} @{subnets}[${INDEX}]
1027 [Arguments] ${vms}=@{EMPTY} ${networks}=@{EMPTY} ${subnets}=@{EMPTY} ${ports}=@{EMPTY} ${sgs}=@{EMPTY}
1028 : FOR ${vm} IN @{vms}
1029 \ BuiltIn.Run Keyword And Ignore Error Delete Vm Instance ${vm}
1030 : FOR ${port} IN @{ports}
1031 \ BuiltIn.Run Keyword And Ignore Error Delete Port ${port}
1032 : FOR ${subnet} IN @{subnets}
1033 \ BuiltIn.Run Keyword And Ignore Error Delete SubNet ${subnet}
1034 : FOR ${network} IN @{networks}
1035 \ BuiltIn.Run Keyword And Ignore Error Delete Network ${network}
1036 : FOR ${sg} IN @{sgs}
1037 \ BuiltIn.Run Keyword And Ignore Error Delete SecurityGroup ${sg}
1040 [Documentation] Get a list of different OpenStack resources that might be in use.
1041 @{modules} = BuiltIn.Create List server port network subnet security group
1042 ... security group rule floating ip router
1043 : FOR ${module} IN @{modules}
1044 \ ${output} = OpenStack CLI openstack ${module} list
1046 OpenStack CLI Get List
1048 [Documentation] Return a json list from the output of an OpenStack command.
1049 @{list} = BuiltIn.Create List
1050 ${json} = OpenStack CLI ${cmd}
1051 @{list} = RequestsLibrary.To Json ${json}
1057 [Documentation] Run the given OpenStack ${cmd} and log the output.
1058 ${result} = Process.Run Process ${cmd} shell=True
1059 BuiltIn.Log ${result.stdout}
1060 BuiltIn.Log ${result.stderr}
1061 BuiltIn.Should Be True '${result.rc}' == '0'
1062 [Return] ${result.stdout}
1064 OpenStack CLI With No Log
1066 [Documentation] Run the given OpenStack ${cmd} and do not log the output.
1067 ${result} = Process.Run Process ${cmd} shell=True
1068 BuiltIn.Should Be True '${result.rc}' == '0'
1069 [Return] ${result.stdout}
1071 OpenStack Cleanup All
1072 [Documentation] Cleanup all Openstack resources with best effort. The keyword will query for all resources
1073 ... in use and then attempt to delete them. Errors are ignored to allow the cleanup to continue.
1074 @{fips} = OpenStack CLI Get List openstack floating ip list -f json
1075 : FOR ${fip} IN @{fips}
1076 \ BuiltIn.Run Keyword And Ignore Error Delete Floating IP ${fip['ID']}
1077 @{vms} = OpenStack CLI Get List openstack server list -f json
1078 : FOR ${vm} IN @{vms}
1079 \ OpenStack CLI openstack server show ${vm['ID']}
1080 \ BuiltIn.Run Keyword And Ignore Error Delete Vm Instance ${vm['ID']}
1081 @{routers} = OpenStack CLI Get List openstack router list -f json
1082 : FOR ${router} IN @{routers}
1083 \ BuiltIn.Run Keyword And Ignore Error Cleanup Router ${router['ID']}
1084 @{ports} = OpenStack CLI Get List openstack port list -f json
1085 : FOR ${port} IN @{ports}
1086 \ BuiltIn.Run Keyword And Ignore Error Delete Port ${port['ID']}
1087 @{networks} = OpenStack CLI Get List openstack network list -f json
1088 : FOR ${network} IN @{networks}
1089 \ BuiltIn.Run Keyword And Ignore Error Delete Subnet ${network['Subnets']}
1090 \ BuiltIn.Run Keyword And Ignore Error Delete Network ${network['ID']}
1091 @{security_groups} = OpenStack CLI Get List openstack security group list -f json
1092 : FOR ${security_group} IN @{security_groups}
1093 \ BuiltIn.Run Keyword If "${security_group['Name']}" != "default" BuiltIn.Run Keyword And Ignore Error Delete SecurityGroup ${security_group['ID']}
1098 [Documentation] Delete a router, but first remove any interfaces or gateways so that the delete will be successful.
1099 @{ports} = OpenStack CLI Get List openstack port list --router ${id} -f json --long
1100 : FOR ${port} IN @{ports}
1101 \ ${subnet_id} = OpenStackOperations.Get Match ${port['Fixed IP Addresses']} ${REGEX_UUID} 0
1102 \ BuiltIn.Run Keyword If "${port['Device Owner']}" == "network:router_gateway" BuiltIn.Run Keyword And Ignore Error Remove Gateway ${id}
1103 \ BuiltIn.Run Keyword If "${port['Device Owner']}" == "network:router_interface" BuiltIn.Run Keyword And Ignore Error Remove Interface ${id} ${subnet_id}
1104 BuiltIn.Run Keyword And Ignore Error Delete Router ${id}
1106 OpenStack Suite Setup
1107 [Documentation] Wrapper teardown keyword that can be used in any suite running in an openstack environement
1108 SetupUtils.Setup_Utils_For_Setup_And_Teardown
1109 @{loggers} = BuiltIn.Create List org.apache.karaf.shell.support.ShellUtil org.apache.sshd.server.session.ServerSessionImpl
1110 Setuputils.Setup_Logging_For_Debug_Purposes_On_List_Or_All OFF ${loggers}
1111 DevstackUtils.Devstack Suite Setup
1112 @{tcpdump_port_6653_conn_ids} = OpenStackOperations.Start Packet Capture On Nodes tcpdump_port_6653 port 6653 @{OS_ALL_IPS}
1113 BuiltIn.Set Suite Variable @{tcpdump_port_6653_conn_ids}
1114 BuiltIn.Run Keyword If "${PRE_CLEAN_OPENSTACK_ALL}"=="True" OpenStack Cleanup All
1115 OpenStackOperations.Add OVS Logging On All OpenStack Nodes
1116 Run_Keyword_If_At_Least_Oxygen Wait Until Keyword Succeeds 60 2 ClusterManagement.Check Status Of Services Is OPERATIONAL @{NETVIRT_DIAG_SERVICES}
1117 Verify Expected Default Tables On Nodes
1119 OpenStack Suite Teardown
1120 [Documentation] Wrapper teardown keyword that can be used in any suite running in an openstack environement
1121 ... to clean up all openstack resources. For example, all instances, networks, ports, etc will be listed and
1122 ... and deleted. As other global cleanup tasks are needed, they can be added here and the suites will all
1123 ... benefit automatically.
1124 # TODO: followup patch will add the list of vms to pass to Show Debugs
1125 # OpenStackOperations.Show Debugs @{NET_1_VMS} @{NET_2_VMS}
1126 OpenStackOperations.Get Suite Debugs
1127 OpenStack Cleanup All
1128 OpenStackOperations.Stop Packet Capture On Nodes ${tcpdump_port_6653_conn_ids}
1129 SSHLibrary.Close All Connections
1130 : FOR ${i} IN RANGE ${NUM_ODL_SYSTEM}
1131 \ KarafKeywords.Issue Command On Karaf Console threads --list | wc -l ${ODL_SYSTEM_${i+1}_IP}
1133 Copy DHCP Files From Control Node
1134 [Documentation] Copy the current DHCP files to the robot vm. The keyword must be called
1135 ... after the subnet(s) are created and before the subnet(s) are deleted.
1136 ${suite_} = BuiltIn.Evaluate """${SUITE_NAME}""".replace(" ","_").replace("/","_").replace(".","_")
1137 ${dstdir} = BuiltIn.Set Variable /tmp/qdhcp/${suite_}
1138 OperatingSystem.Create Directory ${dstdir}
1139 OpenStackOperations.Get ControlNode Connection
1140 BuiltIn.Run Keyword And Ignore Error SSHLibrary.Get Directory /opt/stack/data/neutron/dhcp ${dstdir} recursive=True
1142 Is Feature Installed
1143 [Arguments] ${features}=none
1144 : FOR ${feature} IN @{features}
1145 \ ${status} ${output} BuiltIn.Run Keyword And Ignore Error BuiltIn.Should Contain ${CONTROLLERFEATURES} ${feature}
1146 \ Return From Keyword If "${status}" == "PASS" True
1149 Add OVS Logging On All OpenStack Nodes
1150 [Documentation] Add higher levels of OVS logging to all the OpenStack nodes
1151 : FOR ${conn_id} IN @{OS_ALL_CONN_IDS}
1152 \ OVSDB.Add OVS Logging ${conn_id}
1154 Reset OVS Logging On All OpenStack Nodes
1155 [Documentation] Reset the OVS logging to all the OpenStack nodes
1156 : FOR ${conn_id} IN @{OS_ALL_CONN_IDS}
1157 \ OVSDB.Reset OVS Logging ${conn_id}
1159 Start Packet Capture On Nodes
1160 [Arguments] ${tag} ${filter} @{ips}
1161 [Documentation] Wrapper keyword around the TcpDump packet capture that is catered to the Openstack setup.
1162 ... The caller must pass the three arguments with a variable number of ips at the end,
1163 ... but ${EMPTY} can be used for the tag and filter.
1164 ${suite_} = BuiltIn.Evaluate """${SUITE_NAME}""".replace(" ","_").replace("/","_").replace(".","_")
1165 ${tag_} = BuiltIn.Catenate SEPARATOR=__ ${tag} ${suite_}
1166 @{conn_ids} = Tcpdump.Start Packet Capture on Nodes tag=${tag_} filter=${filter} ips=${ips}
1167 [Return] @{conn_ids}
1169 Stop Packet Capture On Nodes
1170 [Arguments] ${conn_ids}=@{EMPTY}
1171 Tcpdump.Stop Packet Capture on Nodes ${conn_ids}
1174 [Arguments] ${vm_instance_name}
1175 [Documentation] Keyword for live migration of VM instance
1176 ... additional_agrs is to select particular migration(live/shared-migration/block-migration)
1177 ... if the additional_agrs is not given default migration(shared-migration) will happen
1178 ${output} = OpenStackOperations.OpenStack CLI nova live-migration ${vm_instance_name}
1180 Get Hypervisor Host Of Vm
1181 [Arguments] ${vm_name}
1182 [Documentation] Show server with neutron request.
1183 ${output} = OpenStackOperations.OpenStack CLI openstack server show -f value -c OS-EXT-SRV-ATTR:host ${vm_name}
1186 Check If Migration Is Complete
1187 [Arguments] ${vm_name}
1188 [Documentation] Show server and verify if task_state is not migrating
1189 ${output} = OpenStackOperations.OpenStack CLI openstack server show ${vm_name} | grep "OS-EXT-STS:task_state"
1190 BuiltIn.Should Not Contain ${output} migrating
1192 Modify OpenStack Configuration File
1193 [Arguments] ${conn_id} ${file_name} ${section} ${key} ${value}
1194 [Documentation] Use crudini to modify any parameter in any Openstack configuration File
1195 SSHLibrary.Switch Connection ${conn_id}
1196 ${output} ${rc} = SSHLibrary.Execute Command sudo crudini --verbose --set --inplace ${file_name} ${section} ${key} ${value} return_rc=True return_stdout=True
1197 BuiltIn.Log ${output}
1198 BuiltIn.Should Be True '${rc}' == '0'
1200 Restart DevStack Service
1201 [Arguments] ${conn_id} ${service_name}
1202 [Documentation] Restart the Openstack Service
1203 SSHLibrary.Switch Connection ${conn_id}
1204 ${output} ${rc} = SSHLibrary.Execute Command sudo systemctl restart devstack@${service_name}.service return_rc=True return_stdout=True
1205 BuiltIn.Log ${output}
1206 BuiltIn.Should Be True '${rc}' == '0'
1208 Get Network Segmentation Id
1209 [Arguments] ${network_name}
1210 [Documentation] Returns network segmentation id for the given network name.
1211 ${output} = OpenStack CLI openstack network show ${network_name} | grep segmentation_id | awk '{print $4}'
1212 @{list} = String.Split String ${output}
1215 Verify Expected Default Tables On Nodes
1216 [Arguments] ${node_ips}=@{OS_ALL_IPS}
1217 [Documentation] Verify if Default Table Entries are programmed on all Nodes
1218 ${resp} = RequestsLibrary.Get Request session ${CONFIG_NODES_API}
1219 Utils.Log Content ${resp.content}
1220 ${failed_node_list} = BuiltIn.Create List
1221 : FOR ${node_ip} IN @{node_ips}
1222 \ ${failed_table_list} = Verify Expected Default Tables ${node_ip}
1223 \ ${failed_table_list_size} = BuiltIn.Get Length ${failed_table_list}
1224 \ BuiltIn.Run Keyword If ${failed_table_list_size} > 0 Collections.Append To List ${failed_node_list} ${node_ip}
1225 Builtin.Should Be Empty ${failed_node_list}
1227 Verify Expected Default Tables
1228 [Arguments] ${ovs_ip}
1229 [Documentation] Verify if Default Table Entries are programmed on specific Node
1230 ${flow_dump} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -OOpenFlow13
1231 BuiltIn.Log ${flow_dump}
1232 ${failed_table_list} = BuiltIn.Create List
1233 : FOR ${table} IN @{DEFAULT_FLOW_TABLES}
1234 \ ${rc} = Builtin.Run Keyword And Return Status Builtin.Should Not Match Regexp ${flow_dump} .*table=${table}.*priority=0
1235 \ BuiltIn.Run Keyword If ${rc} Collections.Append To List ${failed_table_list} ${table}
1236 [Return] ${failed_table_list}
1239 [Arguments] ${project_name}
1240 [Documentation] Returns project ID for the given project name.
1241 ${project_id} = OpenStack CLI openstack project show ${project_name} -f value -c id
1242 [Return] ${project_id}
1244 Set Instance Quota For Project
1245 [Arguments] ${num_instances} ${project_id}
1246 [Documentation] Set quota for the created instances using the specific project id.
1247 ${output} = OpenStack CLI openstack quota set --instances ${num_instances} ${project_id}