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}'
19 Should Not Be True ${rc}
22 Get Tenant ID From Network
23 [Arguments] ${network_uuid}
24 [Documentation] Returns tenant ID by reading it from existing network.
25 ${resp}= Get_From_Uri uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/ accept=${ACCEPT_EMPTY} session=session
26 ${tenant_id}= Utils.Extract Value From Content ${resp} /network/0/tenant-id strip
30 [Arguments] ${network_name} ${additional_args}=${EMPTY} ${verbose}=TRUE
31 [Documentation] Create Network with neutron request.
32 ${rc} ${output}= Run And Return Rc And Output openstack network create ${network_name} ${additional_args}
34 Should Not Be True ${rc}
38 [Arguments] ${network_name} ${additional_args}=${EMPTY}
39 [Documentation] Update Network with neutron request.
40 ${cmd}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v net-update ${network_name} ${additional_args} openstack network set ${network_name} ${additional_args}
41 ${rc} ${output}= Run And Return Rc And Output ${cmd}
43 Should Not Be True ${rc}
47 [Arguments] ${network_name}
48 [Documentation] Show Network with neutron request.
49 ${rc} ${output}= Run And Return Rc And Output openstack network show ${network_name}
51 Should Not Be True ${rc}
55 [Documentation] List networks and return output with neutron client.
56 ${rc} ${output}= Run And Return Rc And Output openstack network list
58 Should Not Be True ${rc}
62 [Documentation] List subnets and return output with neutron client.
63 ${rc} ${output}= Run And Return Rc And Output openstack subnet list
65 Should Not Be True ${rc}
69 [Arguments] ${network_name}
70 [Documentation] Delete Network with neutron request.
71 ${rc} ${output}= Run And Return Rc And Output openstack network delete ${network_name}
73 Should Not Be True ${rc}
76 [Arguments] ${network_name} ${subnet} ${range_ip} ${additional_args}=${EMPTY}
77 [Documentation] Create SubNet for the Network with neutron request.
78 ${rc} ${output}= Run And Return Rc And Output openstack subnet create --network ${network_name} --subnet-range ${range_ip} ${subnet} ${additional_args}
80 Should Not Be True ${rc}
83 [Arguments] ${subnet_name} ${additional_args}=${EMPTY}
84 [Documentation] Update subnet with neutron request.
85 ${cmd}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v subnet-update ${subnet_name} ${additional_args} openstack subnet set ${subnet_name} ${additional_args}
86 ${rc} ${output}= Run And Return Rc And Output ${cmd}
88 Should Not Be True ${rc}
92 [Arguments] ${subnet_name}
93 [Documentation] Show subnet with neutron request.
94 ${rc} ${output}= Run And Return Rc And Output openstack subnet show ${subnet_name}
96 Should Not Be True ${rc}
100 [Arguments] ${network_name} ${port_name} ${sg}=default ${additional_args}=${EMPTY} ${allowed_address_pairs}=${EMPTY}
101 [Documentation] Create Port with neutron request.
102 # if allowed_address_pairs is not empty we need to create the arguments to pass to the port create command. They are
103 # in a different format with the neutron vs openstack cli.
104 ${address_pair_length}= Get Length ${allowed_address_pairs}
105 ${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]
106 ${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}
107 ${allowed_pairs_argv}= Set Variable If '${address_pair_length}'=='0' ${EMPTY} ${allowed_pairs_argv}
108 ${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}
109 ${rc} ${output}= Run And Return Rc And Output ${cmd}
111 Should Not Be True ${rc}
114 [Arguments] ${port_name} ${additional_args}=${EMPTY}
115 [Documentation] Update port with neutron request.
116 ${rc} ${output}= Run And Return Rc And Output openstack port set ${port_name} ${additional_args}
118 Should Not Be True ${rc}
122 [Arguments] ${port_name}
123 [Documentation] Show port with neutron request.
124 ${rc} ${output}= Run And Return Rc And Output openstack port show ${port_name}
126 Should Not Be True ${rc}
130 [Arguments] ${port_name}
131 [Documentation] Delete Port with neutron request.
132 ${rc} ${output}= Run And Return Rc And Output openstack port delete ${port_name}
134 Should Not Be True ${rc}
137 [Documentation] List ports and return output with neutron client.
138 ${rc} ${output}= Run And Return Rc And Output openstack port list
140 Should Not Be True ${rc}
144 [Documentation] List VMs and return output with nova client.
145 ${rc} ${output}= Run And Return Rc And Output openstack server list
147 Should Not Be True ${rc}
150 Create And Associate Floating IPs
151 [Arguments] ${external_net} @{vm_list}
152 [Documentation] Create and associate floating IPs to VMs with nova request
153 ${ip_list}= Create List @{EMPTY}
154 : FOR ${vm} IN @{vm_list}
155 \ ${rc} ${output}= Run And Return Rc And Output openstack floating ip create ${external_net}
157 \ Should Not Be True ${rc}
158 \ @{ip} Get Regexp Matches ${output} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
159 \ ${ip_length} Get Length ${ip}
160 \ Run Keyword If ${ip_length}>0 Append To List ${ip_list} @{ip}[0]
161 \ ... ELSE Append To List ${ip_list} None
162 \ ${rc} ${output}= Run And Return Rc And Output openstack server add floating ip ${vm} @{ip}[0]
164 \ Should Not Be True ${rc}
168 [Documentation] Verifies the Gateway Ips with dump flow.
169 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
171 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
172 \ Should Contain ${output} ${GatewayIpElement}
175 [Documentation] Verifies the Dhcp Ips with dump flow.
176 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
178 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
179 \ Should Contain ${output} ${DhcpIpElement}
182 [Documentation] Verifies the Dhcp Ips with dump flow.
183 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
185 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
186 \ Should Not Contain ${output} ${DhcpIpElement}
189 [Arguments] ${subnet}
190 [Documentation] Delete SubNet for the Network with neutron request.
192 ${rc} ${output}= Run And Return Rc And Output openstack subnet delete ${subnet}
194 Should Not Be True ${rc}
196 Verify No Gateway Ips
197 [Documentation] Verifies the Gateway Ips removed with dump flow.
198 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
200 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
201 \ Should Not Contain ${output} ${GatewayIpElement}
204 [Arguments] ${vm_name}
205 [Documentation] Delete Vm instances using instance names.
206 ${rc} ${output}= Run And Return Rc And Output openstack server delete ${vm_name}
211 [Arguments] ${network_name} ${devstack_conn_id}
212 [Documentation] Retrieve the net id for the given network name to create specific vm instance
213 ${rc} ${output}= Run And Return Rc And Output openstack network list | grep "${network_name}" | awk '{print $2}'
215 Should Not Be True ${rc}
216 ${splitted_output}= Split String ${output} ${EMPTY}
217 ${net_id}= Get from List ${splitted_output} 0
222 [Arguments] ${subnet_name} ${devstack_conn_id}
223 [Documentation] Retrieve the subnet id for the given subnet name
224 ${rc} ${output}= Run And Return Rc And Output openstack subnet show "${subnet_name}" | grep " id " | awk '{print $4}'
226 Should Not Be True ${rc}
227 ${splitted_output}= Split String ${output} ${EMPTY}
228 ${subnet_id}= Get from List ${splitted_output} 0
230 [Return] ${subnet_id}
233 [Arguments] ${port_name} ${devstack_conn_id}
234 [Documentation] Retrieve the port id for the given port name to attach specific vm instance to a particular port
235 ${rc} ${output}= Run And Return Rc And Output openstack port list | grep "${port_name}" | awk '{print $2}'
237 Should Not Be True ${rc}
238 ${splitted_output}= Split String ${output} ${EMPTY}
239 ${port_id}= Get from List ${splitted_output} 0
244 [Arguments] ${router1} ${devstack_conn_id}
245 [Documentation] Retrieve the router id for the given router name
246 ${rc} ${output}= Run And Return Rc And Output openstack router list -f table | grep "${router1}" | awk '{print $2}'
248 Should Not Be True ${rc}
249 ${splitted_output}= Split String ${output} ${EMPTY}
250 ${router_id}= Get from List ${splitted_output} 0
252 [Return] ${router_id}
255 [Arguments] ${net_name} ${vm_instance_names} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default ${min}=1
257 [Documentation] Create X Vm Instance with the net id of the Netowrk.
258 ${image} Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
259 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
260 : FOR ${VmElement} IN @{vm_instance_names}
261 \ ${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}
262 \ Should Not Be True ${rc}
265 Create Vm Instance With Port
266 [Arguments] ${port_name} ${vm_instance_name} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
267 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
268 ${image} Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
269 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
270 ${rc} ${output}= Run And Return Rc And Output openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-groups ${sg}
273 Create Vm Instance With Ports
274 [Arguments] ${port_name} ${port2_name} ${vm_instance_name} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
275 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
276 ${image} Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
277 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
278 ${port2_id}= Get Port Id ${port2_name} ${devstack_conn_id}
279 ${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}
281 Should Not Be True ${rc}
283 Create Vm Instance With Port On Compute Node
284 [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default
285 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
286 ${image} Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image}
287 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
288 ${hostname_compute_node}= Run Command On Remote System ${compute_node} hostname
289 ${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}
291 Should Not Be True ${rc}
294 [Documentation] Create a nano flavor
295 ${rc} ${output}= Run And Return Rc And Output openstack flavor create m1.nano --id auto --ram 64 --disk 0 --vcpus 1
297 Should Not Be True ${rc}
300 [Arguments] ${vm_name}
301 [Documentation] Run these commands to check whether the created vm instance is active or not.
302 ${rc} ${output}= Run And Return Rc And Output openstack server show ${vm_name} | grep OS-EXT-STS:vm_state
304 Should Not Be True ${rc}
305 Should Contain ${output} active
308 [Arguments] ${vm_name} ${retry}=600s ${retry_interval}=5s
309 [Documentation] Run these commands to check whether the created vm instance is active or not.
310 Wait Until Keyword Succeeds ${retry} ${retry_interval} Verify VM Is ACTIVE ${vm_name}
312 Collect VM IP Addresses
313 [Arguments] ${fail_on_none} @{vm_list}
314 [Documentation] Using nova console-log on the provided ${vm_list} to search for the string "obtained" which
315 ... correlates to the instance receiving it's IP address via DHCP. Also retrieved is the ip of the nameserver
316 ... if available in the console-log output. The keyword will also return a list of the learned ips as it
317 ... finds them in the console log output, and will have "None" for Vms that no ip was found.
318 ${ip_list} Create List @{EMPTY}
319 : FOR ${vm} IN @{vm_list}
320 \ ${rc} ${vm_ip_line}= Run And Return Rc And Output openstack console log show ${vm} | grep -i "obtained"
323 \ @{vm_ip} Get Regexp Matches ${vm_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
324 \ ${vm_ip_length} Get Length ${vm_ip}
325 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip}[0]
326 \ ... ELSE Append To List ${ip_list} None
327 \ ${rc} ${dhcp_ip_line}= Run And Return Rc And Output openstack console log show ${vm} | grep "^nameserver"
328 \ Log ${dhcp_ip_line}
330 \ ${dhcp_ip} Get Regexp Matches ${dhcp_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
331 \ ${dhcp_ip_length} Get Length ${dhcp_ip}
332 \ Run Keyword If ${dhcp_ip_length}<=0 Append To List ${dhcp_ip} None
334 \ ${vm_console_output}= Run openstack console log show ${vm}
335 \ Log ${vm_console_output}
336 ${dhcp_length} Get Length ${dhcp_ip}
337 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${ip_list} None
338 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${dhcp_ip} None
339 Should Be True ${dhcp_length} <= 1
340 Return From Keyword If ${dhcp_length}==0 ${ip_list} ${EMPTY}
341 [Return] ${ip_list} ${dhcp_ip}
343 Collect VM IPv6 SLAAC Addresses
344 [Arguments] ${fail_on_none} ${prefix} @{vm_list}
345 [Documentation] Using nova console-log on the provided ${vm_list} to search for the string "inet6" which
346 ... correlates to the instance generated IPv6 address, based on the ${prefix} received from ODL (SLAAC mode).
347 ${ip_list} Create List @{EMPTY}
348 : FOR ${vm} IN @{vm_list}
350 \ ${rc} ${vm_ip_line}= Run And Return Rc And Output nova console-log ${vm} | grep -i "inet6"
353 \ @{vm_ip_list} Get Regexp Matches ${vm_ip_line} ${prefix}
354 \ ${vm_ip_length} Get Length ${vm_ip_list}
355 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip_list}[0]
356 \ ... ELSE Append To List ${ip_list} None
358 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${ip_list} None
363 [Arguments] ${vm_instance_names}
364 [Documentation] View Console log of the created vm instances using nova show.
365 : FOR ${VmElement} IN @{vm_instance_names}
366 \ ${rc} ${output}= Run And Return Rc And Output nova show ${VmElement}
368 \ Should Not Be True ${rc}
369 \ ${rc} ${output}= Run And Return Rc And Output openstack console log show ${VmElement}
371 \ Should Not Be True ${rc}
373 Ping Vm From DHCP Namespace
374 [Arguments] ${net_name} ${vm_ip}
375 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
377 ${devstack_conn_id}= Get ControlNode Connection
378 Switch Connection ${devstack_conn_id}
379 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
381 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
384 Should Contain ${output} 64 bytes
386 Ping From DHCP Should Not Succeed
387 [Arguments] ${net_name} ${vm_ip}
388 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
389 Return From Keyword If "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
391 ${devstack_conn_id}= Get ControlNode Connection
392 Switch Connection ${devstack_conn_id}
393 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
395 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
398 Should Not Contain ${output} 64 bytes
400 Ping Vm From Control Node
401 [Arguments] ${vm_floating_ip} ${additional_args}=${EMPTY}
402 [Documentation] Ping VM floating IP from control node
403 Log ${vm_floating_ip}
404 ${devstack_conn_id}= Get ControlNode Connection
405 Switch Connection ${devstack_conn_id}
406 ${output}= Write Commands Until Prompt ping ${additional_args} -c 3 ${vm_floating_ip} 20s
409 Should Contain ${output} 64 bytes
412 [Arguments] ${dest_vm_ip}
413 [Documentation] Ping to the expected destination ip.
414 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm_ip} ${OS_SYSTEM_PROMPT}
419 [Documentation] Ping to the expected destination ip.
420 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
421 Write Commands Until Prompt exit
422 Should Contain ${output} 200
425 [Documentation] Exit the vm instance.
426 ${output}= Write Commands Until Prompt exit
429 Check If Console Is VmInstance
430 [Arguments] ${console}=cirros
431 [Documentation] Check if the session has been able to login to the VM instance
432 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
433 Should Contain ${output} ${console}
436 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
437 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
438 Run Keyword If ${rcode} Write Commands Until Prompt exit
442 [Arguments] ${ip_address} ${ttl}=64
443 [Documentation] Run Ping command on the IP available as argument
444 ${ethertype}= Get Regexp Matches ${ip_address} ${IP_REGEX}
445 ${output}= Run Keyword If ${ethertype} Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
446 ... ELSE Write Commands Until Expected Prompt ping6 -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
447 Should Contain ${output} 64 bytes
450 [Arguments] ${ip_address} ${ttl}=64
451 [Documentation] Run Ping command to the IP given as argument, executing 3 times and expecting NOT to see "64 bytes"
452 ${output}= Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
453 Should Not Contain ${output} 64 bytes
455 Check Metadata Access
456 [Documentation] Try curl on the Metadataurl and check if it is okay
457 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
458 Should Contain ${output} 200
460 Execute Command on VM Instance
461 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
462 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
463 ${devstack_conn_id} = Get ControlNode Connection
464 Switch Connection ${devstack_conn_id}
465 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
467 ${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:
469 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
471 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
472 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
473 [Teardown] Exit From Vm Console
476 Test Operations From Vm Instance
477 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:) ${ttl}=64
478 ... ${ping_should_succeed}=True ${check_metadata}=True
479 [Documentation] Login to the vm instance using ssh in the network.
480 ${devstack_conn_id}= Get ControlNode Connection
481 Switch Connection ${devstack_conn_id}
483 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
484 ${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:
486 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
488 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
489 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
490 Run Keyword If ${rcode} Write Commands Until Expected Prompt route -n ${OS_SYSTEM_PROMPT}
491 Run Keyword If ${rcode} Write Commands Until Expected Prompt route -A inet6 ${OS_SYSTEM_PROMPT}
492 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
493 Run Keyword If ${rcode} Write Commands Until Expected Prompt ip -6 neigh ${OS_SYSTEM_PROMPT}
494 : FOR ${dest_ip} IN @{dest_ips}
496 \ ${string_empty}= Run Keyword And Return Status Should Be Empty ${dest_ip}
497 \ Run Keyword If ${string_empty} Continue For Loop
498 \ Run Keyword If ${rcode} and "${ping_should_succeed}" == "True" Check Ping ${dest_ip} ttl=${ttl}
499 \ ... ELSE Check No Ping ${dest_ip} ttl=${ttl}
500 ${ethertype}= Get Regexp Matches ${src_ip} ${IP_REGEX}
501 Run Keyword If ${rcode} and "${check_metadata}" and ${ethertype} == "True" Check Metadata Access
502 [Teardown] Exit From Vm Console
504 Test Netcat Operations From Vm Instance
505 [Arguments] ${net_name} ${vm_ip} ${dest_ip} ${additional_args}=${EMPTY} ${port}=12345 ${user}=cirros
506 ... ${password}=cubswin:)
507 [Documentation] Use Netcat to test TCP/UDP connections to the controller
508 ${client_data} Set Variable Test Client Data
509 ${server_data} Set Variable Test Server Data
510 ${devstack_conn_id}= Get ControlNode Connection
511 Switch Connection ${devstack_conn_id}
513 ${output}= Write Commands Until Prompt ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
515 ${output}= Write Commands Until Prompt sudo netstat -nlap | grep ${port}
517 ${nc_output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo echo "${client_data}" | nc -v -w 5 ${additional_args} ${dest_ip} ${port}
519 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo route -n
521 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo arp -an
523 Should Match Regexp ${nc_output} ${server_data}
526 [Arguments] ${list_of_external_dst_ips}
527 [Documentation] Check reachability with other network's instances.
528 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
529 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
531 \ Check Ping ${dest_ip}
534 [Arguments] ${router_name}
535 [Documentation] Create Router and Add Interface to the subnets.
536 ${rc} ${output}= Run And Return Rc And Output openstack router create ${router_name}
537 Should Not Be True ${rc}
540 [Documentation] List Router and return output with neutron client.
541 ${rc} ${output}= Run And Return Rc And Output openstack router list -f value
543 Should Not Be True ${rc}
547 [Arguments] ${router_name} ${interface_name}
548 ${rc} ${output}= Run And Return Rc And Output openstack router add subnet ${router_name} ${interface_name}
549 Should Not Be True ${rc}
551 Show Router Interface
552 [Arguments] ${router_name}
553 [Documentation] List Router interface associated with given Router and return output with neutron client.
554 ${rc} ${output}= Run And Return Rc And Output openstack port list --router ${router_name} -f value
556 Should Not Be True ${rc}
560 [Arguments] ${router_name} ${external_network_name}
561 ${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}
562 ${rc} ${output}= Run And Return Rc And Output ${cmd}
563 Should Not Be True ${rc}
566 [Arguments] ${router_name} ${interface_name}
567 [Documentation] Remove Interface to the subnets.
568 ${rc} ${output}= Run And Return Rc And Output openstack router remove subnet ${router_name} ${interface_name}
569 Should Not Be True ${rc}
572 [Arguments] ${router_name} ${cmd}
573 [Documentation] Update the router with the command. Router name and command should be passed as argument.
574 ${rc} ${output} = Run And Return Rc And Output openstack router set ${router_name} ${cmd}
575 Should Not Be True ${rc}
578 [Arguments] ${router_name} ${options}
579 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
580 ${rc} ${output} = Run And Return Rc And Output openstack router show ${router_name}
584 [Arguments] ${router_name}
585 [Documentation] Delete Router and Interface to the subnets.
586 ${rc} ${output}= Run And Return Rc And Output openstack router delete ${router_name}
587 Should Not Be True ${rc}
589 Get DumpFlows And Ovsconfig
590 [Arguments] ${openstack_node_ip}
591 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
592 Log ${openstack_node_ip}
593 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
594 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
595 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
596 Write Commands Until Expected Prompt ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
597 Write Commands Until Expected Prompt ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
598 Write Commands Until Expected Prompt ip route ${DEFAULT_LINUX_PROMPT_STRICT}
599 Write Commands Until Expected Prompt arp -an ${DEFAULT_LINUX_PROMPT_STRICT}
600 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ${DEFAULT_LINUX_PROMPT_STRICT}
601 @{lines} Split To Lines ${nslist}
602 : FOR ${line} IN @{lines}
603 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
604 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
605 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT}
606 Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
607 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
608 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
609 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
610 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
611 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
613 Get Karaf Log Type From Test Start
614 [Arguments] ${ip} ${test_name} ${type} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
615 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
616 ${cmd} Set Variable sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
617 ${output} Run Command On Controller ${ip} ${cmd} ${user} ${password} ${prompt}
620 Get Karaf Log Types From Test Start
621 [Arguments] ${ip} ${test_name} ${types} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
622 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
623 : FOR ${type} IN @{types}
624 \ Get Karaf Log Type From Test Start ${ip} ${test_name} ${type} ${user} ${password}
625 \ ... ${prompt} ${log_file}
627 Get Karaf Log Events From Test Start
628 [Arguments] ${test_name} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
629 ${log_types} = Create List ERROR WARN Exception
630 Run Keyword If 0 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_IP} ${test_name} ${log_types}
631 Run Keyword If 1 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_2_IP} ${test_name} ${log_types}
632 Run Keyword If 2 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_3_IP} ${test_name} ${log_types}
634 Get ControlNode Connection
635 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
636 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
637 SSHLibrary.Set Client Configuration timeout=30s
638 [Return] ${control_conn_id}
641 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
642 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
643 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
644 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
646 Get Test Teardown Debugs
647 [Arguments] ${test_name}=${TEST_NAME}
649 Run Keyword And Ignore Error Get Model Dump ${HA_PROXY_IP} ${netvirt_data_models}
650 Get Karaf Log Events From Test Start ${test_name}
653 [Arguments] @{vm_indices}
654 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
655 ${devstack_conn_id}= Get ControlNode Connection
656 Switch Connection ${devstack_conn_id}
657 ${output}= Write Commands Until Prompt sudo ip netns list
660 : FOR ${index} IN @{vm_indices}
661 \ ${rc} ${output}= Run And Return Rc And Output nova show ${index}
669 Neutron Security Group Show
670 [Arguments] ${SecurityGroupRuleName}
671 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
672 ${cmd}= Set Variable openstack security group show ${SecurityGroupRuleName}
674 ${rc} ${output}= Run And Return Rc And Output ${cmd}
676 Should Not Be True ${rc}
680 [Arguments] ${PortName}
681 [Documentation] Display the port configuration that belong to a given neutron port
682 ${cmd}= Set Variable openstack port show ${PortName}
684 ${rc} ${output}= Run And Return Rc And Output ${cmd}
686 Should Not Be True ${rc}
689 Neutron Security Group Create
690 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
691 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
692 ${devstack_conn_id}= Get ControlNode Connection
693 Switch Connection ${devstack_conn_id}
694 ${cmd}= Set Variable openstack security group create ${SecurityGroupName} ${additional_args}
696 ${rc} ${output}= Run And Return Rc And Output ${cmd}
698 Should Not Be True ${rc}
699 ${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}
701 [Return] ${output} ${sgp_id}
703 Neutron Security Group Update
704 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
705 [Documentation] Updating security groups
706 ${cmd}= Set Variable openstack security group set ${SecurityGroupName} ${additional_args}
708 ${rc} ${output}= Run And Return Rc And Output ${cmd}
710 Should Not Be True ${rc}
714 [Arguments] ${sg_name}
715 [Documentation] Delete Security group
716 ${rc} ${output}= Run And Return Rc And Output openstack security group delete ${sg_name}
718 Should Not Be True ${rc}
720 Neutron Security Group Rule Create
721 [Arguments] ${Security_group_name} &{Kwargs}
722 [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]} ..."
723 Run Keyword If ${Kwargs} Log ${Kwargs}
724 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
725 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
726 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
727 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
728 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
729 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
730 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
731 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
732 ${cmd}= Set Variable openstack security group rule create ${Security_group_name}
733 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
734 ... ELSE Catenate ${cmd}
735 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --${direction}
736 ... ELSE Catenate ${cmd}
737 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
738 ... ELSE Catenate ${cmd}
739 ${cmd}= Run Keyword If '${port_range_min}'!='None' and '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_min}:${port_range_max}
740 ... ELSE IF '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_max}
741 ... ELSE IF '${port_range_min}'!='None' Catenate ${cmd} --dst-port ${port_range_min}
742 ... ELSE Catenate ${cmd}
743 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
744 ... ELSE Catenate ${cmd}
745 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote-group ${remote_group_id}
746 ... ELSE Catenate ${cmd}
747 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --src-ip ${remote_ip_prefix}
748 ... ELSE Catenate ${cmd}
749 ${rc} ${output}= Run And Return Rc And Output ${cmd}
750 ${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}
752 Should Not Be True ${rc}
753 [Return] ${output} ${rule_id}
755 Neutron Security Group Rule Create Legacy Cli
756 [Arguments] ${Security_group_name} &{Kwargs}
757 [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]} ..."
758 Run Keyword If ${Kwargs} Log ${Kwargs}
759 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
760 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
761 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
762 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
763 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
764 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
765 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
766 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
767 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
768 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
769 ... ELSE Catenate ${cmd}
770 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
771 ... ELSE Catenate ${cmd}
772 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
773 ... ELSE Catenate ${cmd}
774 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
775 ... ELSE Catenate ${cmd}
776 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
777 ... ELSE Catenate ${cmd}
778 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
779 ... ELSE Catenate ${cmd}
780 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
781 ... ELSE Catenate ${cmd}
782 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
783 ... ELSE Catenate ${cmd}
784 ${rc} ${output}= Run And Return Rc And Output ${cmd}
785 ${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}
787 Should Not Be True ${rc}
788 [Return] ${output} ${rule_id}
790 Security Group Create Without Default Security Rules
791 [Arguments] ${sg_name} ${additional_args}=${EMPTY}
792 [Documentation] Create Neutron Security Group with no default rules, using specified name and optional arguments.
793 Neutron Security Group Create ${sg_name} ${additional_args}
794 Delete All Security Group Rules ${sg_name}
796 Delete All Security Group Rules
797 [Arguments] ${sg_name}
798 [Documentation] Delete all security rules from a specified security group
799 ${rc} ${sg_rules_output}= Run And Return Rc And Output openstack security group rule list ${sg_name} -cID -fvalue
800 Log ${sg_rules_output}
801 Should Not Be True ${rc}
802 @{sg_rules}= Split String ${sg_rules_output} \n
803 : FOR ${rule} IN @{sg_rules}
804 \ ${rc} ${output}= Run And Return Rc And Output openstack security group rule delete ${rule}
806 \ Should Not Be True ${rc}
808 Create Allow All SecurityGroup
809 [Arguments] ${sg_name} ${ether_type}=IPv4
810 [Documentation] Allow all TCP/UDP/ICMP packets for this suite
811 Neutron Security Group Create ${sg_name}
812 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
813 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
814 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} protocol=icmp
815 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} protocol=icmp
816 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
817 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
819 Create Neutron Port With Additional Params
820 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
821 [Documentation] Create Port With given additional parameters
822 ${cmd}= Set Variable neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
824 ${rc} ${output}= Run And Return Rc And Output ${cmd}
826 Should Not Be True ${rc}
827 ${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}
829 [Return] ${OUTPUT} ${port_id}
832 [Arguments] ${portName_list}
833 [Documentation] Retrieve the port MacAddr for the given list of port name and return the MAC address list.
834 ${MacAddr-list} Create List
835 : FOR ${portName} IN @{portName_list}
836 \ ${macAddr}= OpenStackOperations.Get Port Mac ${portName} ${devstack_conn_id}
837 \ Append To List ${MacAddr-list} ${macAddr}
838 [Return] ${MacAddr-list}
841 [Arguments] ${port_name}
842 [Documentation] Keyword would return the IP of the ${port_name} received.
843 ${rc} ${output}= Run And Return Rc And Output openstack port list | grep "${port_name}" | awk -F\\' '{print $2}'
845 ${splitted_output}= Split String ${output} ${EMPTY}
846 ${port_ip}= Get from List ${splitted_output} 0
848 Should Not Be True ${rc}
852 [Arguments] ${port_name} ${conn_id}=${devstack_conn_id}
853 [Documentation] Keyword would return the MAC ID of the ${port_name} received.
854 ${rc} ${output}= Run And Return Rc And Output openstack port show ${port_name} | grep mac_address | awk '{print $4}'
856 ${splitted_output}= Split String ${output} ${EMPTY}
857 ${port_mac}= Get from List ${splitted_output} 0
859 Should Not Be True ${rc}
863 [Arguments] ${bridge_name} ${intf_name} ${gw_name}
864 [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
865 ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name}
867 [Return] ${l2gw_output}
869 Create L2Gateway Connection
870 [Arguments] ${gw_name} ${net_name}
871 [Documentation] Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
872 ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_CONN_CREATE} ${gw_name} ${net_name}
874 Should Not Be True ${rc}
875 [Return] ${l2gw_output}
878 [Documentation] Keyword to return all the L2 Gateways available (Using Neutron CLI).
879 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_YAML}
880 Should Not Be True ${rc}
883 Get All L2Gateway Connection
884 [Documentation] Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
885 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_CONN_YAML}
886 Should Not Be True ${rc}
891 [Documentation] Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
892 ${rc} ${output}= Run And Return Rc And Output ${L2GW_SHOW} ${gw_id}
894 Should Not Be True ${rc}
898 [Arguments] ${l2gw_name}
899 [Documentation] Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
900 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}'
902 Should Not Be True ${rc}
903 ${splitted_output}= Split String ${output} ${EMPTY}
904 ${l2gw_id}= Get from List ${splitted_output} 0
908 Get L2gw Connection Id
909 [Arguments] ${l2gw_name}
910 [Documentation] Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
911 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${l2gw_name}
912 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}'
914 Should Not Be True ${rc}
915 ${splitted_output}= Split String ${output} ${EMPTY}
916 ${splitted_output}= Split String ${output} ${EMPTY}
917 ${l2gw_conn_id}= Get from List ${splitted_output} 0
919 [Return] ${l2gw_conn_id}
921 Neutron Port List Rest
922 [Documentation] Keyword to get all ports details in Neutron (Using REST).
923 ${resp} = RequestsLibrary.Get Request session ${PORT_URL}
925 Should Be Equal As Strings ${resp.status_code} 200
926 [Return] ${resp.content}
928 Get Neutron Port Rest
929 [Arguments] ${port_id}
930 [Documentation] Keyword to get the specific port details in Neutron (Using REST).
931 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id}
933 Should Be Equal As Strings ${resp.status_code} 200
934 [Return] ${resp.content}
937 [Arguments] ${port_id} ${json_data}
938 [Documentation] Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
940 ${resp} = RequestsLibrary.Put Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id} ${json_data}
942 Should Be Equal As Strings ${resp.status_code} 200
943 [Return] ${resp.content}
945 Create And Configure Security Group
946 [Arguments] ${sg-name}
947 [Documentation] Create Security Group with given name, and default allow rules for TCP/UDP/ICMP protocols.
948 Neutron Security Group Create ${sg-name}
949 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
950 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
951 Neutron Security Group Rule Create ${sg-name} direction=ingress protocol=icmp remote_ip_prefix=0.0.0.0/0
952 Neutron Security Group Rule Create ${sg-name} direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0
953 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
954 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
956 Add Security Group To VM
957 [Arguments] ${vm} ${sg}
958 [Documentation] Add the security group provided to the given VM.
959 ${rc} ${output}= Run And Return Rc And Output openstack server add security group ${vm} ${sg}
961 Should Not Be True ${rc}
963 Remove Security Group From VM
964 [Arguments] ${vm} ${sg}
965 [Documentation] Remove the security group provided to the given VM.
966 ${devstack_conn_id}= Get ControlNode Connection
967 Switch Connection ${devstack_conn_id}
968 ${output}= Write Commands Until Prompt openstack server remove security group ${vm} ${sg}
972 Create SFC Flow Classifier
973 [Arguments] ${name} ${src_ip} ${dest_ip} ${protocol} ${dest_port} ${neutron_src_port}
974 [Documentation] Create a flow classifier for SFC
975 ${cmd}= Set Variable neutron 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}
977 ${rc} ${output}= Run And Return Rc And Output ${cmd}
979 Should Not Be True ${rc}
980 Should Contain ${output} Created a new flow_classifier
983 Delete SFC Flow Classifier
985 [Documentation] Delete a SFC flow classifier
986 ${devstack_conn_id}= Get ControlNode Connection
987 Switch Connection ${devstack_conn_id}
988 ${cmd}= Set Variable neutron flow-classifier-delete ${name}
990 ${rc} ${output}= Run And Return Rc And Output ${cmd}
992 Should Not Be True ${rc}
993 Should Contain ${output} Deleted flow_classifier
997 [Arguments] ${name} ${port_in} ${port_out}
998 [Documentation] Creates a neutron port pair for SFC
999 ${devstack_conn_id}= Get ControlNode Connection
1000 Switch Connection ${devstack_conn_id}
1001 ${cmd}= Set Variable neutron port-pair-create --ingress=${port_in} --egress=${port_out} ${name}
1003 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1005 Should Not Be True ${rc}
1006 Should Contain ${output} Created a new port_pair
1009 Delete SFC Port Pair
1011 [Documentation] Delete a SFC port pair
1012 ${cmd}= Set Variable neutron port-pair-delete ${name}
1014 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1016 Should Not Be True ${rc}
1017 Should Contain ${output} Deleted port_pair
1020 Create SFC Port Pair Group
1021 [Arguments] ${name} ${port_pair}
1022 [Documentation] Creates a port pair group with a single port pair for SFC
1023 ${cmd}= Set Variable neutron port-pair-group-create --port-pair ${port_pair} ${name}
1025 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1027 Should Not Be True ${rc}
1028 Should Contain ${output} Created a new port_pair_group
1031 Create SFC Port Pair Group With Two Pairs
1032 [Arguments] ${name} ${port_pair1} ${port_pair2}
1033 [Documentation] Creates a port pair group with two port pairs for SFC
1034 ${cmd}= Set Variable neutron port-pair-group-create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name}
1036 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1038 Should Not Be True ${rc}
1039 Should Contain ${output} Created a new port_pair_group
1042 Delete SFC Port Pair Group
1044 [Documentation] Delete a SFC port pair group
1045 ${devstack_conn_id}= Get ControlNode Connection
1046 ${cmd}= Set Variable neutron port-pair-group-delete ${name}
1048 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1050 Should Not Be True ${rc}
1051 Should Contain ${output} Deleted port_pair_group
1054 Create SFC Port Chain
1055 [Arguments] ${name} ${pg1} ${pg2} ${fc}
1056 [Documentation] Creates a port pair chain with two port groups and a singel classifier.
1057 ${cmd}= Set Variable neutron port-chain-create --port-pair-group ${pg1} --port-pair-group ${pg2} --flow-classifier ${fc} ${name}
1059 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1061 Should Not Be True ${rc}
1062 Should Contain ${output} Created a new port_chain
1065 Delete SFC Port Chain
1067 [Documentation] Delete a SFC port chain
1068 ${cmd}= Set Variable neutron port-chain-delete ${name}
1070 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1072 Should Not Be True ${rc}
1073 Should Contain ${output} Deleted port_chain
1077 [Arguments] ${vm_name}
1078 [Documentation] Reboot NOVA VM
1079 ${rc} ${output}= Run And Return Rc And Output openstack server reboot --wait ${vm_name}
1081 Should Not Be True ${rc}
1082 Wait Until Keyword Succeeds 35s 10s Verify VM Is ACTIVE ${vm_name}
1084 Remove RSA Key From KnowHosts
1085 [Arguments] ${vm_ip}
1086 [Documentation] Remove RSA
1087 ${devstack_conn_id}= Get ControlNode Connection
1088 Switch Connection ${devstack_conn_id}
1089 ${output}= Write Commands Until Prompt sudo cat /root/.ssh/known_hosts 30s
1091 ${output}= Write Commands Until Prompt sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ${vm_ip} 30s
1093 ${output}= Write Commands Until Prompt sudo cat "/root/.ssh/known_hosts" 30s
1095 Wait For Routes To Propogate
1096 [Arguments] ${networks} ${subnets}
1097 [Documentation] Check propagated routes
1098 ${devstack_conn_id} = Get ControlNode Connection
1099 Switch Connection ${devstack_conn_id}
1100 : FOR ${INDEX} IN RANGE 0 1
1101 \ ${net_id}= Get Net Id @{networks}[${INDEX}] ${devstack_conn_id}
1102 \ ${is_ipv6}= Get Regexp Matches @{subnets}[${INDEX}] ${IP6_REGEX}
1103 \ ${length}= Get Length ${is_ipv6}
1104 \ ${cmd}= Set Variable If ${length} == 0 ip route ip -6 route
1105 \ ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ${cmd} ]>
1106 \ Should Contain ${output} @{subnets}[${INDEX}]