2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
6 Resource L2GatewayOperations.robot
7 Resource ../variables/Variables.robot
11 [Arguments] ${force}=no ${source_pwd}=yes
12 [Documentation] Sourcing the Openstack PAsswords for neutron configurations
13 Run Keyword If '${source_pwd}' == 'yes' or '${force}' == 'yes' Write Commands Until Prompt cd ${DEVSTACK_DEPLOY_PATH}; source openrc admin admin
15 Get Tenant ID From Security Group
16 [Documentation] Returns tenant ID by reading it from existing default security-group.
17 ${devstack_conn_id}= Get ControlNode Connection
18 Switch Connection ${devstack_conn_id}
19 ${output}= Write Commands Until Prompt neutron security-group-show default | grep "| tenant_id" | awk '{print $4}'
23 Get Tenant ID From Network
24 [Arguments] ${network_uuid}
25 [Documentation] Returns tenant ID by reading it from existing network.
26 ${resp}= Get_From_Uri uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/ accept=${ACCEPT_EMPTY} session=session
27 ${tenant_id}= Utils.Extract Value From Content ${resp} /network/0/tenant-id strip
31 [Arguments] ${network_name} ${additional_args}=${EMPTY} ${verbose}=TRUE
32 [Documentation] Create Network with neutron request.
33 ${devstack_conn_id}= Get ControlNode Connection
34 Switch Connection ${devstack_conn_id}
35 ${command} Set Variable If "${verbose}" == "TRUE" neutron -v net-create ${network_name} ${additional_args} neutron net-create ${network_name} ${additional_args} | grep -w id | awk '{print $4}'
36 ${output}= Write Commands Until Prompt ${command} 30s
41 [Documentation] List networks and return output with neutron client.
42 ${devstack_conn_id}= Get ControlNode Connection
43 Switch Connection ${devstack_conn_id}
44 ${output}= Write Commands Until Prompt neutron net-list 30s
50 [Documentation] List subnets and return output with neutron client.
51 ${devstack_conn_id}= Get ControlNode Connection
52 Switch Connection ${devstack_conn_id}
53 ${output}= Write Commands Until Prompt neutron subnet-list 30s
59 [Arguments] ${network_name}
60 [Documentation] Delete Network with neutron request.
61 ${devstack_conn_id}= Get ControlNode Connection
62 Switch Connection ${devstack_conn_id}
63 ${output}= Write Commands Until Prompt neutron -v net-delete ${network_name} 30s
66 Should Match Regexp ${output} Deleted network: ${network_name}|Deleted network\\(s\\): ${network_name}
69 [Arguments] ${network_name} ${subnet} ${range_ip} ${additional_args}=${EMPTY}
70 [Documentation] Create SubNet for the Network with neutron request.
71 ${devstack_conn_id}= Get ControlNode Connection
72 Switch Connection ${devstack_conn_id}
73 ${output}= Write Commands Until Prompt neutron -v subnet-create ${network_name} ${range_ip} --name ${subnet} ${additional_args} 30s
76 Should Contain ${output} Created a new subnet
79 [Arguments] ${network_name} ${port_name} ${sg}=default ${additional_args}=${EMPTY}
80 [Documentation] Create Port with neutron request.
81 ${devstack_conn_id}= Get ControlNode Connection
82 Switch Connection ${devstack_conn_id}
83 ${output}= Write Commands Until Prompt neutron -v port-create ${network_name} --name ${port_name} --security-group ${sg} ${additional_args} 30s
86 Should Contain ${output} Created a new port
89 [Arguments] ${port_name}
90 [Documentation] Delete Port with neutron request.
91 ${devstack_conn_id}= Get ControlNode Connection
92 Switch Connection ${devstack_conn_id}
93 ${output}= Write Commands Until Prompt neutron -v port-delete ${port_name} 30s
96 Should Match Regexp ${output} Deleted port: ${port_name}|Deleted port\\(s\\): ${port_name}
99 [Documentation] List ports and return output with neutron client.
100 ${devstack_conn_id}= Get ControlNode Connection
101 Switch Connection ${devstack_conn_id}
102 ${output}= Write Commands Until Prompt neutron port-list 30s
108 [Documentation] List VMs and return output with nova client.
109 ${devstack_conn_id}= Get ControlNode Connection
110 Switch Connection ${devstack_conn_id}
111 ${output}= Write Commands Until Prompt nova list 30s
116 Create And Associate Floating IPs
117 [Arguments] ${external_net} @{vm_list}
118 [Documentation] Create and associate floating IPs to VMs with nova request
119 ${devstack_conn_id}= Get ControlNode Connection
120 Switch Connection ${devstack_conn_id}
121 ${ip_list}= Create List @{EMPTY}
122 : FOR ${vm} IN @{vm_list}
123 \ ${output}= Write Commands Until Prompt neutron floatingip-create ${external_net} 30s
125 \ @{ip} Get Regexp Matches ${output} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
126 \ ${ip_length} Get Length ${ip}
127 \ Run Keyword If ${ip_length}>0 Append To List ${ip_list} @{ip}[0]
128 \ ... ELSE Append To List ${ip_list} None
129 \ ${output}= Write Commands Until Prompt nova floating-ip-associate ${vm} @{ip}[0] 30s
134 [Documentation] Verifies the Gateway Ips with dump flow.
135 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
137 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
138 \ Should Contain ${output} ${GatewayIpElement}
141 [Documentation] Verifies the Dhcp Ips with dump flow.
142 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
144 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
145 \ Should Contain ${output} ${DhcpIpElement}
148 [Documentation] Verifies the Dhcp Ips with dump flow.
149 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
151 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
152 \ Should Not Contain ${output} ${DhcpIpElement}
155 [Arguments] ${subnet}
156 [Documentation] Delete SubNet for the Network with neutron request.
158 ${devstack_conn_id}= Get ControlNode Connection
159 Switch Connection ${devstack_conn_id}
160 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
163 Should Match Regexp ${output} Deleted subnet: ${subnet}|Deleted subnet\\(s\\): ${subnet}
165 Verify No Gateway Ips
166 [Documentation] Verifies the Gateway Ips removed with dump flow.
167 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
169 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
170 \ Should Not Contain ${output} ${GatewayIpElement}
173 [Arguments] ${vm_name}
174 [Documentation] Delete Vm instances using instance names.
175 ${devstack_conn_id}= Get ControlNode Connection
176 Switch Connection ${devstack_conn_id}
177 ${output}= Write Commands Until Prompt nova force-delete ${vm_name} 40s
181 [Arguments] ${network_name} ${devstack_conn_id}
182 [Documentation] Retrieve the net id for the given network name to create specific vm instance
183 Switch Connection ${devstack_conn_id}
184 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | awk '{print $2}' 30s
186 ${splitted_output}= Split String ${output} ${EMPTY}
187 ${net_id}= Get from List ${splitted_output} 0
192 [Arguments] ${subnet_name} ${devstack_conn_id}
193 [Documentation] Retrieve the subnet id for the given subnet name
194 Switch Connection ${devstack_conn_id}
195 ${output}= Write Commands Until Prompt neutron subnet-list | grep "${subnet_name}" | awk '{print $2}' 30s
197 ${splitted_output}= Split String ${output} ${EMPTY}
198 ${subnet_id}= Get from List ${splitted_output} 0
200 [Return] ${subnet_id}
203 [Arguments] ${port_name} ${devstack_conn_id}
204 [Documentation] Retrieve the port id for the given port name to attach specific vm instance to a particular port
205 Switch Connection ${devstack_conn_id}
206 ${output}= Write Commands Until Prompt neutron port-list | grep "${port_name}" | awk '{print $2}' 30s
208 ${splitted_output}= Split String ${output} ${EMPTY}
209 ${port_id}= Get from List ${splitted_output} 0
214 [Arguments] ${router1} ${devstack_conn_id}
215 [Documentation] Retrieve the router id for the given router name
216 Switch Connection ${devstack_conn_id}
217 ${output}= Write Commands Until Prompt neutron router-list | grep "${router1}" | awk '{print $2}' 30s
219 ${splitted_output}= Split String ${output} ${EMPTY}
220 ${router_id}= Get from List ${splitted_output} 0
222 [Return] ${router_id}
225 [Arguments] ${net_name} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
226 [Documentation] Create X Vm Instance with the net id of the Netowrk.
227 ${devstack_conn_id}= Get ControlNode Connection
228 Switch Connection ${devstack_conn_id}
229 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
230 : FOR ${VmElement} IN @{vm_instance_names}
231 \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-groups ${sg} 30s
234 Create Vm Instance With Port On Compute Node
235 [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
236 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
237 ${devstack_conn_id}= Get ControlNode Connection
238 Switch Connection ${devstack_conn_id}
239 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
240 ${hostname_compute_node}= Run Command On Remote System ${compute_node} hostname
241 ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-groups ${sg} --availability-zone nova:${hostname_compute_node} 30s
245 [Arguments] ${vm_name}
246 [Documentation] Run these commands to check whether the created vm instance is active or not.
247 ${devstack_conn_id}= Get ControlNode Connection
248 Switch Connection ${devstack_conn_id}
249 ${output}= Write Commands Until Prompt nova show ${vm_name} | grep OS-EXT-STS:vm_state 30s
251 Should Contain ${output} active
253 Collect VM IP Addresses
254 [Arguments] ${fail_on_none} @{vm_list}
255 [Documentation] Using nova console-log on the provided ${vm_list} to search for the string "obtained" which
256 ... correlates to the instance receiving it's IP address via DHCP. Also retrieved is the ip of the nameserver
257 ... if available in the console-log output. The keyword will also return a list of the learned ips as it
258 ... finds them in the console log output, and will have "None" for Vms that no ip was found.
259 ${devstack_conn_id}= Get ControlNode Connection
260 Switch Connection ${devstack_conn_id}
261 ${ip_list} Create List @{EMPTY}
262 : FOR ${vm} IN @{vm_list}
263 \ ${vm_ip_line}= Write Commands Until Prompt nova console-log ${vm} | grep -i "obtained" 30s
265 \ @{vm_ip} Get Regexp Matches ${vm_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
266 \ ${vm_ip_length} Get Length ${vm_ip}
267 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip}[0]
268 \ ... ELSE Append To List ${ip_list} None
269 \ ${dhcp_ip_line}= Write Commands Until Prompt nova console-log ${vm} | grep "^nameserver" 30s
270 \ Log ${dhcp_ip_line}
271 \ ${dhcp_ip} Get Regexp Matches ${dhcp_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
272 \ ${dhcp_ip_length} Get Length ${dhcp_ip}
273 \ Run Keyword If ${dhcp_ip_length}<=0 Append To List ${dhcp_ip} None
275 ${dhcp_length} Get Length ${dhcp_ip}
276 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${ip_list} None
277 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${dhcp_ip} None
278 Should Be True ${dhcp_length} <= 1
279 Return From Keyword If ${dhcp_length}==0 ${ip_list} ${EMPTY}
280 [Return] ${ip_list} ${dhcp_ip}
283 [Arguments] ${vm_instance_names}
284 [Documentation] View Console log of the created vm instances using nova show.
285 : FOR ${VmElement} IN @{vm_instance_names}
286 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
288 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
291 Ping Vm From DHCP Namespace
292 [Arguments] ${net_name} ${vm_ip}
293 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
295 ${devstack_conn_id}= Get ControlNode Connection
296 Switch Connection ${devstack_conn_id}
297 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
299 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
302 Should Contain ${output} 64 bytes
304 Ping From DHCP Should Not Succeed
305 [Arguments] ${net_name} ${vm_ip}
306 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
308 ${devstack_conn_id}= Get ControlNode Connection
309 Switch Connection ${devstack_conn_id}
310 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
312 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
315 Should Not Contain ${output} 64 bytes
317 Ping Vm From Control Node
318 [Arguments] ${vm_floating_ip}
319 [Documentation] Ping VM floating IP from control node
320 Log ${vm_floating_ip}
321 ${devstack_conn_id}= Get ControlNode Connection
322 Switch Connection ${devstack_conn_id}
323 ${output}= Write Commands Until Prompt ping -c 3 ${vm_floating_ip} 20s
326 Should Contain ${output} 64 bytes
329 [Arguments] ${dest_vm_ip}
330 [Documentation] Ping to the expected destination ip.
331 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm_ip} ${OS_SYSTEM_PROMPT}
336 [Documentation] Ping to the expected destination ip.
337 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
338 Write Commands Until Prompt exit
339 Should Contain ${output} 200
342 [Documentation] Exit the vm instance.
343 ${output}= Write Commands Until Prompt exit
346 Check If Console Is VmInstance
347 [Arguments] ${console}=cirros
348 [Documentation] Check if the session has been able to login to the VM instance
349 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
350 Should Contain ${output} ${console}
353 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
354 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
355 Run Keyword If ${rcode} Write Commands Until Prompt exit
358 [Arguments] ${ip_address}
359 [Documentation] Run Ping command on the IP available as argument
360 ${output}= Write Commands Until Expected Prompt ping -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
361 Should Contain ${output} 64 bytes
363 Check Metadata Access
364 [Documentation] Try curl on the Metadataurl and check if it is okay
365 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
366 Should Contain ${output} 200
368 Execute Command on VM Instance
369 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
370 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
371 ${devstack_conn_id} = Get ControlNode Connection
372 Switch Connection ${devstack_conn_id}
373 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
375 ${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 d:
377 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
379 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
380 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
381 [Teardown] Exit From Vm Console
384 Test Operations From Vm Instance
385 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:)
386 [Documentation] Login to the vm instance using ssh in the network.
387 ${devstack_conn_id}= Get ControlNode Connection
388 Switch Connection ${devstack_conn_id}
390 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
391 ${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 d:
393 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
395 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
396 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
397 Run Keyword If ${rcode} Write Commands Until Expected Prompt route ${OS_SYSTEM_PROMPT}
398 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
399 : FOR ${dest_ip} IN @{dest_ips}
401 \ ${string_empty}= Run Keyword And Return Status Should Be Empty ${dest_ip}
402 \ Run Keyword If ${string_empty} Continue For Loop
403 \ Run Keyword If ${rcode} Check Ping ${dest_ip}
404 Run Keyword If ${rcode} Check Metadata Access
405 [Teardown] Exit From Vm Console
407 Install Netcat On Controller
408 [Documentation] Installs Netcat on the controller - this probably shouldn't be here
409 ${devstack_conn_id}= Get ControlNode Connection
410 Switch Connection ${devstack_conn_id}
411 ${output}= Write Commands Until Prompt sudo yum install -y nc
415 Test Netcat Operations From Vm Instance
416 [Arguments] ${net_name} ${vm_ip} ${dest_ip} ${additional_args}=${EMPTY} ${port}=12345 ${user}=cirros
417 ... ${password}=cubswin:)
418 [Documentation] Use Netcat to test TCP/UDP connections to the controller
419 ${client_data} Set Variable Test Client Data
420 ${server_data} Set Variable Test Server Data
421 ${devstack_conn_id}= Get ControlNode Connection
422 Switch Connection ${devstack_conn_id}
424 ${output}= Write Commands Until Prompt ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
426 ${output}= Write Commands Until Prompt sudo netstat -nlap | grep ${port}
428 ${nc_output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo echo "${client_data}" | nc -v -w 5 ${additional_args} ${dest_ip} ${port}
430 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo route -n
432 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo arp -an
434 Should Match Regexp ${nc_output} ${server_data}
437 [Arguments] ${list_of_external_dst_ips}
438 [Documentation] Check reachability with other network's instances.
439 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
440 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
442 \ Check Ping ${dest_ip}
445 [Arguments] ${router_name}
446 [Documentation] Create Router and Add Interface to the subnets.
447 ${devstack_conn_id}= Get ControlNode Connection
448 Switch Connection ${devstack_conn_id}
449 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name} 30s
451 Should Contain ${output} Created a new router
454 [Documentation] List Router and return output with neutron client.
455 ${devstack_conn_id}= Get ControlNode Connection
456 Switch Connection ${devstack_conn_id}
457 ${output}= Write Commands Until Prompt neutron router-list 30s
463 [Arguments] ${router_name} ${interface_name}
464 ${devstack_conn_id}= Get ControlNode Connection
465 Switch Connection ${devstack_conn_id}
466 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
468 Should Contain ${output} Added interface
470 Show Router Interface
471 [Arguments] ${router_name}
472 [Documentation] List Router interface associated with given Router and return output with neutron client.
473 ${devstack_conn_id}= Get ControlNode Connection
474 Switch Connection ${devstack_conn_id}
475 ${output}= Write Commands Until Prompt neutron router-port-list ${router_name} -f csv 30s
481 [Arguments] ${router_name} ${network_name}
482 ${devstack_conn_id}= Get ControlNode Connection
483 Switch Connection ${devstack_conn_id}
484 ${output}= Write Commands Until Prompt neutron -v router-gateway-set ${router_name} ${network_name}
486 Should Contain ${output} Set gateway
489 [Arguments] ${router_name} ${interface_name}
490 [Documentation] Remove Interface to the subnets.
491 ${devstack_conn_id}= Get ControlNode Connection
492 Switch Connection ${devstack_conn_id}
493 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
495 Should Contain ${output} Removed interface from router
498 [Arguments] ${router_name} ${cmd}
499 [Documentation] Update the router with the command. Router name and command should be passed as argument.
500 ${devstack_conn_id} = Get ControlNode Connection
501 Switch Connection ${devstack_conn_id}
502 ${output} = Write Commands Until Prompt neutron router-update ${router_name} ${cmd} 30s
504 Should Contain ${output} Updated
507 [Arguments] ${router_name} ${options}
508 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
509 ${devstack_conn_id} = Get ControlNode Connection
510 Switch Connection ${devstack_conn_id}
511 ${output} = Write Commands Until Prompt neutron router-show ${router_name} ${options} 30s
516 [Arguments] ${router_name}
517 [Documentation] Delete Router and Interface to the subnets.
518 ${devstack_conn_id}= Get ControlNode Connection
519 Switch Connection ${devstack_conn_id}
520 ${output}= Write Commands Until Prompt neutron -v router-delete ${router_name} 60s
522 Should Match Regexp ${output} Deleted router: ${router_name}|Deleted router\\(s\\): ${router_name}
524 Get DumpFlows And Ovsconfig
525 [Arguments] ${openstack_node_ip}
526 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
527 Log ${openstack_node_ip}
528 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
529 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
530 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
531 Write Commands Until Expected Prompt ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
532 Write Commands Until Expected Prompt ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
533 Write Commands Until Expected Prompt ip route ${DEFAULT_LINUX_PROMPT_STRICT}
534 Write Commands Until Expected Prompt arp -an ${DEFAULT_LINUX_PROMPT_STRICT}
535 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ${DEFAULT_LINUX_PROMPT_STRICT}
536 @{lines} Split To Lines ${nslist}
537 : FOR ${line} IN @{lines}
538 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
539 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
540 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT}
541 Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
542 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
543 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
544 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
545 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
546 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
548 Get Karaf Log Type From Test Start
549 [Arguments] ${ip} ${test_name} ${type} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
550 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
551 ${cmd} Set Variable sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
552 ${output} Run Command On Controller ${ip} ${cmd} ${user} ${password} ${prompt}
555 Get Karaf Log Types From Test Start
556 [Arguments] ${ip} ${test_name} ${types} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
557 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
558 : FOR ${type} IN @{types}
559 \ Get Karaf Log Type From Test Start ${ip} ${test_name} ${type} ${user} ${password}
560 \ ... ${prompt} ${log_file}
562 Get Karaf Log Events From Test Start
563 [Arguments] ${test_name} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
564 ${log_types} = Create List ERROR WARN Exception
565 Run Keyword If 0 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_IP} ${test_name} ${log_types}
566 Run Keyword If 1 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_2_IP} ${test_name} ${log_types}
567 Run Keyword If 2 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_3_IP} ${test_name} ${log_types}
569 Get ControlNode Connection
570 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
571 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
572 SSHLibrary.Set Client Configuration timeout=30s
573 Source Password force=yes
574 [Return] ${control_conn_id}
577 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
578 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
579 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
580 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
582 Get Test Teardown Debugs
583 [Arguments] ${test_name}=${TEST_NAME}
585 Run Keyword And Ignore Error Get Model Dump ${HA_PROXY_IP}
586 Get Karaf Log Events From Test Start ${test_name}
588 Get Suite Teardown Debugs
590 Get Model Dump ${HA_PROXY_IP}
593 [Arguments] @{vm_indices}
594 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
595 ${devstack_conn_id}= Get ControlNode Connection
596 Switch Connection ${devstack_conn_id}
597 ${output}= Write Commands Until Prompt sudo ip netns list
599 : FOR ${index} IN @{vm_indices}
600 \ ${output}= Write Commands Until Prompt nova show ${index} 30s
608 Create Security Group
609 [Arguments] ${sg_name} ${desc}
610 ${devstack_conn_id}= Get ControlNode Connection
611 Switch Connection ${devstack_conn_id}
612 ${output}= Write Commands Until Prompt nova secgroup-create ${sg_name} ${desc} 40s
616 [Arguments] ${direction} ${protocol} ${min_port} ${max_port} ${remote_ip} ${sg_name}
617 ${devstack_conn_id}= Get ControlNode Connection
618 Switch Connection ${devstack_conn_id}
619 ${output}= Write Commands Until Prompt neutron security-group-rule-create --direction ${direction} --protocol ${protocol} --port-range-min ${min_port} --port-range-max ${max_port} --remote-ip-prefix ${remote_ip} ${sg_name}
622 Neutron Security Group Show
623 [Arguments] ${SecurityGroupRuleName} ${additional_args}=${EMPTY}
624 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
625 ${devstack_conn_id}= Get ControlNode Connection
626 Switch Connection ${devstack_conn_id}
627 ${cmd}= Set Variable neutron security-group-show ${SecurityGroupRuleName} ${additional_args}
629 ${output}= Write Commands Until Prompt ${cmd} 30s
635 [Arguments] ${PortName} ${additional_args}=${EMPTY}
636 [Documentation] Display the port configuration that belong to a given neutron port
637 ${devstack_conn_id}= Get ControlNode Connection
638 Switch Connection ${devstack_conn_id}
639 ${cmd}= Set Variable neutron port-show ${PortName} ${additional_args}
641 ${output}= Write Commands Until Prompt ${cmd} 30s
646 Neutron Security Group Create
647 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
648 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
649 ${devstack_conn_id}= Get ControlNode Connection
650 Switch Connection ${devstack_conn_id}
651 ${cmd}= Set Variable neutron security-group-create ${SecurityGroupName} ${additional_args}
653 ${output}= Write Commands Until Prompt ${cmd} 30s
655 Should Contain ${output} Created a new security_group
656 ${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}
659 [Return] ${output} ${sgp_id}
661 Neutron Security Group Update
662 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
663 [Documentation] Updating security groups
664 ${devstack_conn_id}= Get ControlNode Connection
665 Switch Connection ${devstack_conn_id}
666 ${cmd}= Set Variable neutron security-group-update ${SecurityGroupName} ${additional_args}
668 ${output}= Write Commands Until Prompt ${cmd} 30s
674 [Arguments] ${sg_name}
675 [Documentation] Delete Security group
676 ${devstack_conn_id}= Get ControlNode Connection
677 Switch Connection ${devstack_conn_id}
678 ${output}= Write Commands Until Prompt neutron security-group-delete ${sg_name} 40s
680 Should Match Regexp ${output} Deleted security_group: ${sg_name}|Deleted security_group\\(s\\): ${sg_name}
683 Neutron Security Group Rule Create
684 [Arguments] ${Security_group_name} &{Kwargs}
685 [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]} ..."
686 ${devstack_conn_id}= Get ControlNode Connection
687 Switch Connection ${devstack_conn_id}
688 Run Keyword If ${Kwargs} Log ${Kwargs}
689 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
690 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
691 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
692 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
693 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
694 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
695 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
696 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
697 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
698 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
699 ... ELSE Catenate ${cmd}
700 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
701 ... ELSE Catenate ${cmd}
702 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
703 ... ELSE Catenate ${cmd}
704 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
705 ... ELSE Catenate ${cmd}
706 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
707 ... ELSE Catenate ${cmd}
708 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
709 ... ELSE Catenate ${cmd}
710 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
711 ... ELSE Catenate ${cmd}
712 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
713 ... ELSE Catenate ${cmd}
714 ${output}= Write Commands Until Prompt ${cmd} 30s
715 ${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}
717 Should Contain ${output} Created a new security_group_rule
719 [Return] ${output} ${rule_id}
721 Create Neutron Port With Additional Params
722 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
723 [Documentation] Create Port With given additional parameters
724 ${devstack_conn_id}= Get ControlNode Connection
725 Switch Connection ${devstack_conn_id}
726 ${cmd}= Set Variable neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
728 ${OUTPUT}= Write Commands Until Prompt ${cmd} 30s
730 Should Contain ${output} Created a new port
731 ${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}
734 [Return] ${OUTPUT} ${port_id}
737 [Arguments] ${portName_list}
738 [Documentation] Retrieve the port MacAddr for the given list of port name and return the MAC address list.
739 ${devstack_conn_id}= Get ControlNode Connection
740 Switch Connection ${devstack_conn_id}
741 ${MacAddr-list} Create List
742 : FOR ${portName} IN @{portName_list}
743 \ ${macAddr}= OpenStackOperations.Get Port Mac ${portName} ${devstack_conn_id}
744 \ Append To List ${MacAddr-list} ${macAddr}
745 [Return] ${MacAddr-list}
748 [Arguments] ${port_name}
749 [Documentation] Keyword would return the IP of the ${port_name} received.
750 Switch Connection ${devstack_conn_id}
751 ${output}= Write Commands Until Prompt neutron port-list | grep "${port_name}" | awk '{print $11}' | awk -F "\\"" '{print $2}' 30s
753 ${splitted_output}= Split String ${output} ${EMPTY}
754 ${port_ip}= Get from List ${splitted_output} 0
759 [Arguments] ${port_name} ${conn_id}=${devstack_conn_id}
760 [Documentation] Keyword would return the MAC ID of the ${port_name} received.
761 Switch Connection ${conn_id}
762 ${output}= Write Commands Until Prompt neutron port-list | grep "${port_name}" | awk '{print $6}' 30s
764 ${splitted_output}= Split String ${output} ${EMPTY}
765 ${port_mac}= Get from List ${splitted_output} 0
770 [Arguments] ${bridge_name} ${intf_name} ${gw_name}
771 [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
772 Switch Connection ${devstack_conn_id}
773 ${l2gw_output}= Write Commands Until Prompt ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name} 30s
775 [Return] ${l2gw_output}
777 Create L2Gateway Connection
778 [Arguments] ${gw_name} ${net_name}
779 [Documentation] Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
780 Switch Connection ${devstack_conn_id}
781 ${l2gw_output}= Write Commands Until Prompt ${L2GW_CONN_CREATE} ${gw_name} ${net_name} 30s
783 [Return] ${l2gw_output}
786 [Documentation] Keyword to return all the L2 Gateways available (Using Neutron CLI).
787 Switch Connection ${devstack_conn_id}
788 ${output}= Write Commands Until Prompt ${L2GW_GET_YAML} 30s
791 Get All L2Gateway Connection
792 [Documentation] Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
793 Switch Connection ${devstack_conn_id}
794 ${output}= Write Commands Until Prompt ${L2GW_GET_CONN_YAML} 30s
799 [Documentation] Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
800 Switch Connection ${devstack_conn_id}
801 ${output}= Write Commands Until Prompt ${L2GW_SHOW} ${gw_id} 30s
806 [Arguments] ${l2gw_name}
807 [Documentation] Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
808 Switch Connection ${devstack_conn_id}
809 ${output}= Write Commands Until Prompt ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}' 30s
811 ${splitted_output}= Split String ${output} ${EMPTY}
812 ${l2gw_id}= Get from List ${splitted_output} 0
816 Get L2gw Connection Id
817 [Arguments] ${l2gw_name}
818 [Documentation] Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
819 Switch Connection ${devstack_conn_id}
820 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${l2gw_name}
821 ${output}= Write Commands Until Prompt ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}' 30s
823 ${splitted_output}= Split String ${output} ${EMPTY}
824 ${l2gw_conn_id}= Get from List ${splitted_output} 0
826 [Return] ${l2gw_conn_id}
828 Neutron Port List Rest
829 [Documentation] Keyword to get all ports details in Neutron (Using REST).
830 ${resp} = RequestsLibrary.Get Request session ${PORT_URL}
832 Should Be Equal As Strings ${resp.status_code} 200
833 [Return] ${resp.content}
835 Get Neutron Port Rest
836 [Arguments] ${port_id}
837 [Documentation] Keyword to get the specific port details in Neutron (Using REST).
838 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id}
840 Should Be Equal As Strings ${resp.status_code} 200
841 [Return] ${resp.content}
844 [Arguments] ${port_id} ${json_data}
845 [Documentation] Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
847 ${resp} = RequestsLibrary.Put Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id} ${json_data}
849 Should Be Equal As Strings ${resp.status_code} 200
850 [Return] ${resp.content}
852 Create And Configure Security Group
853 [Arguments] ${sg-name}
854 Neutron Security Group Create ${sg-name}
855 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
856 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
857 Neutron Security Group Rule Create ${sg-name} direction=ingress protocol=icmp remote_ip_prefix=0.0.0.0/0
858 Neutron Security Group Rule Create ${sg-name} direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0
859 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
860 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