2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
5 Library OperatingSystem
6 Resource DataModels.robot
8 Resource SSHKeywords.robot
9 Resource L2GatewayOperations.robot
10 Resource ../variables/Variables.robot
11 Resource ../variables/netvirt/Variables.robot
12 Variables ../variables/netvirt/Modules.py
15 Get Tenant ID From Security Group
16 [Documentation] Returns tenant ID by reading it from existing default security-group.
17 ${rc} ${output}= Run And Return Rc And Output openstack security group show default | grep "| tenant_id" | awk '{print $4}'
18 Should Not Be True ${rc}
21 Get Tenant ID From Network
22 [Arguments] ${network_uuid}
23 [Documentation] Returns tenant ID by reading it from existing network.
24 ${resp}= Get_From_Uri uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/ accept=${ACCEPT_EMPTY} session=session
25 ${tenant_id}= Utils.Extract Value From Content ${resp} /network/0/tenant-id strip
29 [Arguments] ${network_name} ${additional_args}=${EMPTY} ${verbose}=TRUE
30 [Documentation] Create Network with neutron request.
31 ${rc} ${output}= Run And Return Rc And Output openstack network create ${network_name} ${additional_args}
33 Should Not Be True ${rc}
37 [Arguments] ${network_name} ${additional_args}=${EMPTY}
38 [Documentation] Update Network with neutron request.
39 ${cmd}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v net-update ${network_name} ${additional_args} openstack network set ${network_name} ${additional_args}
40 ${rc} ${output}= Run And Return Rc And Output ${cmd}
42 Should Not Be True ${rc}
46 [Arguments] ${network_name}
47 [Documentation] Show Network with neutron request.
48 ${rc} ${output}= Run And Return Rc And Output openstack network show ${network_name}
50 Should Not Be True ${rc}
54 [Documentation] List networks and return output with neutron client.
55 ${rc} ${output}= Run And Return Rc And Output openstack network list
57 Should Not Be True ${rc}
61 [Documentation] List subnets and return output with neutron client.
62 ${rc} ${output}= Run And Return Rc And Output openstack subnet list
64 Should Not Be True ${rc}
68 [Arguments] ${network_name}
69 [Documentation] Delete Network with neutron request.
70 ${rc} ${output}= Run And Return Rc And Output openstack network delete ${network_name}
72 Should Not Be True ${rc}
75 [Arguments] ${network_name} ${subnet} ${range_ip} ${additional_args}=${EMPTY}
76 [Documentation] Create SubNet for the Network with neutron request.
77 ${rc} ${output}= Run And Return Rc And Output openstack subnet create --network ${network_name} --subnet-range ${range_ip} ${subnet} ${additional_args}
79 Should Not Be True ${rc}
82 [Arguments] ${subnet_name} ${additional_args}=${EMPTY}
83 [Documentation] Update subnet with neutron request.
84 ${cmd}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v subnet-update ${subnet_name} ${additional_args} openstack subnet set ${subnet_name} ${additional_args}
85 ${rc} ${output}= Run And Return Rc And Output ${cmd}
87 Should Not Be True ${rc}
91 [Arguments] ${subnet_name}
92 [Documentation] Show subnet with neutron request.
93 ${rc} ${output}= Run And Return Rc And Output openstack subnet show ${subnet_name}
95 Should Not Be True ${rc}
99 [Arguments] ${network_name} ${port_name} ${sg}=default ${additional_args}=${EMPTY} ${allowed_address_pairs}=${EMPTY}
100 [Documentation] Create Port with neutron request.
101 # if allowed_address_pairs is not empty we need to create the arguments to pass to the port create command. They are
102 # in a different format with the neutron vs openstack cli.
103 ${address_pair_length}= Get Length ${allowed_address_pairs}
104 ${allowed_pairs_argv}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' and '${address_pair_length}'=='2' --allowed-address-pairs type=dict list=true ip_address=@{allowed_address_pairs}[0] ip_address=@{allowed_address_pairs}[1]
105 ${allowed_pairs_argv}= Set Variable If '${OPENSTACK_BRANCH}'!='stable/newton' and '${address_pair_length}'=='2' --allowed-address ip-address=@{allowed_address_pairs}[0] --allowed-address ip-address=@{allowed_address_pairs}[1] ${allowed_pairs_argv}
106 ${allowed_pairs_argv}= Set Variable If '${address_pair_length}'=='0' ${EMPTY} ${allowed_pairs_argv}
107 ${cmd}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v port-create ${network_name} --name ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv} openstack port create --network ${network_name} ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv}
108 ${rc} ${output}= Run And Return Rc And Output ${cmd}
110 Should Not Be True ${rc}
113 [Arguments] ${port_name} ${additional_args}=${EMPTY}
114 [Documentation] Update port with neutron request.
115 ${rc} ${output}= Run And Return Rc And Output openstack port set ${port_name} ${additional_args}
117 Should Not Be True ${rc}
121 [Arguments] ${port_name}
122 [Documentation] Show port with neutron request.
123 ${rc} ${output}= Run And Return Rc And Output openstack port show ${port_name}
125 Should Not Be True ${rc}
129 [Arguments] ${port_name}
130 [Documentation] Delete Port with neutron request.
131 ${rc} ${output}= Run And Return Rc And Output openstack port delete ${port_name}
133 Should Not Be True ${rc}
136 [Documentation] List ports and return output with neutron client.
137 ${rc} ${output}= Run And Return Rc And Output openstack port list
139 Should Not Be True ${rc}
143 [Documentation] List VMs and return output with nova client.
144 ${rc} ${output}= Run And Return Rc And Output openstack server list --all-projects
146 Should Not Be True ${rc}
149 Create And Associate Floating IPs
150 [Arguments] ${external_net} @{vm_list}
151 [Documentation] Create and associate floating IPs to VMs with nova request
152 ${ip_list}= Create List @{EMPTY}
153 : FOR ${vm} IN @{vm_list}
154 \ ${rc} ${output}= Run And Return Rc And Output openstack floating ip create ${external_net}
156 \ Should Not Be True ${rc}
157 \ @{ip} Get Regexp Matches ${output} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
158 \ ${ip_length} Get Length ${ip}
159 \ Run Keyword If ${ip_length}>0 Append To List ${ip_list} @{ip}[0]
160 \ ... ELSE Append To List ${ip_list} None
161 \ ${rc} ${output}= Run And Return Rc And Output openstack server add floating ip ${vm} @{ip}[0]
163 \ Should Not Be True ${rc}
167 [Documentation] Verifies the Gateway Ips with dump flow.
168 ${output}= Write Commands Until Prompt And Log sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
169 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
170 \ Should Contain ${output} ${GatewayIpElement}
173 [Documentation] Verifies the Dhcp Ips with dump flow.
174 ${output}= Write Commands Until Prompt And Log sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
175 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
176 \ Should Contain ${output} ${DhcpIpElement}
179 [Documentation] Verifies the Dhcp Ips with dump flow.
180 ${output}= Write Commands Until Prompt And Log sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
181 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
182 \ Should Not Contain ${output} ${DhcpIpElement}
185 [Arguments] ${subnet}
186 [Documentation] Delete SubNet for the Network with neutron request.
188 ${rc} ${output}= Run And Return Rc And Output openstack subnet delete ${subnet}
189 Should Not Be True ${rc}
191 Verify No Gateway Ips
192 [Documentation] Verifies the Gateway Ips removed with dump flow.
193 ${output}= Write Commands Until Prompt And Log sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
194 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
195 \ Should Not Contain ${output} ${GatewayIpElement}
198 [Arguments] ${vm_name}
199 [Documentation] Delete Vm instances using instance names.
200 ${rc} ${output}= Run And Return Rc And Output openstack server delete ${vm_name}
204 [Arguments] ${network_name} ${devstack_conn_id}
205 [Documentation] Retrieve the net id for the given network name to create specific vm instance
206 ${rc} ${output}= Run And Return Rc And Output openstack network list | grep "${network_name}" | awk '{print $2}'
207 Should Not Be True ${rc}
208 ${splitted_output}= Split String ${output} ${EMPTY}
209 ${net_id}= Get from List ${splitted_output} 0
213 [Arguments] ${subnet_name} ${devstack_conn_id}
214 [Documentation] Retrieve the subnet id for the given subnet name
215 ${rc} ${output}= Run And Return Rc And Output openstack subnet show "${subnet_name}" | grep " id " | awk '{print $4}'
216 Should Not Be True ${rc}
217 ${splitted_output}= Split String ${output} ${EMPTY}
218 ${subnet_id}= Get from List ${splitted_output} 0
219 [Return] ${subnet_id}
222 [Arguments] ${port_name} ${devstack_conn_id}
223 [Documentation] Retrieve the port id for the given port name to attach specific vm instance to a particular port
224 ${rc} ${output}= Run And Return Rc And Output openstack port list | grep "${port_name}" | awk '{print $2}'
225 Should Not Be True ${rc}
226 ${splitted_output}= Split String ${output} ${EMPTY}
227 ${port_id}= Get from List ${splitted_output} 0
231 [Arguments] ${router1} ${devstack_conn_id}
232 [Documentation] Retrieve the router id for the given router name
233 ${rc} ${output}= Run And Return Rc And Output openstack router list -f table | grep "${router1}" | awk '{print $2}'
234 Should Not Be True ${rc}
235 ${splitted_output}= Split String ${output} ${EMPTY}
236 ${router_id}= Get from List ${splitted_output} 0
237 [Return] ${router_id}
240 [Arguments] ${net_name} ${vm_instance_names} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default ${min}=1
242 [Documentation] Create X Vm Instance with the net id of the Netowrk.
243 ${image} Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
244 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
245 : FOR ${VmElement} IN @{vm_instance_names}
246 \ ${rc} ${output}= Run And Return Rc And Output openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-group ${sg} --min ${min} --max ${max}
247 \ Should Not Be True ${rc}
250 Create Vm Instance With Port
251 [Arguments] ${port_name} ${vm_instance_name} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
252 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
253 ${image} Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
254 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
255 ${rc} ${output}= Run And Return Rc And Output openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-group ${sg}
258 Create Vm Instance With Ports
259 [Arguments] ${port_name} ${port2_name} ${vm_instance_name} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
260 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
261 ${image} Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
262 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
263 ${port2_id}= Get Port Id ${port2_name} ${devstack_conn_id}
264 ${rc} ${output}= Run And Return Rc And Output openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --nic port-id=${port2_id} ${vm_instance_name} --security-group ${sg}
266 Should Not Be True ${rc}
268 Create Vm Instance With Port On Compute Node
269 [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
270 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
271 ${image} Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
272 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
273 ${hostname_compute_node}= Get Hypervisor Hostname From IP ${compute_node}
274 ${rc} ${output}= Run And Return Rc And Output openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --security-group ${sg} --availability-zone nova:${hostname_compute_node} ${vm_instance_name}
276 Should Not Be True ${rc}
278 Get Hypervisor Hostname From IP
279 [Arguments] ${hypervisor_ip}
280 [Documentation] Returns the hostname found for the given IP address if it's listed in hypervisor list. For debuggability
281 ... the full listing is logged first, then followed by a grep | cut to focus on the actual hostname to return
282 ${rc} ${output} Run And Return Rc And Output openstack hypervisor list
284 ${rc} ${hostname}= Run And Return Rc And Output openstack hypervisor list -f value | grep ${hypervisor_ip} | cut -d" " -f 2
286 Should Not Be True ${rc}
290 [Documentation] Create a nano flavor
291 ${rc} ${output}= Run And Return Rc And Output openstack flavor create m1.nano --id auto --ram 64 --disk 0 --vcpus 1
293 Should Not Be True ${rc}
296 [Arguments] ${vm_name}
297 [Documentation] Run these commands to check whether the created vm instance is active or not.
298 ${rc} ${output}= Run And Return Rc And Output openstack server show ${vm_name} | grep OS-EXT-STS:vm_state
299 Should Be True '${rc}' == '0'
300 Should Contain ${output} active
303 [Arguments] ${vm_name} ${retry}=600s ${retry_interval}=30s
304 [Documentation] Run these commands to check whether the created vm instance is active or not.
305 Wait Until Keyword Succeeds ${retry} ${retry_interval} Verify VM Is ACTIVE ${vm_name}
307 Collect VM IP Addresses
308 [Arguments] ${fail_on_none} @{vm_list}
309 [Documentation] Using the console-log on the provided ${vm_list} to search for the string "obtained" which
310 ... correlates to the instance receiving it's IP address via DHCP. Also retrieved is the ip of the nameserver
311 ... if available in the console-log output. The keyword will also return a list of the learned ips as it
312 ... finds them in the console log output, and will have "None" for Vms that no ip was found.
313 ${ip_list} Create List @{EMPTY}
314 : FOR ${vm} IN @{vm_list}
315 \ ${rc} ${vm_ip_line}= Run And Return Rc And Output openstack console log show ${vm} | grep -i "obtained"
316 \ @{vm_ip} Get Regexp Matches ${vm_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
317 \ ${vm_ip_length} Get Length ${vm_ip}
318 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip}[0]
319 \ ... ELSE Append To List ${ip_list} None
320 \ ${rc} ${dhcp_ip_line}= Run And Return Rc And Output openstack console log show ${vm} | grep "^nameserver"
321 \ ${dhcp_ip} Get Regexp Matches ${dhcp_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
322 \ ${dhcp_ip_length} Get Length ${dhcp_ip}
323 \ Run Keyword If ${dhcp_ip_length}<=0 Append To List ${dhcp_ip} None
324 \ ${vm_console_output}= Run openstack console log show ${vm}
325 \ Log ${vm_console_output}
326 ${dhcp_length} Get Length ${dhcp_ip}
327 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${ip_list} None
328 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${dhcp_ip} None
329 Should Be True ${dhcp_length} <= 1
330 Return From Keyword If ${dhcp_length}==0 ${ip_list} ${EMPTY}
331 [Return] ${ip_list} ${dhcp_ip}
334 [Arguments] ${text} ${regexp}
335 [Documentation] Wrapper around Get Regexp Matches to return None if not found or the first match if found.
336 @{matches} = String.Get Regexp Matches ${text} ${regexp}
337 ${matches_length} = Get Length ${matches}
338 BuiltIn.Set Test Variable ${match} None
339 BuiltIn.Run Keyword If ${matches_length} > 0 BuiltIn.Set Test Variable ${match} @{matches}[0]
343 [Arguments] ${fail_on_none} ${vm}
344 [Documentation] Get the vm ip address and nameserver by scraping the vm's console log.
345 ... Get VM IP returns three values: [0] the vm IP, [1] the DHCP IP and [2] the vm console log.
346 ${rc} ${vm_console_output}= Run And Return Rc And Output openstack console log show ${vm}
347 ${vm_ip} = Set Variable None
348 ${dhcp_ip} = Set Variable None
349 ${match} = Get Match ${vm_console_output} ${REGEX_OBTAINED}
350 ${vm_ip} = Get Match ${match} ${REGEX_IPV4}
351 ${match} = Get Match ${vm_console_output} ${REGEX_NAMESERVER}
352 ${dhcp_ip} = Get Match ${match} ${REGEX_IPV4}
353 BuiltIn.Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${vm_ip} None
354 BuiltIn.Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${dhcp_ip} None
355 [Return] ${vm_ip} ${dhcp_ip} ${vm_console_output}
359 [Documentation] Get the instance IP addresses and nameserver address for the list of given vms.
360 ... First poll for the vm instance to be in the active state, then poll for the vm ip address and nameserver.
361 ... Get VM IPs returns two things: [0] a list of the ips for the vms passed to this keyword (may contain values
362 ... of None) and [1] the dhcp ip address found in the last vm checked.
363 ... TODO: there is a potential issue for a caller that passes in VMs belonging to different networks that
364 ... may have different dhcp server addresses. Not sure what TODO about that, but noting it here for reference.
365 @{vm_ips} BuiltIn.Create List @{EMPTY}
366 : FOR ${vm} IN @{vms}
367 \ Poll VM Is ACTIVE ${vm}
368 \ ${status} ${ips_and_console_log} Run Keyword And Ignore Error Wait Until Keyword Succeeds 120s 15s
369 \ ... Get VM IP true ${vm}
370 \ # If there is trouble with Get VM IP, the status will be FAIL and the return value will be a string of what went
371 \ # wrong. We need to handle both the PASS and FAIL cases. In the FAIL case we know we wont have access to the
372 \ # console log, as it would not be returned; so we need to grab it again to log it. We also can append 'None' to
373 \ # the vm ip list if status is FAIL.
374 \ Run Keyword If "${status}" == "PASS" BuiltIn.Log ${ips_and_console_log[2]}
375 \ BuiltIn.Run Keyword If "${status}" == "PASS" Collections.Append To List ${vm_ips} ${ips_and_console_log[0]}
376 \ BuiltIn.Run Keyword If "${status}" == "FAIL" Collections.Append To List ${vm_ips} None
377 \ ${rc} ${vm_console_output}= BuiltIn.Run Keyword If "${status}" == "FAIL" Run And Return Rc And Output openstack console log show ${vm}
378 \ BuiltIn.Run Keyword If "${status}" == "FAIL" BuiltIn.Log ${vm_console_output}
379 [Return] @{vm_ips} ${ips_and_console_log[1]}
381 Collect VM IPv6 SLAAC Addresses
382 [Arguments] ${fail_on_none} ${prefix} @{vm_list}
383 [Documentation] Using the console-log on the provided ${vm_list} to search for the string "inet6" which
384 ... correlates to the instance generated IPv6 address, based on the ${prefix} received from ODL (SLAAC mode).
385 ${ip_list} Create List @{EMPTY}
386 : FOR ${vm} IN @{vm_list}
388 \ ${rc} ${vm_ip_line}= Run And Return Rc And Output openstack console log show ${vm} | grep -i "inet6"
391 \ @{vm_ip_list} Get Regexp Matches ${vm_ip_line} ${prefix}
392 \ ${vm_ip_length} Get Length ${vm_ip_list}
393 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip_list}[0]
394 \ ... ELSE Append To List ${ip_list} None
396 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${ip_list} None
401 [Arguments] ${vm_instance_names}
402 [Documentation] View Console log of the created vm instances using nova show.
403 : FOR ${VmElement} IN @{vm_instance_names}
404 \ ${rc} ${output}= Run And Return Rc And Output openstack server show ${VmElement}
406 \ Should Not Be True ${rc}
407 \ ${rc} ${output}= Run And Return Rc And Output openstack console log show ${VmElement}
409 \ Should Not Be True ${rc}
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.
415 ${devstack_conn_id}= Get ControlNode Connection
416 Switch Connection ${devstack_conn_id}
417 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
419 ${output}= Write Commands Until Prompt And Log sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
421 Should Contain ${output} 64 bytes
423 Ping From DHCP Should Not Succeed
424 [Arguments] ${net_name} ${vm_ip}
425 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
426 Return From Keyword If "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
428 ${devstack_conn_id}= Get ControlNode Connection
429 Switch Connection ${devstack_conn_id}
430 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
432 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
435 Should Not Contain ${output} 64 bytes
437 Ping Vm From Control Node
438 [Arguments] ${vm_floating_ip} ${additional_args}=${EMPTY}
439 [Documentation] Ping VM floating IP from control node
440 Log ${vm_floating_ip}
441 ${devstack_conn_id}= Get ControlNode Connection
442 Switch Connection ${devstack_conn_id}
443 ${output}= Write Commands Until Prompt And Log ping ${additional_args} -c 3 ${vm_floating_ip} 20s
445 Should Contain ${output} 64 bytes
448 [Arguments] ${dest_vm_ip}
449 [Documentation] Ping to the expected destination ip.
450 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm_ip} ${OS_SYSTEM_PROMPT}
455 [Documentation] Ping to the expected destination ip.
456 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
457 Write Commands Until Prompt exit
458 Should Contain ${output} 200
461 [Documentation] Exit the vm instance.
462 ${output}= Write Commands Until Prompt And Log exit
464 Check If Console Is VmInstance
465 [Arguments] ${console}=cirros
466 [Documentation] Check if the session has been able to login to the VM instance
467 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
468 Should Contain ${output} ${console}
471 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
472 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
473 Run Keyword If ${rcode} Write Commands Until Prompt exit
477 [Arguments] ${ip_address} ${ttl}=64
478 [Documentation] Run Ping command on the IP available as argument
479 ${ethertype}= Get Regexp Matches ${ip_address} ${IP_REGEX}
480 ${output}= Run Keyword If ${ethertype} Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
481 ... ELSE Write Commands Until Expected Prompt ping6 -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
482 Should Contain ${output} 64 bytes
485 [Arguments] ${ip_address} ${ttl}=64
486 [Documentation] Run Ping command to the IP given as argument, executing 3 times and expecting NOT to see "64 bytes"
487 ${output}= Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
488 Should Not Contain ${output} 64 bytes
490 Check Metadata Access
491 [Documentation] Try curl on the Metadataurl and check if it is okay
492 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
493 Should Contain ${output} 200
495 Execute Command on VM Instance
496 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
497 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
498 ${devstack_conn_id} = Get ControlNode Connection
499 Switch Connection ${devstack_conn_id}
500 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
502 ${output} = Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${vm_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null password:
504 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
506 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
507 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
508 [Teardown] Exit From Vm Console
511 Test Operations From Vm Instance
512 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:) ${ttl}=64
513 ... ${ping_should_succeed}=True ${check_metadata}=True
514 [Documentation] Login to the vm instance using ssh in the network.
515 ${devstack_conn_id}= Get ControlNode Connection
516 Switch Connection ${devstack_conn_id}
518 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
519 ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no ${user}@${src_ip} -o UserKnownHostsFile=/dev/null password:
521 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
523 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
524 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
525 Run Keyword If ${rcode} Write Commands Until Expected Prompt route -n ${OS_SYSTEM_PROMPT}
526 Run Keyword If ${rcode} Write Commands Until Expected Prompt route -A inet6 ${OS_SYSTEM_PROMPT}
527 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
528 Run Keyword If ${rcode} Write Commands Until Expected Prompt ip -f inet6 neigh show ${OS_SYSTEM_PROMPT}
529 : FOR ${dest_ip} IN @{dest_ips}
531 \ ${string_empty}= Run Keyword And Return Status Should Be Empty ${dest_ip}
532 \ Run Keyword If ${string_empty} Continue For Loop
533 \ Run Keyword If ${rcode} and "${ping_should_succeed}" == "True" Check Ping ${dest_ip} ttl=${ttl}
534 \ ... ELSE Check No Ping ${dest_ip} ttl=${ttl}
535 ${ethertype}= Get Regexp Matches ${src_ip} ${IP_REGEX}
536 Run Keyword If ${rcode} and "${check_metadata}" and ${ethertype} == "True" Check Metadata Access
537 [Teardown] Exit From Vm Console
539 Test Netcat Operations From Vm Instance
540 [Arguments] ${net_name} ${vm_ip} ${dest_ip} ${additional_args}=${EMPTY} ${port}=12345 ${user}=cirros
541 ... ${password}=cubswin:)
542 [Documentation] Use Netcat to test TCP/UDP connections to the controller
543 ${client_data} Set Variable Test Client Data
544 ${server_data} Set Variable Test Server Data
545 ${devstack_conn_id}= Get ControlNode Connection
546 Switch Connection ${devstack_conn_id}
548 ${output}= Write Commands Until Prompt And Log ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
549 ${output}= Write Commands Until Prompt And Log sudo netstat -nlap | grep ${port}
550 ${nc_output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo echo "${client_data}" | nc -v -w 5 ${additional_args} ${dest_ip} ${port}
552 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo route -n
554 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo arp -an
556 Should Match Regexp ${nc_output} ${server_data}
559 [Arguments] ${list_of_external_dst_ips}
560 [Documentation] Check reachability with other network's instances.
561 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
562 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
564 \ Check Ping ${dest_ip}
567 [Arguments] ${router_name}
568 [Documentation] Create Router and Add Interface to the subnets.
569 ${rc} ${output}= Run And Return Rc And Output openstack router create ${router_name}
570 Should Not Be True ${rc}
573 [Documentation] List Router and return output with neutron client.
574 ${rc} ${output}= Run And Return Rc And Output openstack router list -f value
576 Should Not Be True ${rc}
580 [Arguments] ${router_name} ${interface_name}
581 ${rc} ${output}= Run And Return Rc And Output openstack router add subnet ${router_name} ${interface_name}
582 Should Not Be True ${rc}
584 Show Router Interface
585 [Arguments] ${router_name}
586 [Documentation] List Router interface associated with given Router and return output with neutron client.
587 ${rc} ${output}= Run And Return Rc And Output openstack port list --router ${router_name} -f value
588 Should Not Be True ${rc}
592 [Arguments] ${router_name} ${external_network_name}
593 ${cmd}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v router-gateway-set ${router_name} ${external_network_name} openstack router set ${router_name} --external-gateway ${external_network_name}
594 ${rc} ${output}= Run And Return Rc And Output ${cmd}
595 Should Not Be True ${rc}
598 [Arguments] ${router_name} ${interface_name}
599 [Documentation] Remove Interface to the subnets.
600 ${rc} ${output}= Run And Return Rc And Output openstack router remove subnet ${router_name} ${interface_name}
601 Should Not Be True ${rc}
604 [Arguments] ${router_name} ${cmd}
605 [Documentation] Update the router with the command. Router name and command should be passed as argument.
606 ${rc} ${output} = Run And Return Rc And Output openstack router set ${router_name} ${cmd}
607 Should Not Be True ${rc}
610 [Arguments] ${router_name} ${options}
611 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
612 ${rc} ${output} = Run And Return Rc And Output openstack router show ${router_name}
616 [Arguments] ${router_name}
617 [Documentation] Delete Router and Interface to the subnets.
618 ${rc} ${output}= Run And Return Rc And Output openstack router delete ${router_name}
619 Should Not Be True ${rc}
621 Get DumpFlows And Ovsconfig
622 [Arguments] ${openstack_node_ip}
623 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
624 Log ${openstack_node_ip}
625 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
626 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
627 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
628 Write Commands Until Expected Prompt ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
629 Write Commands Until Expected Prompt ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
630 Write Commands Until Expected Prompt ip route ${DEFAULT_LINUX_PROMPT_STRICT}
631 Write Commands Until Expected Prompt arp -an ${DEFAULT_LINUX_PROMPT_STRICT}
632 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ${DEFAULT_LINUX_PROMPT_STRICT}
633 @{lines} Split To Lines ${nslist} end=-1
634 : FOR ${line} IN @{lines}
635 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
636 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
637 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT}
638 Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
639 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
640 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
641 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
642 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
643 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
645 Get Karaf Log Type From Test Start
646 [Arguments] ${ip} ${test_name} ${type} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
647 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
648 ${cmd} Set Variable sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
649 ${output} Run Command On Controller ${ip} ${cmd} ${user} ${password} ${prompt}
652 Get Karaf Log Types From Test Start
653 [Arguments] ${ip} ${test_name} ${types} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
654 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
655 : FOR ${type} IN @{types}
656 \ Get Karaf Log Type From Test Start ${ip} ${test_name} ${type} ${user} ${password}
657 \ ... ${prompt} ${log_file}
659 Get Karaf Log Events From Test Start
660 [Arguments] ${test_name} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
661 ${log_types} = Create List ERROR WARN Exception
662 Run Keyword If 0 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_IP} ${test_name} ${log_types}
663 Run Keyword If 1 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_2_IP} ${test_name} ${log_types}
664 Run Keyword If 2 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_3_IP} ${test_name} ${log_types}
666 Get ControlNode Connection
667 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
668 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
669 SSHLibrary.Set Client Configuration timeout=30s
670 [Return] ${control_conn_id}
673 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
674 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
675 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
676 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
678 Get Test Teardown Debugs
679 [Arguments] ${test_name}=${TEST_NAME}
681 Run Keyword And Ignore Error Get Model Dump ${HA_PROXY_IP} ${netvirt_data_models}
682 Get Karaf Log Events From Test Start ${test_name}
684 Get Test Teardown Debugs For SFC
685 [Arguments] ${test_name}=${TEST_NAME}
686 Run Keyword And Ignore Error Get Model Dump ${HA_PROXY_IP} ${netvirt_sfc_data_models}
689 [Arguments] @{vm_indices}
690 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
691 ${devstack_conn_id}= Get ControlNode Connection
692 Switch Connection ${devstack_conn_id}
693 ${output}= Write Commands Until Prompt And Log sudo ip netns list
695 : FOR ${index} IN @{vm_indices}
696 \ ${rc} ${output}= Run And Return Rc And Output nova show ${index}
703 Neutron Security Group Show
704 [Arguments] ${SecurityGroupRuleName}
705 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
706 ${rc} ${output}= Run And Return Rc And Output openstack security group show ${SecurityGroupRuleName}
708 Should Not Be True ${rc}
712 [Arguments] ${PortName}
713 [Documentation] Display the port configuration that belong to a given neutron port
714 ${rc} ${output}= Run And Return Rc And Output openstack port show ${PortName}
716 Should Not Be True ${rc}
719 Neutron Security Group Create
720 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
721 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
722 ${devstack_conn_id}= Get ControlNode Connection
723 Switch Connection ${devstack_conn_id}
724 ${rc} ${output}= Run And Return Rc And Output openstack security group create ${SecurityGroupName} ${additional_args}
726 Should Not Be True ${rc}
727 ${sgp_id}= Should Match Regexp ${output} [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
729 [Return] ${output} ${sgp_id}
731 Neutron Security Group Update
732 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
733 [Documentation] Updating security groups
734 ${rc} ${output}= Run And Return Rc And Output openstack security group set ${SecurityGroupName} ${additional_args}
736 Should Not Be True ${rc}
740 [Arguments] ${sg_name}
741 [Documentation] Delete Security group
742 ${rc} ${output}= Run And Return Rc And Output openstack security group delete ${sg_name}
744 Should Not Be True ${rc}
746 Neutron Security Group Rule Create
747 [Arguments] ${Security_group_name} &{Kwargs}
748 [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 catenated with mandatory args, example of usage: "Neutron Security Group Rule Create ${SGP_SSH} direction=${RULE_PARAMS[0]} ethertype=${RULE_PARAMS[1]} ..."
749 Run Keyword If ${Kwargs} Log ${Kwargs}
750 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
751 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
752 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
753 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
754 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
755 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
756 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
757 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
758 ${cmd}= Set Variable openstack security group rule create ${Security_group_name}
759 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
760 ... ELSE Catenate ${cmd}
761 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --${direction}
762 ... ELSE Catenate ${cmd}
763 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
764 ... ELSE Catenate ${cmd}
765 ${cmd}= Run Keyword If '${port_range_min}'!='None' and '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_min}:${port_range_max}
766 ... ELSE IF '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_max}
767 ... ELSE IF '${port_range_min}'!='None' Catenate ${cmd} --dst-port ${port_range_min}
768 ... ELSE Catenate ${cmd}
769 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
770 ... ELSE Catenate ${cmd}
771 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote-group ${remote_group_id}
772 ... ELSE Catenate ${cmd}
773 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --src-ip ${remote_ip_prefix}
774 ... ELSE Catenate ${cmd}
775 ${rc} ${output}= Run And Return Rc And Output ${cmd}
776 ${rule_id}= Should Match Regexp ${output} [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
778 Should Not Be True ${rc}
779 [Return] ${output} ${rule_id}
781 Neutron Security Group Rule Create Legacy Cli
782 [Arguments] ${Security_group_name} &{Kwargs}
783 [Documentation] Creates neutron security rule with neutron request with or without optional params, here security group name is mandatory args, rule with optional params can be created by passing the optional args values ex: direction=${INGRESS_EGRESS}, Then these optional params are catenated with mandatory args, example of usage: "Neutron Security Group Rule Create ${SGP_SSH} direction=${RULE_PARAMS[0]} ethertype=${RULE_PARAMS[1]} ..."
784 Run Keyword If ${Kwargs} Log ${Kwargs}
785 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
786 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
787 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
788 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
789 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
790 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
791 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
792 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
793 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
794 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
795 ... ELSE Catenate ${cmd}
796 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
797 ... ELSE Catenate ${cmd}
798 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
799 ... ELSE Catenate ${cmd}
800 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
801 ... ELSE Catenate ${cmd}
802 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
803 ... ELSE Catenate ${cmd}
804 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
805 ... ELSE Catenate ${cmd}
806 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
807 ... ELSE Catenate ${cmd}
808 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
809 ... ELSE Catenate ${cmd}
810 ${rc} ${output}= Run And Return Rc And Output ${cmd}
811 ${rule_id}= Should Match Regexp ${output} [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
813 Should Not Be True ${rc}
814 [Return] ${output} ${rule_id}
816 Security Group Create Without Default Security Rules
817 [Arguments] ${sg_name} ${additional_args}=${EMPTY}
818 [Documentation] Create Neutron Security Group with no default rules, using specified name and optional arguments.
819 Neutron Security Group Create ${sg_name} ${additional_args}
820 Delete All Security Group Rules ${sg_name}
822 Delete All Security Group Rules
823 [Arguments] ${sg_name}
824 [Documentation] Delete all security rules from a specified security group
825 ${rc} ${sg_rules_output}= Run And Return Rc And Output openstack security group rule list ${sg_name} -cID -fvalue
826 Log ${sg_rules_output}
827 Should Not Be True ${rc}
828 @{sg_rules}= Split String ${sg_rules_output} \n
829 : FOR ${rule} IN @{sg_rules}
830 \ ${rc} ${output}= Run And Return Rc And Output openstack security group rule delete ${rule}
832 \ Should Not Be True ${rc}
834 Create Allow All SecurityGroup
835 [Arguments] ${sg_name} ${ether_type}=IPv4
836 [Documentation] Allow all TCP/UDP/ICMP packets for this suite
837 Neutron Security Group Create ${sg_name}
838 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
839 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
840 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} protocol=icmp
841 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} protocol=icmp
842 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
843 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
845 Create Neutron Port With Additional Params
846 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
847 [Documentation] Create Port With given additional parameters
848 ${rc} ${output}= Run And Return Rc And Output neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
850 Should Not Be True ${rc}
851 ${port_id}= Should Match Regexp ${OUTPUT} [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
853 [Return] ${OUTPUT} ${port_id}
856 [Arguments] ${portName_list}
857 [Documentation] Retrieve the port MacAddr for the given list of port name and return the MAC address list.
858 ${MacAddr-list} Create List
859 : FOR ${portName} IN @{portName_list}
860 \ ${macAddr}= OpenStackOperations.Get Port Mac ${portName} ${devstack_conn_id}
861 \ Append To List ${MacAddr-list} ${macAddr}
862 [Return] ${MacAddr-list}
865 [Arguments] ${port_name}
866 [Documentation] Keyword would return the IP of the ${port_name} received.
867 ${rc} ${output}= Run And Return Rc And Output openstack port list | grep "${port_name}" | awk -F\\' '{print $2}'
868 ${splitted_output}= Split String ${output} ${EMPTY}
869 ${port_ip}= Get from List ${splitted_output} 0
870 Should Not Be True ${rc}
874 [Arguments] ${port_name} ${conn_id}=${devstack_conn_id}
875 [Documentation] Keyword would return the MAC ID of the ${port_name} received.
876 ${rc} ${output}= Run And Return Rc And Output openstack port show ${port_name} | grep mac_address | awk '{print $4}'
877 ${splitted_output}= Split String ${output} ${EMPTY}
878 ${port_mac}= Get from List ${splitted_output} 0
879 Should Not Be True ${rc}
883 [Arguments] ${bridge_name} ${intf_name} ${gw_name}
884 [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
885 ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name}
887 [Return] ${l2gw_output}
889 Create L2Gateway Connection
890 [Arguments] ${gw_name} ${net_name}
891 [Documentation] Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
892 ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_CONN_CREATE} ${gw_name} ${net_name}
894 Should Not Be True ${rc}
895 [Return] ${l2gw_output}
898 [Documentation] Keyword to return all the L2 Gateways available (Using Neutron CLI).
899 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_YAML}
900 Should Not Be True ${rc}
903 Get All L2Gateway Connection
904 [Documentation] Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
905 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_CONN_YAML}
906 Should Not Be True ${rc}
911 [Documentation] Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
912 ${rc} ${output}= Run And Return Rc And Output ${L2GW_SHOW} ${gw_id}
914 Should Not Be True ${rc}
918 [Arguments] ${l2gw_name}
919 [Documentation] Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
920 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}'
922 Should Not Be True ${rc}
923 ${splitted_output}= Split String ${output} ${EMPTY}
924 ${l2gw_id}= Get from List ${splitted_output} 0
927 Get L2gw Connection Id
928 [Arguments] ${l2gw_name}
929 [Documentation] Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
930 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${l2gw_name}
931 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}'
932 Should Not Be True ${rc}
933 ${splitted_output}= Split String ${output} ${EMPTY}
934 ${splitted_output}= Split String ${output} ${EMPTY}
935 ${l2gw_conn_id}= Get from List ${splitted_output} 0
936 [Return] ${l2gw_conn_id}
938 Neutron Port List Rest
939 [Documentation] Keyword to get all ports details in Neutron (Using REST).
940 ${resp} = RequestsLibrary.Get Request session ${PORT_URL}
942 Should Be Equal As Strings ${resp.status_code} 200
943 [Return] ${resp.content}
945 Get Neutron Port Rest
946 [Arguments] ${port_id}
947 [Documentation] Keyword to get the specific port details in Neutron (Using REST).
948 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id}
950 Should Be Equal As Strings ${resp.status_code} 200
951 [Return] ${resp.content}
954 [Arguments] ${port_id} ${json_data}
955 [Documentation] Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
957 ${resp} = RequestsLibrary.Put Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id} ${json_data}
959 Should Be Equal As Strings ${resp.status_code} 200
960 [Return] ${resp.content}
962 Create And Configure Security Group
963 [Arguments] ${sg-name}
964 [Documentation] Create Security Group with given name, and default allow rules for TCP/UDP/ICMP protocols.
965 Neutron Security Group Create ${sg-name}
966 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
967 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
968 Neutron Security Group Rule Create ${sg-name} direction=ingress protocol=icmp remote_ip_prefix=0.0.0.0/0
969 Neutron Security Group Rule Create ${sg-name} direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0
970 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
971 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
973 Add Security Group To VM
974 [Arguments] ${vm} ${sg}
975 [Documentation] Add the security group provided to the given VM.
976 ${rc} ${output}= Run And Return Rc And Output openstack server add security group ${vm} ${sg}
978 Should Not Be True ${rc}
980 Remove Security Group From VM
981 [Arguments] ${vm} ${sg}
982 [Documentation] Remove the security group provided to the given VM.
983 ${devstack_conn_id}= Get ControlNode Connection
984 Switch Connection ${devstack_conn_id}
985 ${output}= Write Commands Until Prompt And Log openstack server remove security group ${vm} ${sg}
988 Create SFC Flow Classifier
989 [Arguments] ${name} ${src_ip} ${dest_ip} ${protocol} ${dest_port} ${neutron_src_port}
990 [Documentation] Create a flow classifier for SFC
991 ${rc} ${output}= Run And Return Rc And Output openstack sfc flow classifier create --ethertype IPv4 --source-ip-prefix ${src_ip}/32 --destination-ip-prefix ${dest_ip}/32 --protocol ${protocol} --destination-port ${dest_port}:${dest_port} --logical-source-port ${neutron_src_port} ${name}
993 Should Not Be True ${rc}
994 Should Contain ${output} ${name}
997 Delete SFC Flow Classifier
999 [Documentation] Delete a SFC flow classifier
1000 ${devstack_conn_id}= Get ControlNode Connection
1001 Switch Connection ${devstack_conn_id}
1002 ${rc} ${output}= Run And Return Rc And Output openstack sfc flow classifier delete ${name}
1004 Should Not Be True ${rc}
1007 Create SFC Port Pair
1008 [Arguments] ${name} ${port_in} ${port_out}
1009 [Documentation] Creates a neutron port pair for SFC
1010 ${devstack_conn_id}= Get ControlNode Connection
1011 Switch Connection ${devstack_conn_id}
1012 ${rc} ${output}= Run And Return Rc And Output openstack sfc port pair create --ingress=${port_in} --egress=${port_out} ${name}
1014 Should Not Be True ${rc}
1015 Should Contain ${output} ${name}
1018 Delete SFC Port Pair
1020 [Documentation] Delete a SFC port pair
1021 ${rc} ${output}= Run And Return Rc And Output openstack sfc port pair delete ${name}
1023 Should Not Be True ${rc}
1026 Create SFC Port Pair Group
1027 [Arguments] ${name} ${port_pair}
1028 [Documentation] Creates a port pair group with a single port pair for SFC
1029 ${rc} ${output}= Run And Return Rc And Output openstack sfc port pair group create --port-pair ${port_pair} ${name}
1031 Should Not Be True ${rc}
1032 Should Contain ${output} ${name}
1035 Create SFC Port Pair Group With Two Pairs
1036 [Arguments] ${name} ${port_pair1} ${port_pair2}
1037 [Documentation] Creates a port pair group with two port pairs for SFC
1038 ${rc} ${output}= Run And Return Rc And Output openstack sfc port pair group create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name}
1040 Should Not Be True ${rc}
1041 Should Contain ${output} ${name}
1044 Delete SFC Port Pair Group
1046 [Documentation] Delete a SFC port pair group
1047 ${devstack_conn_id}= Get ControlNode Connection
1048 ${rc} ${output}= Run And Return Rc And Output openstack sfc port pair group delete ${name}
1050 Should Not Be True ${rc}
1053 Create SFC Port Chain
1054 [Arguments] ${name} ${pg1} ${pg2} ${fc}
1055 [Documentation] Creates a port pair chain with two port groups and a singel classifier.
1056 ${rc} ${output}= Run And Return Rc And Output openstack sfc port chain create --port-pair-group ${pg1} --port-pair-group ${pg2} --flow-classifier ${fc} ${name}
1058 Should Not Be True ${rc}
1059 Should Contain ${output} ${name}
1062 Delete SFC Port Chain
1064 [Documentation] Delete a SFC port chain
1065 ${rc} ${output}= Run And Return Rc And Output openstack sfc port chain delete ${name}
1067 Should Not Be True ${rc}
1071 [Arguments] ${vm_name}
1072 [Documentation] Reboot NOVA VM
1073 ${rc} ${output}= Run And Return Rc And Output openstack server reboot --wait ${vm_name}
1075 Should Not Be True ${rc}
1076 Wait Until Keyword Succeeds 35s 10s Verify VM Is ACTIVE ${vm_name}
1078 Remove RSA Key From KnowHosts
1079 [Arguments] ${vm_ip}
1080 [Documentation] Remove RSA
1081 ${devstack_conn_id}= Get ControlNode Connection
1082 Switch Connection ${devstack_conn_id}
1083 ${output}= Write Commands Until Prompt And Log sudo cat /root/.ssh/known_hosts 30s
1084 ${output}= Write Commands Until Prompt And Log sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ${vm_ip} 30s
1085 ${output}= Write Commands Until Prompt sudo cat "/root/.ssh/known_hosts" 30s
1087 Wait For Routes To Propogate
1088 [Arguments] ${networks} ${subnets}
1089 [Documentation] Check propagated routes
1090 ${devstack_conn_id} = Get ControlNode Connection
1091 Switch Connection ${devstack_conn_id}
1092 : FOR ${INDEX} IN RANGE 0 1
1093 \ ${net_id}= Get Net Id @{networks}[${INDEX}] ${devstack_conn_id}
1094 \ ${is_ipv6}= Get Regexp Matches @{subnets}[${INDEX}] ${IP6_REGEX}
1095 \ ${length}= Get Length ${is_ipv6}
1096 \ ${cmd}= Set Variable If ${length} == 0 ip route ip -6 route
1097 \ ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ${cmd} ]>
1098 \ Should Contain ${output} @{subnets}[${INDEX}]