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 Verify VMs Received DHCP Lease
254 [Arguments] @{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 ${dhcp_ip} Create List @{EMPTY}
263 : FOR ${vm} IN @{vm_list}
264 \ ${vm_ip_line}= Write Commands Until Prompt nova console-log ${vm} | grep -i "obtained" 30s
266 \ @{vm_ip} Get Regexp Matches ${vm_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
267 \ ${vm_ip_length} Get Length ${vm_ip}
268 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip}[0]
269 \ ... ELSE Append To List ${ip_list} None
270 \ ${dhcp_ip_line}= Write Commands Until Prompt nova console-log ${vm} | grep "^nameserver" 30s
271 \ Log ${dhcp_ip_line}
272 \ @{dhcp_ip} Get Regexp Matches ${dhcp_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
273 \ ${dhcp_ip_length} Get Length ${dhcp_ip}
274 \ Run Keyword If ${dhcp_ip_length}<=0 Append To List ${dhcp_ip} None
276 ${dhcp_length} Get Length ${dhcp_ip}
277 Return From Keyword If ${dhcp_length}==0 ${ip_list} ${EMPTY}
278 [Return] ${ip_list} @{dhcp_ip}[0]
281 [Arguments] ${vm_instance_names}
282 [Documentation] View Console log of the created vm instances using nova show.
283 : FOR ${VmElement} IN @{vm_instance_names}
284 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
286 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
289 Ping Vm From DHCP Namespace
290 [Arguments] ${net_name} ${vm_ip}
291 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
293 ${devstack_conn_id}= Get ControlNode Connection
294 Switch Connection ${devstack_conn_id}
295 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
297 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
300 Should Contain ${output} 64 bytes
302 Ping From DHCP Should Not Succeed
303 [Arguments] ${net_name} ${vm_ip}
304 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
306 ${devstack_conn_id}= Get ControlNode Connection
307 Switch Connection ${devstack_conn_id}
308 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
310 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
313 Should Not Contain ${output} 64 bytes
315 Ping Vm From Control Node
316 [Arguments] ${vm_floating_ip}
317 [Documentation] Ping VM floating IP from control node
318 Log ${vm_floating_ip}
319 ${devstack_conn_id}= Get ControlNode Connection
320 Switch Connection ${devstack_conn_id}
321 ${output}= Write Commands Until Prompt ping -c 3 ${vm_floating_ip} 20s
324 Should Contain ${output} 64 bytes
327 [Arguments] ${dest_vm_ip}
328 [Documentation] Ping to the expected destination ip.
329 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm_ip} ${OS_SYSTEM_PROMPT}
334 [Documentation] Ping to the expected destination ip.
335 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
336 Write Commands Until Prompt exit
337 Should Contain ${output} 200
340 [Documentation] Exit the vm instance.
341 ${output}= Write Commands Until Prompt exit
344 Check If Console Is VmInstance
345 [Arguments] ${console}=cirros
346 [Documentation] Check if the session has been able to login to the VM instance
347 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
348 Should Contain ${output} ${console}
351 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
352 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
353 Run Keyword If ${rcode} Write Commands Until Prompt exit
356 [Arguments] ${ip_address}
357 [Documentation] Run Ping command on the IP available as argument
358 ${output}= Write Commands Until Expected Prompt ping -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
359 Should Contain ${output} 64 bytes
361 Check Metadata Access
362 [Documentation] Try curl on the Metadataurl and check if it is okay
363 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
364 Should Contain ${output} 200
366 Execute Command on VM Instance
367 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
368 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
369 ${devstack_conn_id} = Get ControlNode Connection
370 Switch Connection ${devstack_conn_id}
371 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
373 ${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:
375 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
377 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
378 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
379 [Teardown] Exit From Vm Console
382 Test Operations From Vm Instance
383 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:)
384 [Documentation] Login to the vm instance using ssh in the network.
385 ${devstack_conn_id}= Get ControlNode Connection
386 Switch Connection ${devstack_conn_id}
388 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
389 ${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:
391 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
393 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
394 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
395 Run Keyword If ${rcode} Write Commands Until Expected Prompt route ${OS_SYSTEM_PROMPT}
396 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
397 : FOR ${dest_ip} IN @{dest_ips}
399 \ ${string_empty}= Run Keyword And Return Status Should Be Empty ${dest_ip}
400 \ Run Keyword If ${string_empty} Continue For Loop
401 \ Run Keyword If ${rcode} Check Ping ${dest_ip}
402 Run Keyword If ${rcode} Check Metadata Access
403 [Teardown] Exit From Vm Console
405 Install Netcat On Controller
406 [Documentation] Installs Netcat on the controller - this probably shouldn't be here
407 ${devstack_conn_id}= Get ControlNode Connection
408 Switch Connection ${devstack_conn_id}
409 ${output}= Write Commands Until Prompt sudo yum install -y nc
413 Test Netcat Operations From Vm Instance
414 [Arguments] ${net_name} ${vm_ip} ${dest_ip} ${additional_args}=${EMPTY} ${port}=12345 ${user}=cirros
415 ... ${password}=cubswin:)
416 [Documentation] Use Netcat to test TCP/UDP connections to the controller
417 ${client_data} Set Variable Test Client Data
418 ${server_data} Set Variable Test Server Data
419 ${devstack_conn_id}= Get ControlNode Connection
420 Switch Connection ${devstack_conn_id}
422 ${output}= Write Commands Until Prompt ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
424 ${output}= Write Commands Until Prompt sudo netstat -nlap | grep ${port}
426 ${nc_output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo echo "${client_data}" | nc -v -w 5 ${additional_args} ${dest_ip} ${port}
428 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo route -n
430 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo arp -an
432 Should Match Regexp ${nc_output} ${server_data}
435 [Arguments] ${list_of_external_dst_ips}
436 [Documentation] Check reachability with other network's instances.
437 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
438 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
440 \ Check Ping ${dest_ip}
443 [Arguments] ${router_name}
444 [Documentation] Create Router and Add Interface to the subnets.
445 ${devstack_conn_id}= Get ControlNode Connection
446 Switch Connection ${devstack_conn_id}
447 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name} 30s
449 Should Contain ${output} Created a new router
452 [Documentation] List Router and return output with neutron client.
453 ${devstack_conn_id}= Get ControlNode Connection
454 Switch Connection ${devstack_conn_id}
455 ${output}= Write Commands Until Prompt neutron router-list 30s
461 [Arguments] ${router_name} ${interface_name}
462 ${devstack_conn_id}= Get ControlNode Connection
463 Switch Connection ${devstack_conn_id}
464 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
466 Should Contain ${output} Added interface
468 Show Router Interface
469 [Arguments] ${router_name}
470 [Documentation] List Router interface associated with given Router and return output with neutron client.
471 ${devstack_conn_id}= Get ControlNode Connection
472 Switch Connection ${devstack_conn_id}
473 ${output}= Write Commands Until Prompt neutron router-port-list ${router_name} -f csv 30s
479 [Arguments] ${router_name} ${network_name}
480 ${devstack_conn_id}= Get ControlNode Connection
481 Switch Connection ${devstack_conn_id}
482 ${output}= Write Commands Until Prompt neutron -v router-gateway-set ${router_name} ${network_name}
484 Should Contain ${output} Set gateway
487 [Arguments] ${router_name} ${interface_name}
488 [Documentation] Remove Interface to the subnets.
489 ${devstack_conn_id}= Get ControlNode Connection
490 Switch Connection ${devstack_conn_id}
491 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
493 Should Contain ${output} Removed interface from router
496 [Arguments] ${router_name} ${cmd}
497 [Documentation] Update the router with the command. Router name and command should be passed as argument.
498 ${devstack_conn_id} = Get ControlNode Connection
499 Switch Connection ${devstack_conn_id}
500 ${output} = Write Commands Until Prompt neutron router-update ${router_name} ${cmd} 30s
502 Should Contain ${output} Updated
505 [Arguments] ${router_name} ${options}
506 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
507 ${devstack_conn_id} = Get ControlNode Connection
508 Switch Connection ${devstack_conn_id}
509 ${output} = Write Commands Until Prompt neutron router-show ${router_name} ${options} 30s
514 [Arguments] ${router_name}
515 [Documentation] Delete Router and Interface to the subnets.
516 ${devstack_conn_id}= Get ControlNode Connection
517 Switch Connection ${devstack_conn_id}
518 ${output}= Write Commands Until Prompt neutron -v router-delete ${router_name} 60s
520 Should Match Regexp ${output} Deleted router: ${router_name}|Deleted router\\(s\\): ${router_name}
522 Get DumpFlows And Ovsconfig
523 [Arguments] ${openstack_node_ip}
524 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
525 Log ${openstack_node_ip}
526 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
527 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
528 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
529 Write Commands Until Expected Prompt ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
530 Write Commands Until Expected Prompt ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
531 Write Commands Until Expected Prompt ip route ${DEFAULT_LINUX_PROMPT_STRICT}
532 Write Commands Until Expected Prompt arp -an ${DEFAULT_LINUX_PROMPT_STRICT}
533 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ${DEFAULT_LINUX_PROMPT_STRICT}
534 @{lines} Split To Lines ${nslist}
535 : FOR ${line} IN @{lines}
536 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
537 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
538 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT}
539 Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
540 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
541 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
542 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
543 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
544 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
546 Get Karaf Log Type From Test Start
547 [Arguments] ${ip} ${test_name} ${type} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
548 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
549 ${cmd} Set Variable sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
550 ${output} Run Command On Controller ${ip} ${cmd} ${user} ${password} ${prompt}
553 Get Karaf Log Types From Test Start
554 [Arguments] ${ip} ${test_name} ${types} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
555 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
556 : FOR ${type} IN @{types}
557 \ Get Karaf Log Type From Test Start ${ip} ${test_name} ${type} ${user} ${password}
558 \ ... ${prompt} ${log_file}
560 Get Karaf Log Events From Test Start
561 [Arguments] ${test_name} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
562 ${log_types} = Create List ERROR WARN Exception
563 Run Keyword If 0 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_IP} ${test_name} ${log_types}
564 Run Keyword If 1 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_2_IP} ${test_name} ${log_types}
565 Run Keyword If 2 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_3_IP} ${test_name} ${log_types}
567 Get ControlNode Connection
568 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
569 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
570 SSHLibrary.Set Client Configuration timeout=30s
571 Source Password force=yes
572 [Return] ${control_conn_id}
575 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
576 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
577 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
578 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
580 Get Test Teardown Debugs
581 [Arguments] ${test_name}=${TEST_NAME}
583 Run Keyword And Ignore Error Get Model Dump ${HA_PROXY_IP}
584 Get Karaf Log Events From Test Start ${test_name}
586 Get Suite Teardown Debugs
588 Get Model Dump ${HA_PROXY_IP}
591 [Arguments] @{vm_indices}
592 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
593 ${devstack_conn_id}= Get ControlNode Connection
594 Switch Connection ${devstack_conn_id}
595 ${output}= Write Commands Until Prompt sudo ip netns list
597 : FOR ${index} IN @{vm_indices}
598 \ ${output}= Write Commands Until Prompt nova show ${index} 30s
606 Create Security Group
607 [Arguments] ${sg_name} ${desc}
608 ${devstack_conn_id}= Get ControlNode Connection
609 Switch Connection ${devstack_conn_id}
610 ${output}= Write Commands Until Prompt nova secgroup-create ${sg_name} ${desc} 40s
614 [Arguments] ${direction} ${protocol} ${min_port} ${max_port} ${remote_ip} ${sg_name}
615 ${devstack_conn_id}= Get ControlNode Connection
616 Switch Connection ${devstack_conn_id}
617 ${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}
620 Neutron Security Group Show
621 [Arguments] ${SecurityGroupRuleName} ${additional_args}=${EMPTY}
622 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
623 ${devstack_conn_id}= Get ControlNode Connection
624 Switch Connection ${devstack_conn_id}
625 ${cmd}= Set Variable neutron security-group-show ${SecurityGroupRuleName} ${additional_args}
627 ${output}= Write Commands Until Prompt ${cmd} 30s
633 [Arguments] ${PortName} ${additional_args}=${EMPTY}
634 [Documentation] Display the port configuration that belong to a given neutron port
635 ${devstack_conn_id}= Get ControlNode Connection
636 Switch Connection ${devstack_conn_id}
637 ${cmd}= Set Variable neutron port-show ${PortName} ${additional_args}
639 ${output}= Write Commands Until Prompt ${cmd} 30s
644 Neutron Security Group Create
645 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
646 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
647 ${devstack_conn_id}= Get ControlNode Connection
648 Switch Connection ${devstack_conn_id}
649 ${cmd}= Set Variable neutron security-group-create ${SecurityGroupName} ${additional_args}
651 ${output}= Write Commands Until Prompt ${cmd} 30s
653 Should Contain ${output} Created a new security_group
654 ${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}
657 [Return] ${output} ${sgp_id}
659 Neutron Security Group Update
660 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
661 [Documentation] Updating security groups
662 ${devstack_conn_id}= Get ControlNode Connection
663 Switch Connection ${devstack_conn_id}
664 ${cmd}= Set Variable neutron security-group-update ${SecurityGroupName} ${additional_args}
666 ${output}= Write Commands Until Prompt ${cmd} 30s
672 [Arguments] ${sg_name}
673 [Documentation] Delete Security group
674 ${devstack_conn_id}= Get ControlNode Connection
675 Switch Connection ${devstack_conn_id}
676 ${output}= Write Commands Until Prompt neutron security-group-delete ${sg_name} 40s
678 Should Match Regexp ${output} Deleted security_group: ${sg_name}|Deleted security_group\\(s\\): ${sg_name}
681 Neutron Security Group Rule Create
682 [Arguments] ${Security_group_name} &{Kwargs}
683 [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]} ..."
684 ${devstack_conn_id}= Get ControlNode Connection
685 Switch Connection ${devstack_conn_id}
686 Run Keyword If ${Kwargs} Log ${Kwargs}
687 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
688 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
689 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
690 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
691 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
692 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
693 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
694 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
695 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
696 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
697 ... ELSE Catenate ${cmd}
698 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
699 ... ELSE Catenate ${cmd}
700 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
701 ... ELSE Catenate ${cmd}
702 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
703 ... ELSE Catenate ${cmd}
704 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
705 ... ELSE Catenate ${cmd}
706 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
707 ... ELSE Catenate ${cmd}
708 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
709 ... ELSE Catenate ${cmd}
710 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
711 ... ELSE Catenate ${cmd}
712 ${output}= Write Commands Until Prompt ${cmd} 30s
713 ${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}
715 Should Contain ${output} Created a new security_group_rule
717 [Return] ${output} ${rule_id}
719 Create Neutron Port With Additional Params
720 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
721 [Documentation] Create Port With given additional parameters
722 ${devstack_conn_id}= Get ControlNode Connection
723 Switch Connection ${devstack_conn_id}
724 ${cmd}= Set Variable neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
726 ${OUTPUT}= Write Commands Until Prompt ${cmd} 30s
728 Should Contain ${output} Created a new port
729 ${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}
732 [Return] ${OUTPUT} ${port_id}
735 [Arguments] ${portName_list}
736 [Documentation] Retrieve the port MacAddr for the given list of port name and return the MAC address list.
737 ${devstack_conn_id}= Get ControlNode Connection
738 Switch Connection ${devstack_conn_id}
739 ${MacAddr-list} Create List
740 : FOR ${portName} IN @{portName_list}
741 \ ${macAddr}= OpenStackOperations.Get Port Mac ${portName} ${devstack_conn_id}
742 \ Append To List ${MacAddr-list} ${macAddr}
743 [Return] ${MacAddr-list}
746 [Arguments] ${port_name}
747 [Documentation] Keyword would return the IP of the ${port_name} received.
748 Switch Connection ${devstack_conn_id}
749 ${output}= Write Commands Until Prompt neutron port-list | grep "${port_name}" | awk '{print $11}' | awk -F "\\"" '{print $2}' 30s
751 ${splitted_output}= Split String ${output} ${EMPTY}
752 ${port_ip}= Get from List ${splitted_output} 0
757 [Arguments] ${port_name} ${conn_id}=${devstack_conn_id}
758 [Documentation] Keyword would return the MAC ID of the ${port_name} received.
759 Switch Connection ${conn_id}
760 ${output}= Write Commands Until Prompt neutron port-list | grep "${port_name}" | awk '{print $6}' 30s
762 ${splitted_output}= Split String ${output} ${EMPTY}
763 ${port_mac}= Get from List ${splitted_output} 0
768 [Arguments] ${bridge_name} ${intf_name} ${gw_name}
769 [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
770 Switch Connection ${devstack_conn_id}
771 ${l2gw_output}= Write Commands Until Prompt ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name} 30s
773 [Return] ${l2gw_output}
775 Create L2Gateway Connection
776 [Arguments] ${gw_name} ${net_name}
777 [Documentation] Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
778 Switch Connection ${devstack_conn_id}
779 ${l2gw_output}= Write Commands Until Prompt ${L2GW_CONN_CREATE} ${gw_name} ${net_name} 30s
781 [Return] ${l2gw_output}
784 [Documentation] Keyword to return all the L2 Gateways available (Using Neutron CLI).
785 Switch Connection ${devstack_conn_id}
786 ${output}= Write Commands Until Prompt ${L2GW_GET_YAML} 30s
789 Get All L2Gateway Connection
790 [Documentation] Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
791 Switch Connection ${devstack_conn_id}
792 ${output}= Write Commands Until Prompt ${L2GW_GET_CONN_YAML} 30s
797 [Documentation] Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
798 Switch Connection ${devstack_conn_id}
799 ${output}= Write Commands Until Prompt ${L2GW_SHOW} ${gw_id} 30s
804 [Arguments] ${l2gw_name}
805 [Documentation] Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
806 Switch Connection ${devstack_conn_id}
807 ${output}= Write Commands Until Prompt ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}' 30s
809 ${splitted_output}= Split String ${output} ${EMPTY}
810 ${l2gw_id}= Get from List ${splitted_output} 0
814 Get L2gw Connection Id
815 [Arguments] ${l2gw_name}
816 [Documentation] Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
817 Switch Connection ${devstack_conn_id}
818 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${l2gw_name}
819 ${output}= Write Commands Until Prompt ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}' 30s
821 ${splitted_output}= Split String ${output} ${EMPTY}
822 ${l2gw_conn_id}= Get from List ${splitted_output} 0
824 [Return] ${l2gw_conn_id}
826 Neutron Port List Rest
827 [Documentation] Keyword to get all ports details in Neutron (Using REST).
828 ${resp} = RequestsLibrary.Get Request session ${PORT_URL}
830 Should Be Equal As Strings ${resp.status_code} 200
831 [Return] ${resp.content}
833 Get Neutron Port Rest
834 [Arguments] ${port_id}
835 [Documentation] Keyword to get the specific port details in Neutron (Using REST).
836 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id}
838 Should Be Equal As Strings ${resp.status_code} 200
839 [Return] ${resp.content}
842 [Arguments] ${port_id} ${json_data}
843 [Documentation] Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
845 ${resp} = RequestsLibrary.Put Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id} ${json_data}
847 Should Be Equal As Strings ${resp.status_code} 200
848 [Return] ${resp.content}
850 Create And Configure Security Group
851 [Arguments] ${sg-name}
852 Neutron Security Group Create ${sg-name}
853 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
854 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
855 Neutron Security Group Rule Create ${sg-name} direction=ingress protocol=icmp remote_ip_prefix=0.0.0.0/0
856 Neutron Security Group Rule Create ${sg-name} direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0
857 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
858 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