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 IP returns three values: [0] the vm IP, [1] the DHCP IP and [2] the vm console log.
362 @{vm_ips} BuiltIn.Create List @{EMPTY}
363 : FOR ${vm} IN @{vms}
364 \ Poll VM Is ACTIVE ${vm}
365 \ ${status} ${ips_and_console_log} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 15s
366 \ ... Get VM IP true ${vm}
367 \ # If there is trouble with Get VM IP, the status will be FAIL and the return value will be a string of what went
368 \ # wrong. We need to handle both the PASS and FAIL cases. In the FAIL case we know we wont have access to the
369 \ # console log, as it would not be returned; so we need to grab it again to log it. We also can append 'None' to
370 \ # the vm ip list if status is FAIL.
371 \ Run Keyword If "${status}" == "PASS" BuiltIn.Log ${ips_and_console_log[2]}
372 \ BuiltIn.Run Keyword If "${status}" == "PASS" Collections.Append To List ${vm_ips} ${ips_and_console_log[0]}
373 \ BuiltIn.Run Keyword If "${status}" == "FAIL" Collections.Append To List ${vm_ips} None
374 \ ${rc} ${vm_console_output}= BuiltIn.Run Keyword If "${status}" == "FAIL" Run And Return Rc And Output openstack console log show ${vm}
375 \ BuiltIn.Run Keyword If "${status}" == "FAIL" BuiltIn.Log ${vm_console_output}
376 [Return] @{vm_ips} ${ips_and_console_log[1]}
378 Collect VM IPv6 SLAAC Addresses
379 [Arguments] ${fail_on_none} ${prefix} @{vm_list}
380 [Documentation] Using the console-log on the provided ${vm_list} to search for the string "inet6" which
381 ... correlates to the instance generated IPv6 address, based on the ${prefix} received from ODL (SLAAC mode).
382 ${ip_list} Create List @{EMPTY}
383 : FOR ${vm} IN @{vm_list}
385 \ ${rc} ${vm_ip_line}= Run And Return Rc And Output openstack console log show ${vm} | grep -i "inet6"
388 \ @{vm_ip_list} Get Regexp Matches ${vm_ip_line} ${prefix}
389 \ ${vm_ip_length} Get Length ${vm_ip_list}
390 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip_list}[0]
391 \ ... ELSE Append To List ${ip_list} None
393 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${ip_list} None
398 [Arguments] ${vm_instance_names}
399 [Documentation] View Console log of the created vm instances using nova show.
400 : FOR ${VmElement} IN @{vm_instance_names}
401 \ ${rc} ${output}= Run And Return Rc And Output openstack server show ${VmElement}
403 \ Should Not Be True ${rc}
404 \ ${rc} ${output}= Run And Return Rc And Output openstack console log show ${VmElement}
406 \ Should Not Be True ${rc}
408 Ping Vm From DHCP Namespace
409 [Arguments] ${net_name} ${vm_ip}
410 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
412 ${devstack_conn_id}= Get ControlNode Connection
413 Switch Connection ${devstack_conn_id}
414 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
416 ${output}= Write Commands Until Prompt And Log sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
418 Should Contain ${output} 64 bytes
420 Ping From DHCP Should Not Succeed
421 [Arguments] ${net_name} ${vm_ip}
422 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
423 Return From Keyword If "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
425 ${devstack_conn_id}= Get ControlNode Connection
426 Switch Connection ${devstack_conn_id}
427 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
429 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
432 Should Not Contain ${output} 64 bytes
434 Ping Vm From Control Node
435 [Arguments] ${vm_floating_ip} ${additional_args}=${EMPTY}
436 [Documentation] Ping VM floating IP from control node
437 Log ${vm_floating_ip}
438 ${devstack_conn_id}= Get ControlNode Connection
439 Switch Connection ${devstack_conn_id}
440 ${output}= Write Commands Until Prompt And Log ping ${additional_args} -c 3 ${vm_floating_ip} 20s
442 Should Contain ${output} 64 bytes
445 [Arguments] ${dest_vm_ip}
446 [Documentation] Ping to the expected destination ip.
447 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm_ip} ${OS_SYSTEM_PROMPT}
452 [Documentation] Ping to the expected destination ip.
453 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
454 Write Commands Until Prompt exit
455 Should Contain ${output} 200
458 [Documentation] Exit the vm instance.
459 ${output}= Write Commands Until Prompt And Log exit
461 Check If Console Is VmInstance
462 [Arguments] ${console}=cirros
463 [Documentation] Check if the session has been able to login to the VM instance
464 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
465 Should Contain ${output} ${console}
468 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
469 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
470 Run Keyword If ${rcode} Write Commands Until Prompt exit
474 [Arguments] ${ip_address} ${ttl}=64
475 [Documentation] Run Ping command on the IP available as argument
476 ${ethertype}= Get Regexp Matches ${ip_address} ${IP_REGEX}
477 ${output}= Run Keyword If ${ethertype} Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
478 ... ELSE Write Commands Until Expected Prompt ping6 -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
479 Should Contain ${output} 64 bytes
482 [Arguments] ${ip_address} ${ttl}=64
483 [Documentation] Run Ping command to the IP given as argument, executing 3 times and expecting NOT to see "64 bytes"
484 ${output}= Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
485 Should Not Contain ${output} 64 bytes
487 Check Metadata Access
488 [Documentation] Try curl on the Metadataurl and check if it is okay
489 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
490 Should Contain ${output} 200
492 Execute Command on VM Instance
493 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
494 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
495 ${devstack_conn_id} = Get ControlNode Connection
496 Switch Connection ${devstack_conn_id}
497 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
499 ${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:
501 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
503 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
504 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
505 [Teardown] Exit From Vm Console
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
511 [Documentation] Login to the vm instance using ssh in the network.
512 ${devstack_conn_id}= Get ControlNode Connection
513 Switch Connection ${devstack_conn_id}
515 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
516 ${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:
518 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
520 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
521 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
522 Run Keyword If ${rcode} Write Commands Until Expected Prompt route -n ${OS_SYSTEM_PROMPT}
523 Run Keyword If ${rcode} Write Commands Until Expected Prompt route -A inet6 ${OS_SYSTEM_PROMPT}
524 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
525 Run Keyword If ${rcode} Write Commands Until Expected Prompt ip -6 neigh ${OS_SYSTEM_PROMPT}
526 : FOR ${dest_ip} IN @{dest_ips}
528 \ ${string_empty}= Run Keyword And Return Status Should Be Empty ${dest_ip}
529 \ Run Keyword If ${string_empty} Continue For Loop
530 \ Run Keyword If ${rcode} and "${ping_should_succeed}" == "True" Check Ping ${dest_ip} ttl=${ttl}
531 \ ... ELSE Check No Ping ${dest_ip} ttl=${ttl}
532 ${ethertype}= Get Regexp Matches ${src_ip} ${IP_REGEX}
533 Run Keyword If ${rcode} and "${check_metadata}" and ${ethertype} == "True" Check Metadata Access
534 [Teardown] Exit From Vm Console
536 Test Netcat Operations From Vm Instance
537 [Arguments] ${net_name} ${vm_ip} ${dest_ip} ${additional_args}=${EMPTY} ${port}=12345 ${user}=cirros
538 ... ${password}=cubswin:)
539 [Documentation] Use Netcat to test TCP/UDP connections to the controller
540 ${client_data} Set Variable Test Client Data
541 ${server_data} Set Variable Test Server Data
542 ${devstack_conn_id}= Get ControlNode Connection
543 Switch Connection ${devstack_conn_id}
545 ${output}= Write Commands Until Prompt And Log ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
546 ${output}= Write Commands Until Prompt And Log sudo netstat -nlap | grep ${port}
547 ${nc_output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo echo "${client_data}" | nc -v -w 5 ${additional_args} ${dest_ip} ${port}
549 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo route -n
551 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo arp -an
553 Should Match Regexp ${nc_output} ${server_data}
556 [Arguments] ${list_of_external_dst_ips}
557 [Documentation] Check reachability with other network's instances.
558 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
559 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
561 \ Check Ping ${dest_ip}
564 [Arguments] ${router_name}
565 [Documentation] Create Router and Add Interface to the subnets.
566 ${rc} ${output}= Run And Return Rc And Output openstack router create ${router_name}
567 Should Not Be True ${rc}
570 [Documentation] List Router and return output with neutron client.
571 ${rc} ${output}= Run And Return Rc And Output openstack router list -f value
573 Should Not Be True ${rc}
577 [Arguments] ${router_name} ${interface_name}
578 ${rc} ${output}= Run And Return Rc And Output openstack router add subnet ${router_name} ${interface_name}
579 Should Not Be True ${rc}
581 Show Router Interface
582 [Arguments] ${router_name}
583 [Documentation] List Router interface associated with given Router and return output with neutron client.
584 ${rc} ${output}= Run And Return Rc And Output openstack port list --router ${router_name} -f value
585 Should Not Be True ${rc}
589 [Arguments] ${router_name} ${external_network_name}
590 ${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}
591 ${rc} ${output}= Run And Return Rc And Output ${cmd}
592 Should Not Be True ${rc}
595 [Arguments] ${router_name} ${interface_name}
596 [Documentation] Remove Interface to the subnets.
597 ${rc} ${output}= Run And Return Rc And Output openstack router remove subnet ${router_name} ${interface_name}
598 Should Not Be True ${rc}
601 [Arguments] ${router_name} ${cmd}
602 [Documentation] Update the router with the command. Router name and command should be passed as argument.
603 ${rc} ${output} = Run And Return Rc And Output openstack router set ${router_name} ${cmd}
604 Should Not Be True ${rc}
607 [Arguments] ${router_name} ${options}
608 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
609 ${rc} ${output} = Run And Return Rc And Output openstack router show ${router_name}
613 [Arguments] ${router_name}
614 [Documentation] Delete Router and Interface to the subnets.
615 ${rc} ${output}= Run And Return Rc And Output openstack router delete ${router_name}
616 Should Not Be True ${rc}
618 Get DumpFlows And Ovsconfig
619 [Arguments] ${openstack_node_ip}
620 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
621 Log ${openstack_node_ip}
622 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
623 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
624 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
625 Write Commands Until Expected Prompt ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
626 Write Commands Until Expected Prompt ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
627 Write Commands Until Expected Prompt ip route ${DEFAULT_LINUX_PROMPT_STRICT}
628 Write Commands Until Expected Prompt arp -an ${DEFAULT_LINUX_PROMPT_STRICT}
629 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ${DEFAULT_LINUX_PROMPT_STRICT}
630 @{lines} Split To Lines ${nslist} end=-1
631 : FOR ${line} IN @{lines}
632 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
633 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
634 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT}
635 Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
636 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
637 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
638 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
639 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
640 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
642 Get Karaf Log Type From Test Start
643 [Arguments] ${ip} ${test_name} ${type} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
644 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
645 ${cmd} Set Variable sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
646 ${output} Run Command On Controller ${ip} ${cmd} ${user} ${password} ${prompt}
649 Get Karaf Log Types From Test Start
650 [Arguments] ${ip} ${test_name} ${types} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
651 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
652 : FOR ${type} IN @{types}
653 \ Get Karaf Log Type From Test Start ${ip} ${test_name} ${type} ${user} ${password}
654 \ ... ${prompt} ${log_file}
656 Get Karaf Log Events From Test Start
657 [Arguments] ${test_name} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
658 ${log_types} = Create List ERROR WARN Exception
659 Run Keyword If 0 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_IP} ${test_name} ${log_types}
660 Run Keyword If 1 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_2_IP} ${test_name} ${log_types}
661 Run Keyword If 2 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_3_IP} ${test_name} ${log_types}
663 Get ControlNode Connection
664 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
665 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
666 SSHLibrary.Set Client Configuration timeout=30s
667 [Return] ${control_conn_id}
670 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
671 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
672 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
673 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
675 Get Test Teardown Debugs
676 [Arguments] ${test_name}=${TEST_NAME}
678 Run Keyword And Ignore Error Get Model Dump ${HA_PROXY_IP} ${netvirt_data_models}
679 Get Karaf Log Events From Test Start ${test_name}
681 Get Test Teardown Debugs For SFC
682 [Arguments] ${test_name}=${TEST_NAME}
683 Run Keyword And Ignore Error Get Model Dump ${HA_PROXY_IP} ${netvirt_sfc_data_models}
686 [Arguments] @{vm_indices}
687 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
688 ${devstack_conn_id}= Get ControlNode Connection
689 Switch Connection ${devstack_conn_id}
690 ${output}= Write Commands Until Prompt And Log sudo ip netns list
692 : FOR ${index} IN @{vm_indices}
693 \ ${rc} ${output}= Run And Return Rc And Output nova show ${index}
700 Neutron Security Group Show
701 [Arguments] ${SecurityGroupRuleName}
702 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
703 ${rc} ${output}= Run And Return Rc And Output openstack security group show ${SecurityGroupRuleName}
705 Should Not Be True ${rc}
709 [Arguments] ${PortName}
710 [Documentation] Display the port configuration that belong to a given neutron port
711 ${rc} ${output}= Run And Return Rc And Output openstack port show ${PortName}
713 Should Not Be True ${rc}
716 Neutron Security Group Create
717 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
718 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
719 ${devstack_conn_id}= Get ControlNode Connection
720 Switch Connection ${devstack_conn_id}
721 ${rc} ${output}= Run And Return Rc And Output openstack security group create ${SecurityGroupName} ${additional_args}
723 Should Not Be True ${rc}
724 ${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}
726 [Return] ${output} ${sgp_id}
728 Neutron Security Group Update
729 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
730 [Documentation] Updating security groups
731 ${rc} ${output}= Run And Return Rc And Output openstack security group set ${SecurityGroupName} ${additional_args}
733 Should Not Be True ${rc}
737 [Arguments] ${sg_name}
738 [Documentation] Delete Security group
739 ${rc} ${output}= Run And Return Rc And Output openstack security group delete ${sg_name}
741 Should Not Be True ${rc}
743 Neutron Security Group Rule Create
744 [Arguments] ${Security_group_name} &{Kwargs}
745 [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]} ..."
746 Run Keyword If ${Kwargs} Log ${Kwargs}
747 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
748 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
749 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
750 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
751 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
752 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
753 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
754 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
755 ${cmd}= Set Variable openstack security group rule create ${Security_group_name}
756 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
757 ... ELSE Catenate ${cmd}
758 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --${direction}
759 ... ELSE Catenate ${cmd}
760 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
761 ... ELSE Catenate ${cmd}
762 ${cmd}= Run Keyword If '${port_range_min}'!='None' and '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_min}:${port_range_max}
763 ... ELSE IF '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_max}
764 ... ELSE IF '${port_range_min}'!='None' Catenate ${cmd} --dst-port ${port_range_min}
765 ... ELSE Catenate ${cmd}
766 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
767 ... ELSE Catenate ${cmd}
768 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote-group ${remote_group_id}
769 ... ELSE Catenate ${cmd}
770 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --src-ip ${remote_ip_prefix}
771 ... ELSE Catenate ${cmd}
772 ${rc} ${output}= Run And Return Rc And Output ${cmd}
773 ${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}
775 Should Not Be True ${rc}
776 [Return] ${output} ${rule_id}
778 Neutron Security Group Rule Create Legacy Cli
779 [Arguments] ${Security_group_name} &{Kwargs}
780 [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]} ..."
781 Run Keyword If ${Kwargs} Log ${Kwargs}
782 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
783 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
784 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
785 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
786 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
787 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
788 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
789 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
790 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
791 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
792 ... ELSE Catenate ${cmd}
793 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
794 ... ELSE Catenate ${cmd}
795 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
796 ... ELSE Catenate ${cmd}
797 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
798 ... ELSE Catenate ${cmd}
799 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
800 ... ELSE Catenate ${cmd}
801 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
802 ... ELSE Catenate ${cmd}
803 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
804 ... ELSE Catenate ${cmd}
805 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
806 ... ELSE Catenate ${cmd}
807 ${rc} ${output}= Run And Return Rc And Output ${cmd}
808 ${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}
810 Should Not Be True ${rc}
811 [Return] ${output} ${rule_id}
813 Security Group Create Without Default Security Rules
814 [Arguments] ${sg_name} ${additional_args}=${EMPTY}
815 [Documentation] Create Neutron Security Group with no default rules, using specified name and optional arguments.
816 Neutron Security Group Create ${sg_name} ${additional_args}
817 Delete All Security Group Rules ${sg_name}
819 Delete All Security Group Rules
820 [Arguments] ${sg_name}
821 [Documentation] Delete all security rules from a specified security group
822 ${rc} ${sg_rules_output}= Run And Return Rc And Output openstack security group rule list ${sg_name} -cID -fvalue
823 Log ${sg_rules_output}
824 Should Not Be True ${rc}
825 @{sg_rules}= Split String ${sg_rules_output} \n
826 : FOR ${rule} IN @{sg_rules}
827 \ ${rc} ${output}= Run And Return Rc And Output openstack security group rule delete ${rule}
829 \ Should Not Be True ${rc}
831 Create Allow All SecurityGroup
832 [Arguments] ${sg_name} ${ether_type}=IPv4
833 [Documentation] Allow all TCP/UDP/ICMP packets for this suite
834 Neutron Security Group Create ${sg_name}
835 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
836 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
837 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} protocol=icmp
838 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} protocol=icmp
839 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
840 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
842 Create Neutron Port With Additional Params
843 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
844 [Documentation] Create Port With given additional parameters
845 ${rc} ${output}= Run And Return Rc And Output neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
847 Should Not Be True ${rc}
848 ${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}
850 [Return] ${OUTPUT} ${port_id}
853 [Arguments] ${portName_list}
854 [Documentation] Retrieve the port MacAddr for the given list of port name and return the MAC address list.
855 ${MacAddr-list} Create List
856 : FOR ${portName} IN @{portName_list}
857 \ ${macAddr}= OpenStackOperations.Get Port Mac ${portName} ${devstack_conn_id}
858 \ Append To List ${MacAddr-list} ${macAddr}
859 [Return] ${MacAddr-list}
862 [Arguments] ${port_name}
863 [Documentation] Keyword would return the IP of the ${port_name} received.
864 ${rc} ${output}= Run And Return Rc And Output openstack port list | grep "${port_name}" | awk -F\\' '{print $2}'
865 ${splitted_output}= Split String ${output} ${EMPTY}
866 ${port_ip}= Get from List ${splitted_output} 0
867 Should Not Be True ${rc}
871 [Arguments] ${port_name} ${conn_id}=${devstack_conn_id}
872 [Documentation] Keyword would return the MAC ID of the ${port_name} received.
873 ${rc} ${output}= Run And Return Rc And Output openstack port show ${port_name} | grep mac_address | awk '{print $4}'
874 ${splitted_output}= Split String ${output} ${EMPTY}
875 ${port_mac}= Get from List ${splitted_output} 0
876 Should Not Be True ${rc}
880 [Arguments] ${bridge_name} ${intf_name} ${gw_name}
881 [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
882 ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name}
884 [Return] ${l2gw_output}
886 Create L2Gateway Connection
887 [Arguments] ${gw_name} ${net_name}
888 [Documentation] Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
889 ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_CONN_CREATE} ${gw_name} ${net_name}
891 Should Not Be True ${rc}
892 [Return] ${l2gw_output}
895 [Documentation] Keyword to return all the L2 Gateways available (Using Neutron CLI).
896 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_YAML}
897 Should Not Be True ${rc}
900 Get All L2Gateway Connection
901 [Documentation] Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
902 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_CONN_YAML}
903 Should Not Be True ${rc}
908 [Documentation] Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
909 ${rc} ${output}= Run And Return Rc And Output ${L2GW_SHOW} ${gw_id}
911 Should Not Be True ${rc}
915 [Arguments] ${l2gw_name}
916 [Documentation] Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
917 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}'
919 Should Not Be True ${rc}
920 ${splitted_output}= Split String ${output} ${EMPTY}
921 ${l2gw_id}= Get from List ${splitted_output} 0
924 Get L2gw Connection Id
925 [Arguments] ${l2gw_name}
926 [Documentation] Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
927 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${l2gw_name}
928 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}'
929 Should Not Be True ${rc}
930 ${splitted_output}= Split String ${output} ${EMPTY}
931 ${splitted_output}= Split String ${output} ${EMPTY}
932 ${l2gw_conn_id}= Get from List ${splitted_output} 0
933 [Return] ${l2gw_conn_id}
935 Neutron Port List Rest
936 [Documentation] Keyword to get all ports details in Neutron (Using REST).
937 ${resp} = RequestsLibrary.Get Request session ${PORT_URL}
939 Should Be Equal As Strings ${resp.status_code} 200
940 [Return] ${resp.content}
942 Get Neutron Port Rest
943 [Arguments] ${port_id}
944 [Documentation] Keyword to get the specific port details in Neutron (Using REST).
945 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id}
947 Should Be Equal As Strings ${resp.status_code} 200
948 [Return] ${resp.content}
951 [Arguments] ${port_id} ${json_data}
952 [Documentation] Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
954 ${resp} = RequestsLibrary.Put Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id} ${json_data}
956 Should Be Equal As Strings ${resp.status_code} 200
957 [Return] ${resp.content}
959 Create And Configure Security Group
960 [Arguments] ${sg-name}
961 [Documentation] Create Security Group with given name, and default allow rules for TCP/UDP/ICMP protocols.
962 Neutron Security Group Create ${sg-name}
963 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
964 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
965 Neutron Security Group Rule Create ${sg-name} direction=ingress protocol=icmp remote_ip_prefix=0.0.0.0/0
966 Neutron Security Group Rule Create ${sg-name} direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0
967 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
968 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
970 Add Security Group To VM
971 [Arguments] ${vm} ${sg}
972 [Documentation] Add the security group provided to the given VM.
973 ${rc} ${output}= Run And Return Rc And Output openstack server add security group ${vm} ${sg}
975 Should Not Be True ${rc}
977 Remove Security Group From VM
978 [Arguments] ${vm} ${sg}
979 [Documentation] Remove the security group provided to the given VM.
980 ${devstack_conn_id}= Get ControlNode Connection
981 Switch Connection ${devstack_conn_id}
982 ${output}= Write Commands Until Prompt And Log openstack server remove security group ${vm} ${sg}
985 Create SFC Flow Classifier
986 [Arguments] ${name} ${src_ip} ${dest_ip} ${protocol} ${dest_port} ${neutron_src_port}
987 [Documentation] Create a flow classifier for SFC
988 ${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}
990 Should Not Be True ${rc}
991 Should Contain ${output} ${name}
994 Delete SFC Flow Classifier
996 [Documentation] Delete a SFC flow classifier
997 ${devstack_conn_id}= Get ControlNode Connection
998 Switch Connection ${devstack_conn_id}
999 ${rc} ${output}= Run And Return Rc And Output openstack sfc flow classifier delete ${name}
1001 Should Not Be True ${rc}
1004 Create SFC Port Pair
1005 [Arguments] ${name} ${port_in} ${port_out}
1006 [Documentation] Creates a neutron port pair for SFC
1007 ${devstack_conn_id}= Get ControlNode Connection
1008 Switch Connection ${devstack_conn_id}
1009 ${rc} ${output}= Run And Return Rc And Output openstack sfc port pair create --ingress=${port_in} --egress=${port_out} ${name}
1011 Should Not Be True ${rc}
1012 Should Contain ${output} ${name}
1015 Delete SFC Port Pair
1017 [Documentation] Delete a SFC port pair
1018 ${rc} ${output}= Run And Return Rc And Output openstack sfc port pair delete ${name}
1020 Should Not Be True ${rc}
1023 Create SFC Port Pair Group
1024 [Arguments] ${name} ${port_pair}
1025 [Documentation] Creates a port pair group with a single port pair for SFC
1026 ${rc} ${output}= Run And Return Rc And Output openstack sfc port pair group create --port-pair ${port_pair} ${name}
1028 Should Not Be True ${rc}
1029 Should Contain ${output} ${name}
1032 Create SFC Port Pair Group With Two Pairs
1033 [Arguments] ${name} ${port_pair1} ${port_pair2}
1034 [Documentation] Creates a port pair group with two port pairs for SFC
1035 ${rc} ${output}= Run And Return Rc And Output openstack sfc port pair group create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name}
1037 Should Not Be True ${rc}
1038 Should Contain ${output} ${name}
1041 Delete SFC Port Pair Group
1043 [Documentation] Delete a SFC port pair group
1044 ${devstack_conn_id}= Get ControlNode Connection
1045 ${rc} ${output}= Run And Return Rc And Output openstack sfc port pair group delete ${name}
1047 Should Not Be True ${rc}
1050 Create SFC Port Chain
1051 [Arguments] ${name} ${pg1} ${pg2} ${fc}
1052 [Documentation] Creates a port pair chain with two port groups and a singel classifier.
1053 ${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}
1055 Should Not Be True ${rc}
1056 Should Contain ${output} ${name}
1059 Delete SFC Port Chain
1061 [Documentation] Delete a SFC port chain
1062 ${rc} ${output}= Run And Return Rc And Output openstack sfc port chain delete ${name}
1064 Should Not Be True ${rc}
1068 [Arguments] ${vm_name}
1069 [Documentation] Reboot NOVA VM
1070 ${rc} ${output}= Run And Return Rc And Output openstack server reboot --wait ${vm_name}
1072 Should Not Be True ${rc}
1073 Wait Until Keyword Succeeds 35s 10s Verify VM Is ACTIVE ${vm_name}
1075 Remove RSA Key From KnowHosts
1076 [Arguments] ${vm_ip}
1077 [Documentation] Remove RSA
1078 ${devstack_conn_id}= Get ControlNode Connection
1079 Switch Connection ${devstack_conn_id}
1080 ${output}= Write Commands Until Prompt And Log sudo cat /root/.ssh/known_hosts 30s
1081 ${output}= Write Commands Until Prompt And Log sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ${vm_ip} 30s
1082 ${output}= Write Commands Until Prompt sudo cat "/root/.ssh/known_hosts" 30s
1084 Wait For Routes To Propogate
1085 [Arguments] ${networks} ${subnets}
1086 [Documentation] Check propagated routes
1087 ${devstack_conn_id} = Get ControlNode Connection
1088 Switch Connection ${devstack_conn_id}
1089 : FOR ${INDEX} IN RANGE 0 1
1090 \ ${net_id}= Get Net Id @{networks}[${INDEX}] ${devstack_conn_id}
1091 \ ${is_ipv6}= Get Regexp Matches @{subnets}[${INDEX}] ${IP6_REGEX}
1092 \ ${length}= Get Length ${is_ipv6}
1093 \ ${cmd}= Set Variable If ${length} == 0 ip route ip -6 route
1094 \ ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ${cmd} ]>
1095 \ Should Contain ${output} @{subnets}[${INDEX}]