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}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
256 [Documentation] Create X Vm Instance with the net id of the Netowrk.
257 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
258 : FOR ${VmElement} IN @{vm_instance_names}
259 \ ${rc} ${output}= Run And Return Rc And Output openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-group ${sg}
260 \ Should Not Be True ${rc}
263 Create Vm Instance With Port
264 [Arguments] ${port_name} ${vm_instance_name} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
265 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
266 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
267 ${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}
270 Create Vm Instance With Ports
271 [Arguments] ${port_name} ${port2_name} ${vm_instance_name} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
272 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
273 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
274 ${port2_id}= Get Port Id ${port2_name} ${devstack_conn_id}
275 ${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}
277 Should Not Be True ${rc}
279 Create Vm Instance With Port On Compute Node
280 [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
281 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
282 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
283 ${hostname_compute_node}= Run Command On Remote System ${compute_node} hostname
284 ${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}
286 Should Not Be True ${rc}
289 [Arguments] ${vm_name}
290 [Documentation] Run these commands to check whether the created vm instance is active or not.
291 ${rc} ${output}= Run And Return Rc And Output openstack server show ${vm_name} | grep OS-EXT-STS:vm_state
293 Should Not Be True ${rc}
294 Should Contain ${output} active
296 Collect VM IP Addresses
297 [Arguments] ${fail_on_none} @{vm_list}
298 [Documentation] Using nova console-log on the provided ${vm_list} to search for the string "obtained" which
299 ... correlates to the instance receiving it's IP address via DHCP. Also retrieved is the ip of the nameserver
300 ... if available in the console-log output. The keyword will also return a list of the learned ips as it
301 ... finds them in the console log output, and will have "None" for Vms that no ip was found.
302 ${ip_list} Create List @{EMPTY}
303 : FOR ${vm} IN @{vm_list}
304 \ ${rc} ${vm_ip_line}= Run And Return Rc And Output openstack console log show ${vm} | grep -i "obtained"
307 \ @{vm_ip} Get Regexp Matches ${vm_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
308 \ ${vm_ip_length} Get Length ${vm_ip}
309 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip}[0]
310 \ ... ELSE Append To List ${ip_list} None
311 \ ${rc} ${dhcp_ip_line}= Run And Return Rc And Output openstack console log show ${vm} | grep "^nameserver"
312 \ Log ${dhcp_ip_line}
314 \ ${dhcp_ip} Get Regexp Matches ${dhcp_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
315 \ ${dhcp_ip_length} Get Length ${dhcp_ip}
316 \ Run Keyword If ${dhcp_ip_length}<=0 Append To List ${dhcp_ip} None
318 \ ${vm_console_output}= Run openstack console log show ${vm}
319 \ Log ${vm_console_output}
320 ${dhcp_length} Get Length ${dhcp_ip}
321 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${ip_list} None
322 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${dhcp_ip} None
323 Should Be True ${dhcp_length} <= 1
324 Return From Keyword If ${dhcp_length}==0 ${ip_list} ${EMPTY}
325 [Return] ${ip_list} ${dhcp_ip}
327 Collect VM IPv6 SLAAC Addresses
328 [Arguments] ${fail_on_none} ${prefix} @{vm_list}
329 [Documentation] Using nova console-log on the provided ${vm_list} to search for the string "inet6" which
330 ... correlates to the instance generated IPv6 address, based on the ${prefix} received from ODL (SLAAC mode).
331 ${ip_list} Create List @{EMPTY}
332 : FOR ${vm} IN @{vm_list}
334 \ ${rc} ${vm_ip_line}= Run And Return Rc And Output nova console-log ${vm} | grep -i "inet6"
337 \ @{vm_ip_list} Get Regexp Matches ${vm_ip_line} ${prefix}
338 \ ${vm_ip_length} Get Length ${vm_ip_list}
339 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip_list}[0]
340 \ ... ELSE Append To List ${ip_list} None
342 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${ip_list} None
347 [Arguments] ${vm_instance_names}
348 [Documentation] View Console log of the created vm instances using nova show.
349 : FOR ${VmElement} IN @{vm_instance_names}
350 \ ${rc} ${output}= Run And Return Rc And Output nova show ${VmElement}
352 \ Should Not Be True ${rc}
353 \ ${rc} ${output}= Run And Return Rc And Output openstack console log show ${VmElement}
355 \ Should Not Be True ${rc}
357 Ping Vm From DHCP Namespace
358 [Arguments] ${net_name} ${vm_ip}
359 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
361 ${devstack_conn_id}= Get ControlNode Connection
362 Switch Connection ${devstack_conn_id}
363 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
365 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
368 Should Contain ${output} 64 bytes
370 Ping From DHCP Should Not Succeed
371 [Arguments] ${net_name} ${vm_ip}
372 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
373 Return From Keyword If "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
375 ${devstack_conn_id}= Get ControlNode Connection
376 Switch Connection ${devstack_conn_id}
377 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
379 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
382 Should Not Contain ${output} 64 bytes
384 Ping Vm From Control Node
385 [Arguments] ${vm_floating_ip} ${additional_args}=${EMPTY}
386 [Documentation] Ping VM floating IP from control node
387 Log ${vm_floating_ip}
388 ${devstack_conn_id}= Get ControlNode Connection
389 Switch Connection ${devstack_conn_id}
390 ${output}= Write Commands Until Prompt ping ${additional_args} -c 3 ${vm_floating_ip} 20s
393 Should Contain ${output} 64 bytes
396 [Arguments] ${dest_vm_ip}
397 [Documentation] Ping to the expected destination ip.
398 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm_ip} ${OS_SYSTEM_PROMPT}
403 [Documentation] Ping to the expected destination ip.
404 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
405 Write Commands Until Prompt exit
406 Should Contain ${output} 200
409 [Documentation] Exit the vm instance.
410 ${output}= Write Commands Until Prompt exit
413 Check If Console Is VmInstance
414 [Arguments] ${console}=cirros
415 [Documentation] Check if the session has been able to login to the VM instance
416 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
417 Should Contain ${output} ${console}
420 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
421 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
422 Run Keyword If ${rcode} Write Commands Until Prompt exit
426 [Arguments] ${ip_address} ${ttl}=64
427 [Documentation] Run Ping command on the IP available as argument
428 ${ethertype}= Get Regexp Matches ${ip_address} ${IP_REGEX}
429 ${output}= Run Keyword If ${ethertype} Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
430 ... ELSE Write Commands Until Expected Prompt ping6 -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
431 Should Contain ${output} 64 bytes
434 [Arguments] ${ip_address} ${ttl}=64
435 [Documentation] Run Ping command to the IP given as argument, executing 3 times and expecting NOT to see "64 bytes"
436 ${output}= Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
437 Should Not Contain ${output} 64 bytes
439 Check Metadata Access
440 [Documentation] Try curl on the Metadataurl and check if it is okay
441 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
442 Should Contain ${output} 200
444 Execute Command on VM Instance
445 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
446 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
447 ${devstack_conn_id} = Get ControlNode Connection
448 Switch Connection ${devstack_conn_id}
449 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
451 ${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:
453 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
455 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
456 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
457 [Teardown] Exit From Vm Console
460 Test Operations From Vm Instance
461 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:) ${ttl}=64
462 ... ${ping_should_succeed}=True ${check_metadata}=True
463 [Documentation] Login to the vm instance using ssh in the network.
464 ${devstack_conn_id}= Get ControlNode Connection
465 Switch Connection ${devstack_conn_id}
467 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
468 ${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:
470 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
472 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
473 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
474 Run Keyword If ${rcode} Write Commands Until Expected Prompt route -n ${OS_SYSTEM_PROMPT}
475 Run Keyword If ${rcode} Write Commands Until Expected Prompt route -A inet6 ${OS_SYSTEM_PROMPT}
476 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
477 Run Keyword If ${rcode} Write Commands Until Expected Prompt ip -6 neigh ${OS_SYSTEM_PROMPT}
478 : FOR ${dest_ip} IN @{dest_ips}
480 \ ${string_empty}= Run Keyword And Return Status Should Be Empty ${dest_ip}
481 \ Run Keyword If ${string_empty} Continue For Loop
482 \ Run Keyword If ${rcode} and "${ping_should_succeed}" == "True" Check Ping ${dest_ip} ttl=${ttl}
483 \ ... ELSE Check No Ping ${dest_ip} ttl=${ttl}
484 ${ethertype}= Get Regexp Matches ${src_ip} ${IP_REGEX}
485 Run Keyword If ${rcode} and "${check_metadata}" and ${ethertype} == "True" Check Metadata Access
486 [Teardown] Exit From Vm Console
488 Test Netcat Operations From Vm Instance
489 [Arguments] ${net_name} ${vm_ip} ${dest_ip} ${additional_args}=${EMPTY} ${port}=12345 ${user}=cirros
490 ... ${password}=cubswin:)
491 [Documentation] Use Netcat to test TCP/UDP connections to the controller
492 ${client_data} Set Variable Test Client Data
493 ${server_data} Set Variable Test Server Data
494 ${devstack_conn_id}= Get ControlNode Connection
495 Switch Connection ${devstack_conn_id}
497 ${output}= Write Commands Until Prompt ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
499 ${output}= Write Commands Until Prompt sudo netstat -nlap | grep ${port}
501 ${nc_output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo echo "${client_data}" | nc -v -w 5 ${additional_args} ${dest_ip} ${port}
503 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo route -n
505 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo arp -an
507 Should Match Regexp ${nc_output} ${server_data}
510 [Arguments] ${list_of_external_dst_ips}
511 [Documentation] Check reachability with other network's instances.
512 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
513 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
515 \ Check Ping ${dest_ip}
518 [Arguments] ${router_name}
519 [Documentation] Create Router and Add Interface to the subnets.
520 ${rc} ${output}= Run And Return Rc And Output openstack router create ${router_name}
521 Should Not Be True ${rc}
524 [Documentation] List Router and return output with neutron client.
525 ${rc} ${output}= Run And Return Rc And Output openstack router list -f value
527 Should Not Be True ${rc}
531 [Arguments] ${router_name} ${interface_name}
532 ${rc} ${output}= Run And Return Rc And Output openstack router add subnet ${router_name} ${interface_name}
533 Should Not Be True ${rc}
535 Show Router Interface
536 [Arguments] ${router_name}
537 [Documentation] List Router interface associated with given Router and return output with neutron client.
538 ${rc} ${output}= Run And Return Rc And Output openstack port list --router ${router_name} -f value
540 Should Not Be True ${rc}
544 [Arguments] ${router_name} ${external_network_name}
545 ${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}
546 ${rc} ${output}= Run And Return Rc And Output ${cmd}
547 Should Not Be True ${rc}
550 [Arguments] ${router_name} ${interface_name}
551 [Documentation] Remove Interface to the subnets.
552 ${rc} ${output}= Run And Return Rc And Output openstack router remove subnet ${router_name} ${interface_name}
553 Should Not Be True ${rc}
556 [Arguments] ${router_name} ${cmd}
557 [Documentation] Update the router with the command. Router name and command should be passed as argument.
558 ${rc} ${output} = Run And Return Rc And Output openstack router set ${router_name} ${cmd}
559 Should Not Be True ${rc}
562 [Arguments] ${router_name} ${options}
563 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
564 ${rc} ${output} = Run And Return Rc And Output openstack router show ${router_name}
568 [Arguments] ${router_name}
569 [Documentation] Delete Router and Interface to the subnets.
570 ${rc} ${output}= Run And Return Rc And Output openstack router delete ${router_name}
571 Should Not Be True ${rc}
573 Get DumpFlows And Ovsconfig
574 [Arguments] ${openstack_node_ip}
575 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
576 Log ${openstack_node_ip}
577 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
578 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
579 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
580 Write Commands Until Expected Prompt ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
581 Write Commands Until Expected Prompt ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
582 Write Commands Until Expected Prompt ip route ${DEFAULT_LINUX_PROMPT_STRICT}
583 Write Commands Until Expected Prompt arp -an ${DEFAULT_LINUX_PROMPT_STRICT}
584 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ${DEFAULT_LINUX_PROMPT_STRICT}
585 @{lines} Split To Lines ${nslist}
586 : FOR ${line} IN @{lines}
587 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
588 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
589 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT}
590 Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
591 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
592 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
593 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
594 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
595 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
597 Get Karaf Log Type From Test Start
598 [Arguments] ${ip} ${test_name} ${type} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
599 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
600 ${cmd} Set Variable sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
601 ${output} Run Command On Controller ${ip} ${cmd} ${user} ${password} ${prompt}
604 Get Karaf Log Types From Test Start
605 [Arguments] ${ip} ${test_name} ${types} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
606 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
607 : FOR ${type} IN @{types}
608 \ Get Karaf Log Type From Test Start ${ip} ${test_name} ${type} ${user} ${password}
609 \ ... ${prompt} ${log_file}
611 Get Karaf Log Events From Test Start
612 [Arguments] ${test_name} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
613 ${log_types} = Create List ERROR WARN Exception
614 Run Keyword If 0 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_IP} ${test_name} ${log_types}
615 Run Keyword If 1 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_2_IP} ${test_name} ${log_types}
616 Run Keyword If 2 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_3_IP} ${test_name} ${log_types}
618 Get ControlNode Connection
619 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
620 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
621 SSHLibrary.Set Client Configuration timeout=30s
622 [Return] ${control_conn_id}
625 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
626 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
627 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
628 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
630 Get Test Teardown Debugs
631 [Arguments] ${test_name}=${TEST_NAME}
633 Run Keyword And Ignore Error Get Model Dump ${HA_PROXY_IP} ${netvirt_data_models}
634 Get Karaf Log Events From Test Start ${test_name}
637 [Arguments] @{vm_indices}
638 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
639 ${devstack_conn_id}= Get ControlNode Connection
640 Switch Connection ${devstack_conn_id}
641 ${output}= Write Commands Until Prompt sudo ip netns list
644 : FOR ${index} IN @{vm_indices}
645 \ ${rc} ${output}= Run And Return Rc And Output nova show ${index}
653 Neutron Security Group Show
654 [Arguments] ${SecurityGroupRuleName}
655 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
656 ${cmd}= Set Variable openstack security group show ${SecurityGroupRuleName}
658 ${rc} ${output}= Run And Return Rc And Output ${cmd}
660 Should Not Be True ${rc}
664 [Arguments] ${PortName}
665 [Documentation] Display the port configuration that belong to a given neutron port
666 ${cmd}= Set Variable openstack port show ${PortName}
668 ${rc} ${output}= Run And Return Rc And Output ${cmd}
670 Should Not Be True ${rc}
673 Neutron Security Group Create
674 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
675 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
676 ${devstack_conn_id}= Get ControlNode Connection
677 Switch Connection ${devstack_conn_id}
678 ${cmd}= Set Variable openstack security group create ${SecurityGroupName} ${additional_args}
680 ${rc} ${output}= Run And Return Rc And Output ${cmd}
682 Should Not Be True ${rc}
683 ${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}
685 [Return] ${output} ${sgp_id}
687 Neutron Security Group Update
688 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
689 [Documentation] Updating security groups
690 ${cmd}= Set Variable openstack security group set ${SecurityGroupName} ${additional_args}
692 ${rc} ${output}= Run And Return Rc And Output ${cmd}
694 Should Not Be True ${rc}
698 [Arguments] ${sg_name}
699 [Documentation] Delete Security group
700 ${rc} ${output}= Run And Return Rc And Output openstack security group delete ${sg_name}
702 Should Not Be True ${rc}
704 Neutron Security Group Rule Create
705 [Arguments] ${Security_group_name} &{Kwargs}
706 [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]} ..."
707 Run Keyword If ${Kwargs} Log ${Kwargs}
708 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
709 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
710 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
711 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
712 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
713 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
714 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
715 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
716 ${cmd}= Set Variable openstack security group rule create ${Security_group_name}
717 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
718 ... ELSE Catenate ${cmd}
719 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --${direction}
720 ... ELSE Catenate ${cmd}
721 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
722 ... ELSE Catenate ${cmd}
723 ${cmd}= Run Keyword If '${port_range_min}'!='None' and '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_min}:${port_range_max}
724 ... ELSE IF '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_max}
725 ... ELSE IF '${port_range_min}'!='None' Catenate ${cmd} --dst-port ${port_range_min}
726 ... ELSE Catenate ${cmd}
727 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
728 ... ELSE Catenate ${cmd}
729 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote-group ${remote_group_id}
730 ... ELSE Catenate ${cmd}
731 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --src-ip ${remote_ip_prefix}
732 ... ELSE Catenate ${cmd}
733 ${rc} ${output}= Run And Return Rc And Output ${cmd}
734 ${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}
736 Should Not Be True ${rc}
737 [Return] ${output} ${rule_id}
739 Neutron Security Group Rule Create Legacy Cli
740 [Arguments] ${Security_group_name} &{Kwargs}
741 [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]} ..."
742 Run Keyword If ${Kwargs} Log ${Kwargs}
743 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
744 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
745 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
746 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
747 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
748 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
749 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
750 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
751 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
752 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
753 ... ELSE Catenate ${cmd}
754 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
755 ... ELSE Catenate ${cmd}
756 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
757 ... ELSE Catenate ${cmd}
758 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
759 ... ELSE Catenate ${cmd}
760 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
761 ... ELSE Catenate ${cmd}
762 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
763 ... ELSE Catenate ${cmd}
764 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
765 ... ELSE Catenate ${cmd}
766 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
767 ... ELSE Catenate ${cmd}
768 ${rc} ${output}= Run And Return Rc And Output ${cmd}
769 ${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}
771 Should Not Be True ${rc}
772 [Return] ${output} ${rule_id}
774 Security Group Create Without Default Security Rules
775 [Arguments] ${sg_name} ${additional_args}=${EMPTY}
776 [Documentation] Create Neutron Security Group with no default rules, using specified name and optional arguments.
777 Neutron Security Group Create ${sg_name} ${additional_args}
778 Delete All Security Group Rules ${sg_name}
780 Delete All Security Group Rules
781 [Arguments] ${sg_name}
782 [Documentation] Delete all security rules from a specified security group
783 ${rc} ${sg_rules_output}= Run And Return Rc And Output openstack security group rule list ${sg_name} -cID -fvalue
784 Log ${sg_rules_output}
785 Should Not Be True ${rc}
786 @{sg_rules}= Split String ${sg_rules_output} \n
787 : FOR ${rule} IN @{sg_rules}
788 \ ${rc} ${output}= Run And Return Rc And Output openstack security group rule delete ${rule}
790 \ Should Not Be True ${rc}
792 Create Allow All SecurityGroup
793 [Arguments] ${sg_name} ${ether_type}=IPv4
794 [Documentation] Allow all TCP/UDP/ICMP packets for this suite
795 Neutron Security Group Create ${sg_name}
796 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
797 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
798 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} protocol=icmp
799 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} protocol=icmp
800 Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
801 Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
803 Create Neutron Port With Additional Params
804 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
805 [Documentation] Create Port With given additional parameters
806 ${cmd}= Set Variable neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
808 ${rc} ${output}= Run And Return Rc And Output ${cmd}
810 Should Not Be True ${rc}
811 ${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}
813 [Return] ${OUTPUT} ${port_id}
816 [Arguments] ${portName_list}
817 [Documentation] Retrieve the port MacAddr for the given list of port name and return the MAC address list.
818 ${MacAddr-list} Create List
819 : FOR ${portName} IN @{portName_list}
820 \ ${macAddr}= OpenStackOperations.Get Port Mac ${portName} ${devstack_conn_id}
821 \ Append To List ${MacAddr-list} ${macAddr}
822 [Return] ${MacAddr-list}
825 [Arguments] ${port_name}
826 [Documentation] Keyword would return the IP of the ${port_name} received.
827 ${rc} ${output}= Run And Return Rc And Output openstack port list | grep "${port_name}" | awk -F\\' '{print $2}'
829 ${splitted_output}= Split String ${output} ${EMPTY}
830 ${port_ip}= Get from List ${splitted_output} 0
832 Should Not Be True ${rc}
836 [Arguments] ${port_name} ${conn_id}=${devstack_conn_id}
837 [Documentation] Keyword would return the MAC ID of the ${port_name} received.
838 ${rc} ${output}= Run And Return Rc And Output openstack port show ${port_name} | grep mac_address | awk '{print $4}'
840 ${splitted_output}= Split String ${output} ${EMPTY}
841 ${port_mac}= Get from List ${splitted_output} 0
843 Should Not Be True ${rc}
847 [Arguments] ${bridge_name} ${intf_name} ${gw_name}
848 [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
849 ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name}
851 [Return] ${l2gw_output}
853 Create L2Gateway Connection
854 [Arguments] ${gw_name} ${net_name}
855 [Documentation] Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
856 ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_CONN_CREATE} ${gw_name} ${net_name}
858 Should Not Be True ${rc}
859 [Return] ${l2gw_output}
862 [Documentation] Keyword to return all the L2 Gateways available (Using Neutron CLI).
863 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_YAML}
864 Should Not Be True ${rc}
867 Get All L2Gateway Connection
868 [Documentation] Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
869 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_CONN_YAML}
870 Should Not Be True ${rc}
875 [Documentation] Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
876 ${rc} ${output}= Run And Return Rc And Output ${L2GW_SHOW} ${gw_id}
878 Should Not Be True ${rc}
882 [Arguments] ${l2gw_name}
883 [Documentation] Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
884 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}'
886 Should Not Be True ${rc}
887 ${splitted_output}= Split String ${output} ${EMPTY}
888 ${l2gw_id}= Get from List ${splitted_output} 0
892 Get L2gw Connection Id
893 [Arguments] ${l2gw_name}
894 [Documentation] Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
895 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${l2gw_name}
896 ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}'
898 Should Not Be True ${rc}
899 ${splitted_output}= Split String ${output} ${EMPTY}
900 ${splitted_output}= Split String ${output} ${EMPTY}
901 ${l2gw_conn_id}= Get from List ${splitted_output} 0
903 [Return] ${l2gw_conn_id}
905 Neutron Port List Rest
906 [Documentation] Keyword to get all ports details in Neutron (Using REST).
907 ${resp} = RequestsLibrary.Get Request session ${PORT_URL}
909 Should Be Equal As Strings ${resp.status_code} 200
910 [Return] ${resp.content}
912 Get Neutron Port Rest
913 [Arguments] ${port_id}
914 [Documentation] Keyword to get the specific port details in Neutron (Using REST).
915 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id}
917 Should Be Equal As Strings ${resp.status_code} 200
918 [Return] ${resp.content}
921 [Arguments] ${port_id} ${json_data}
922 [Documentation] Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
924 ${resp} = RequestsLibrary.Put Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id} ${json_data}
926 Should Be Equal As Strings ${resp.status_code} 200
927 [Return] ${resp.content}
929 Create And Configure Security Group
930 [Arguments] ${sg-name}
931 [Documentation] Create Security Group with given name, and default allow rules for TCP/UDP/ICMP protocols.
932 Neutron Security Group Create ${sg-name}
933 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
934 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
935 Neutron Security Group Rule Create ${sg-name} direction=ingress protocol=icmp remote_ip_prefix=0.0.0.0/0
936 Neutron Security Group Rule Create ${sg-name} direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0
937 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
938 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
940 Add Security Group To VM
941 [Arguments] ${vm} ${sg}
942 [Documentation] Add the security group provided to the given VM.
943 ${rc} ${output}= Run And Return Rc And Output openstack server add security group ${vm} ${sg}
945 Should Not Be True ${rc}
947 Remove Security Group From VM
948 [Arguments] ${vm} ${sg}
949 [Documentation] Remove the security group provided to the given VM.
950 ${devstack_conn_id}= Get ControlNode Connection
951 Switch Connection ${devstack_conn_id}
952 ${output}= Write Commands Until Prompt openstack server remove security group ${vm} ${sg}
956 Create SFC Flow Classifier
957 [Arguments] ${name} ${src_ip} ${dest_ip} ${protocol} ${dest_port} ${neutron_src_port}
958 [Documentation] Create a flow classifier for SFC
959 ${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}
961 ${rc} ${output}= Run And Return Rc And Output ${cmd}
963 Should Not Be True ${rc}
964 Should Contain ${output} Created a new flow_classifier
967 Delete SFC Flow Classifier
969 [Documentation] Delete a SFC flow classifier
970 ${devstack_conn_id}= Get ControlNode Connection
971 Switch Connection ${devstack_conn_id}
972 ${cmd}= Set Variable neutron flow-classifier-delete ${name}
974 ${rc} ${output}= Run And Return Rc And Output ${cmd}
976 Should Not Be True ${rc}
977 Should Contain ${output} Deleted flow_classifier
981 [Arguments] ${name} ${port_in} ${port_out}
982 [Documentation] Creates a neutron port pair for SFC
983 ${devstack_conn_id}= Get ControlNode Connection
984 Switch Connection ${devstack_conn_id}
985 ${cmd}= Set Variable neutron port-pair-create --ingress=${port_in} --egress=${port_out} ${name}
987 ${rc} ${output}= Run And Return Rc And Output ${cmd}
989 Should Not Be True ${rc}
990 Should Contain ${output} Created a new port_pair
995 [Documentation] Delete a SFC port pair
996 ${cmd}= Set Variable neutron port-pair-delete ${name}
998 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1000 Should Not Be True ${rc}
1001 Should Contain ${output} Deleted port_pair
1004 Create SFC Port Pair Group
1005 [Arguments] ${name} ${port_pair}
1006 [Documentation] Creates a port pair group with a single port pair for SFC
1007 ${cmd}= Set Variable neutron port-pair-group-create --port-pair ${port_pair} ${name}
1009 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1011 Should Not Be True ${rc}
1012 Should Contain ${output} Created a new port_pair_group
1015 Create SFC Port Pair Group With Two Pairs
1016 [Arguments] ${name} ${port_pair1} ${port_pair2}
1017 [Documentation] Creates a port pair group with two port pairs for SFC
1018 ${cmd}= Set Variable neutron port-pair-group-create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name}
1020 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1022 Should Not Be True ${rc}
1023 Should Contain ${output} Created a new port_pair_group
1026 Delete SFC Port Pair Group
1028 [Documentation] Delete a SFC port pair group
1029 ${devstack_conn_id}= Get ControlNode Connection
1030 ${cmd}= Set Variable neutron port-pair-group-delete ${name}
1032 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1034 Should Not Be True ${rc}
1035 Should Contain ${output} Deleted port_pair_group
1038 Create SFC Port Chain
1039 [Arguments] ${name} ${pg1} ${pg2} ${fc}
1040 [Documentation] Creates a port pair chain with two port groups and a singel classifier.
1041 ${cmd}= Set Variable neutron port-chain-create --port-pair-group ${pg1} --port-pair-group ${pg2} --flow-classifier ${fc} ${name}
1043 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1045 Should Not Be True ${rc}
1046 Should Contain ${output} Created a new port_chain
1049 Delete SFC Port Chain
1051 [Documentation] Delete a SFC port chain
1052 ${cmd}= Set Variable neutron port-chain-delete ${name}
1054 ${rc} ${output}= Run And Return Rc And Output ${cmd}
1056 Should Not Be True ${rc}
1057 Should Contain ${output} Deleted port_chain
1061 [Arguments] ${vm_name}
1062 [Documentation] Reboot NOVA VM
1063 ${rc} ${output}= Run And Return Rc And Output openstack server reboot --wait ${vm_name}
1065 Should Not Be True ${rc}
1066 Wait Until Keyword Succeeds 35s 10s Verify VM Is ACTIVE ${vm_name}
1068 Remove RSA Key From KnowHosts
1069 [Arguments] ${vm_ip}
1070 [Documentation] Remove RSA
1071 ${devstack_conn_id}= Get ControlNode Connection
1072 Switch Connection ${devstack_conn_id}
1073 ${output}= Write Commands Until Prompt sudo cat /root/.ssh/known_hosts 30s
1075 ${output}= Write Commands Until Prompt sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ${vm_ip} 30s
1077 ${output}= Write Commands Until Prompt sudo cat "/root/.ssh/known_hosts" 30s
1079 Wait For Routes To Propogate
1080 [Arguments] ${networks} ${subnets}
1081 [Documentation] Check propagated routes
1082 ${devstack_conn_id} = Get ControlNode Connection
1083 Switch Connection ${devstack_conn_id}
1084 : FOR ${INDEX} IN RANGE 0 1
1085 \ ${net_id}= Get Net Id @{networks}[${INDEX}] ${devstack_conn_id}
1086 \ ${is_ipv6}= Get Regexp Matches @{subnets}[${INDEX}] ${IP6_REGEX}
1087 \ ${length}= Get Length ${is_ipv6}
1088 \ ${cmd}= Set Variable If ${length} == 0 ip route ip -6 route
1089 \ ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ${cmd} ]>
1090 \ Should Contain ${output} @{subnets}[${INDEX}]