2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
6 Resource ../variables/Variables.robot
10 [Arguments] ${force}=no ${source_pwd}=yes
11 [Documentation] Sourcing the Openstack PAsswords for neutron configurations
12 Run Keyword If '${source_pwd}' == 'yes' or '${force}' == 'yes' Write Commands Until Prompt cd ${DEVSTACK_DEPLOY_PATH}; source openrc admin admin
14 Get Tenant ID From Security Group
15 [Documentation] Returns tenant ID by reading it from existing default security-group.
16 ${devstack_conn_id}= Get ControlNode Connection
17 Switch Connection ${devstack_conn_id}
18 ${output}= Write Commands Until Prompt neutron security-group-show default | grep "| tenant_id" | awk '{print $4}'
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 ${devstack_conn_id}= Get ControlNode Connection
33 Switch Connection ${devstack_conn_id}
34 ${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}'
35 ${output}= Write Commands Until Prompt ${command} 30s
40 [Documentation] List networks and return output with neutron client.
41 ${devstack_conn_id}= Get ControlNode Connection
42 Switch Connection ${devstack_conn_id}
43 ${output}= Write Commands Until Prompt neutron net-list 30s
49 [Documentation] List subnets and return output with neutron client.
50 ${devstack_conn_id}= Get ControlNode Connection
51 Switch Connection ${devstack_conn_id}
52 ${output}= Write Commands Until Prompt neutron subnet-list 30s
58 [Arguments] ${network_name}
59 [Documentation] Delete Network with neutron request.
60 ${devstack_conn_id}= Get ControlNode Connection
61 Switch Connection ${devstack_conn_id}
62 ${output}= Write Commands Until Prompt neutron -v net-delete ${network_name} 30s
65 Should Match Regexp ${output} Deleted network: ${network_name}|Deleted network\\(s\\): ${network_name}
68 [Arguments] ${network_name} ${subnet} ${range_ip} ${additional_args}=${EMPTY}
69 [Documentation] Create SubNet for the Network with neutron request.
70 ${devstack_conn_id}= Get ControlNode Connection
71 Switch Connection ${devstack_conn_id}
72 ${output}= Write Commands Until Prompt neutron -v subnet-create ${network_name} ${range_ip} --name ${subnet} ${additional_args} 30s
75 Should Contain ${output} Created a new subnet
78 [Arguments] ${network_name} ${port_name} ${sg}=default
79 [Documentation] Create Port with neutron request.
80 ${devstack_conn_id}= Get ControlNode Connection
81 Switch Connection ${devstack_conn_id}
82 ${output}= Write Commands Until Prompt neutron -v port-create ${network_name} --name ${port_name} --security-group ${sg} 30s
85 Should Contain ${output} Created a new port
88 [Arguments] ${port_name}
89 [Documentation] Delete Port with neutron request.
90 ${devstack_conn_id}= Get ControlNode Connection
91 Switch Connection ${devstack_conn_id}
92 ${output}= Write Commands Until Prompt neutron -v port-delete ${port_name} 30s
95 Should Match Regexp ${output} Deleted port: ${port_name}|Deleted port\\(s\\): ${port_name}
98 [Documentation] List ports and return output with neutron client.
99 ${devstack_conn_id}= Get ControlNode Connection
100 Switch Connection ${devstack_conn_id}
101 ${output}= Write Commands Until Prompt neutron port-list 30s
107 [Documentation] List VMs and return output with nova client.
108 ${devstack_conn_id}= Get ControlNode Connection
109 Switch Connection ${devstack_conn_id}
110 ${output}= Write Commands Until Prompt nova list 30s
115 Create And Associate Floating IPs
116 [Arguments] ${external_net} @{vm_list}
117 [Documentation] Create and associate floating IPs to VMs with nova request
118 ${devstack_conn_id}= Get ControlNode Connection
119 Switch Connection ${devstack_conn_id}
120 ${ip_list}= Create List @{EMPTY}
121 : FOR ${vm} IN @{vm_list}
122 \ ${output}= Write Commands Until Prompt neutron floatingip-create ${external_net} 30s
124 \ @{ip} Get Regexp Matches ${output} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
125 \ ${ip_length} Get Length ${ip}
126 \ Run Keyword If ${ip_length}>0 Append To List ${ip_list} @{ip}[0]
127 \ ... ELSE Append To List ${ip_list} None
128 \ ${output}= Write Commands Until Prompt nova floating-ip-associate ${vm} @{ip}[0] 30s
133 [Documentation] Verifies the Gateway Ips with dump flow.
134 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
136 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
137 \ Should Contain ${output} ${GatewayIpElement}
140 [Documentation] Verifies the Dhcp Ips with dump flow.
141 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
143 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
144 \ Should Contain ${output} ${DhcpIpElement}
147 [Documentation] Verifies the Dhcp Ips with dump flow.
148 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
150 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
151 \ Should Not Contain ${output} ${DhcpIpElement}
154 [Arguments] ${subnet}
155 [Documentation] Delete SubNet for the Network with neutron request.
157 ${devstack_conn_id}= Get ControlNode Connection
158 Switch Connection ${devstack_conn_id}
159 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
162 Should Match Regexp ${output} Deleted subnet: ${subnet}|Deleted subnet\\(s\\): ${subnet}
164 Verify No Gateway Ips
165 [Documentation] Verifies the Gateway Ips removed with dump flow.
166 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
168 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
169 \ Should Not Contain ${output} ${GatewayIpElement}
172 [Arguments] ${vm_name}
173 [Documentation] Delete Vm instances using instance names.
174 ${devstack_conn_id}= Get ControlNode Connection
175 Switch Connection ${devstack_conn_id}
176 ${output}= Write Commands Until Prompt nova force-delete ${vm_name} 40s
180 [Arguments] ${network_name} ${devstack_conn_id}
181 [Documentation] Retrieve the net id for the given network name to create specific vm instance
182 Switch Connection ${devstack_conn_id}
183 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | awk '{print $2}' 30s
185 ${splitted_output}= Split String ${output} ${EMPTY}
186 ${net_id}= Get from List ${splitted_output} 0
191 [Arguments] ${subnet_name} ${devstack_conn_id}
192 [Documentation] Retrieve the subnet id for the given subnet name
193 Switch Connection ${devstack_conn_id}
194 ${output}= Write Commands Until Prompt neutron subnet-list | grep "${subnet_name}" | awk '{print $2}' 30s
196 ${splitted_output}= Split String ${output} ${EMPTY}
197 ${subnet_id}= Get from List ${splitted_output} 0
199 [Return] ${subnet_id}
202 [Arguments] ${port_name} ${devstack_conn_id}
203 [Documentation] Retrieve the port id for the given port name to attach specific vm instance to a particular port
204 Switch Connection ${devstack_conn_id}
205 ${output}= Write Commands Until Prompt neutron port-list | grep "${port_name}" | awk '{print $2}' 30s
207 ${splitted_output}= Split String ${output} ${EMPTY}
208 ${port_id}= Get from List ${splitted_output} 0
213 [Arguments] ${router1} ${devstack_conn_id}
214 [Documentation] Retrieve the router id for the given router name
215 Switch Connection ${devstack_conn_id}
216 ${output}= Write Commands Until Prompt neutron router-list | grep "${router1}" | awk '{print $2}' 30s
218 ${splitted_output}= Split String ${output} ${EMPTY}
219 ${router_id}= Get from List ${splitted_output} 0
221 [Return] ${router_id}
224 [Arguments] ${net_name} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
225 [Documentation] Create X Vm Instance with the net id of the Netowrk.
226 ${devstack_conn_id}= Get ControlNode Connection
227 Switch Connection ${devstack_conn_id}
228 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
229 : FOR ${VmElement} IN @{vm_instance_names}
230 \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-groups ${sg} 30s
233 Create Vm Instance With Port On Compute Node
234 [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
235 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
236 ${devstack_conn_id}= Get ControlNode Connection
237 Switch Connection ${devstack_conn_id}
238 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
239 ${hostname_compute_node}= Run Command On Remote System ${compute_node} hostname
240 ${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
244 [Arguments] ${vm_name}
245 [Documentation] Run these commands to check whether the created vm instance is active or not.
246 ${devstack_conn_id}= Get ControlNode Connection
247 Switch Connection ${devstack_conn_id}
248 ${output}= Write Commands Until Prompt nova show ${vm_name} | grep OS-EXT-STS:vm_state 30s
250 Should Contain ${output} active
252 Verify VMs Received DHCP Lease
253 [Arguments] @{vm_list}
254 [Documentation] Using nova console-log on the provided ${vm_list} to search for the string "obtained" which
255 ... correlates to the instance receiving it's IP address via DHCP. Also retrieved is the ip of the nameserver
256 ... if available in the console-log output. The keyword will also return a list of the learned ips as it
257 ... finds them in the console log output, and will have "None" for Vms that no ip was found.
258 ${devstack_conn_id}= Get ControlNode Connection
259 Switch Connection ${devstack_conn_id}
260 ${ip_list} Create List @{EMPTY}
261 ${dhcp_ip} 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}
273 ${dhcp_length} Get Length ${dhcp_ip}
274 Return From Keyword If ${dhcp_length}==0 ${ip_list} ${EMPTY}
275 [Return] ${ip_list} @{dhcp_ip}[0]
278 [Arguments] ${vm_instance_names}
279 [Documentation] View Console log of the created vm instances using nova show.
280 : FOR ${VmElement} IN @{vm_instance_names}
281 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
283 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
286 Ping Vm From DHCP Namespace
287 [Arguments] ${net_name} ${vm_ip}
288 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
290 ${devstack_conn_id}= Get ControlNode Connection
291 Switch Connection ${devstack_conn_id}
292 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
294 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
297 Should Contain ${output} 64 bytes
299 Ping From DHCP Should Not Succeed
300 [Arguments] ${net_name} ${vm_ip}
301 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
303 ${devstack_conn_id}= Get ControlNode Connection
304 Switch Connection ${devstack_conn_id}
305 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
307 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
310 Should Not Contain ${output} 64 bytes
312 Ping Vm From Control Node
313 [Arguments] ${vm_floating_ip}
314 [Documentation] Ping VM floating IP from control node
315 Log ${vm_floating_ip}
316 ${devstack_conn_id}= Get ControlNode Connection
317 Switch Connection ${devstack_conn_id}
318 ${output}= Write Commands Until Prompt ping -c 3 ${vm_floating_ip} 20s
321 Should Contain ${output} 64 bytes
324 [Arguments] ${dest_vm_ip}
325 [Documentation] Ping to the expected destination ip.
326 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm_ip} ${OS_SYSTEM_PROMPT}
331 [Documentation] Ping to the expected destination ip.
332 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
333 Write Commands Until Prompt exit
334 Should Contain ${output} 200
337 [Documentation] Exit the vm instance.
338 ${output}= Write Commands Until Prompt exit
341 Check If Console Is VmInstance
342 [Arguments] ${console}=cirros
343 [Documentation] Check if the session has been able to login to the VM instance
344 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
345 Should Contain ${output} ${console}
348 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
349 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
350 Run Keyword If ${rcode} Write Commands Until Prompt exit
354 [Arguments] ${ip_address}
355 [Documentation] Run Ping command on the IP available as argument
356 ${output}= Write Commands Until Expected Prompt ping -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
357 Should Contain ${output} 64 bytes
359 Check Metadata Access
360 [Documentation] Try curl on the Metadataurl and check if it is okay
361 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
362 Should Contain ${output} 200
364 Execute Command on VM Instance
365 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
366 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
367 ${devstack_conn_id} = Get ControlNode Connection
368 Switch Connection ${devstack_conn_id}
369 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
371 ${output} = Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${vm_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no d:
373 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
375 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
376 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
377 [Teardown] Exit From Vm Console
380 Test Operations From Vm Instance
381 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:)
382 [Documentation] Login to the vm instance using ssh in the network.
383 ${devstack_conn_id}= Get ControlNode Connection
384 Switch Connection ${devstack_conn_id}
386 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
387 ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no ${user}@${src_ip} d:
389 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
391 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
392 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
393 Run Keyword If ${rcode} Write Commands Until Expected Prompt route ${OS_SYSTEM_PROMPT}
394 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
395 : FOR ${dest_ip} IN @{dest_ips}
397 \ ${string_empty}= Run Keyword And Return Status Should Be Empty ${dest_ip}
398 \ Run Keyword If ${string_empty} Continue For Loop
399 \ Run Keyword If ${rcode} Check Ping ${dest_ip}
400 Run Keyword If ${rcode} Check Metadata Access
401 [Teardown] Exit From Vm Console
404 [Arguments] ${list_of_external_dst_ips}
405 [Documentation] Check reachability with other network's instances.
406 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
407 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
409 \ Check Ping ${dest_ip}
412 [Arguments] ${router_name}
413 [Documentation] Create Router and Add Interface to the subnets.
414 ${devstack_conn_id}= Get ControlNode Connection
415 Switch Connection ${devstack_conn_id}
416 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name} 30s
418 Should Contain ${output} Created a new router
421 [Documentation] List Router and return output with neutron client.
422 ${devstack_conn_id}= Get ControlNode Connection
423 Switch Connection ${devstack_conn_id}
424 ${output}= Write Commands Until Prompt neutron router-list 30s
430 [Arguments] ${router_name} ${interface_name}
431 ${devstack_conn_id}= Get ControlNode Connection
432 Switch Connection ${devstack_conn_id}
433 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
435 Should Contain ${output} Added interface
437 Show Router Interface
438 [Arguments] ${router_name}
439 [Documentation] List Router interface associated with given Router and return output with neutron client.
440 ${devstack_conn_id}= Get ControlNode Connection
441 Switch Connection ${devstack_conn_id}
442 ${output}= Write Commands Until Prompt neutron router-port-list ${router_name} -f csv 30s
448 [Arguments] ${router_name} ${network_name}
449 ${devstack_conn_id}= Get ControlNode Connection
450 Switch Connection ${devstack_conn_id}
451 ${output}= Write Commands Until Prompt neutron -v router-gateway-set ${router_name} ${network_name}
453 Should Contain ${output} Set gateway
456 [Arguments] ${router_name} ${interface_name}
457 [Documentation] Remove Interface to the subnets.
458 ${devstack_conn_id}= Get ControlNode Connection
459 Switch Connection ${devstack_conn_id}
460 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
462 Should Contain ${output} Removed interface from router
465 [Arguments] ${router_name} ${cmd}
466 [Documentation] Update the router with the command. Router name and command should be passed as argument.
467 ${devstack_conn_id} = Get ControlNode Connection
468 Switch Connection ${devstack_conn_id}
469 ${output} = Write Commands Until Prompt neutron router-update ${router_name} ${cmd} 30s
471 Should Contain ${output} Updated
474 [Arguments] ${router_name} ${options}
475 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
476 ${devstack_conn_id} = Get ControlNode Connection
477 Switch Connection ${devstack_conn_id}
478 ${output} = Write Commands Until Prompt neutron router-show ${router_name} ${options} 30s
483 [Arguments] ${router_name}
484 [Documentation] Delete Router and Interface to the subnets.
485 ${devstack_conn_id}= Get ControlNode Connection
486 Switch Connection ${devstack_conn_id}
487 ${output}= Write Commands Until Prompt neutron -v router-delete ${router_name} 60s
489 Should Match Regexp ${output} Deleted router: ${router_name}|Deleted router\\(s\\): ${router_name}
491 Get DumpFlows And Ovsconfig
492 [Arguments] ${openstack_node_ip}
493 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
494 Log ${openstack_node_ip}
495 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
496 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
497 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
498 Write Commands Until Expected Prompt ip -o link ]>
499 Write Commands Until Expected Prompt ip -o addr ]>
500 Write Commands Until Expected Prompt ip route ]>
501 Write Commands Until Expected Prompt arp -an ]>
502 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ]>
503 @{lines} Split To Lines ${nslist}
504 : FOR ${line} IN @{lines}
505 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ]>
506 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ]>
507 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ]>
508 Write Commands Until Expected Prompt sudo ovs-vsctl show ]>
509 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ]>
510 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ]>
511 Write Commands Until Expected Prompt sudo ovs-ofctl dump-ports-desc br-int -OOpenFlow13 ]>
512 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ]>
513 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ]>
514 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ]>
516 Get Karaf Log Type From Test Start
517 [Arguments] ${ip} ${test_name} ${type} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
518 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
519 ${cmd} Set Variable sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
520 ${output} Run Command On Controller ${ip} ${cmd} ${user} ${password} ${prompt}
523 Get Karaf Log Types From Test Start
524 [Arguments] ${ip} ${test_name} ${types} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
525 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
526 : FOR ${type} IN @{types}
527 \ Get Karaf Log Type From Test Start ${ip} ${test_name} ${type} ${user} ${password}
528 \ ... ${prompt} ${log_file}
530 Get Karaf Log Events From Test Start
531 [Arguments] ${test_name} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
532 ${log_types} = Create List ERROR WARN Exception
533 Run Keyword If 0 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_IP} ${test_name} ${log_types}
534 Run Keyword If 1 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_2_IP} ${test_name} ${log_types}
535 Run Keyword If 2 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_3_IP} ${test_name} ${log_types}
537 Get ControlNode Connection
538 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
539 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
540 SSHLibrary.Set Client Configuration timeout=30s
541 Source Password force=yes
542 [Return] ${control_conn_id}
545 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
546 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
547 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
548 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
550 Get Test Teardown Debugs
551 [Arguments] ${test_name}=${TEST_NAME}
553 Get Model Dump ${HA_PROXY_IP}
554 Get Karaf Log Events From Test Start ${test_name}
557 [Arguments] @{vm_indices}
558 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
559 ${devstack_conn_id}= Get ControlNode Connection
560 Switch Connection ${devstack_conn_id}
561 ${output}= Write Commands Until Prompt sudo ip netns list
563 : FOR ${index} IN @{vm_indices}
564 \ ${output}= Write Commands Until Prompt nova show ${index} 30s
572 Create Security Group
573 [Arguments] ${sg_name} ${desc}
574 ${devstack_conn_id}= Get ControlNode Connection
575 Switch Connection ${devstack_conn_id}
576 ${output}= Write Commands Until Prompt nova secgroup-create ${sg_name} ${desc} 40s
580 [Arguments] ${direction} ${protocol} ${min_port} ${max_port} ${remote_ip} ${sg_name}
581 ${devstack_conn_id}= Get ControlNode Connection
582 Switch Connection ${devstack_conn_id}
583 ${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}
586 Neutron Security Group Show
587 [Arguments] ${SecurityGroupRuleName} ${additional_args}=${EMPTY}
588 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
589 ${devstack_conn_id}= Get ControlNode Connection
590 Switch Connection ${devstack_conn_id}
591 ${cmd}= Set Variable neutron security-group-show ${SecurityGroupRuleName} ${additional_args}
593 ${output}= Write Commands Until Prompt ${cmd} 30s
599 [Arguments] ${PortName} ${additional_args}=${EMPTY}
600 [Documentation] Display the port configuration that belong to a given neutron port
601 ${devstack_conn_id}= Get ControlNode Connection
602 Switch Connection ${devstack_conn_id}
603 ${cmd}= Set Variable neutron port-show ${PortName} ${additional_args}
605 ${output}= Write Commands Until Prompt ${cmd} 30s
610 Neutron Security Group Create
611 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
612 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
613 ${devstack_conn_id}= Get ControlNode Connection
614 Switch Connection ${devstack_conn_id}
615 ${cmd}= Set Variable neutron security-group-create ${SecurityGroupName} ${additional_args}
617 ${output}= Write Commands Until Prompt ${cmd} 30s
619 Should Contain ${output} Created a new security_group
620 ${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}
623 [Return] ${output} ${sgp_id}
625 Neutron Security Group Update
626 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
627 [Documentation] Updating security groups
628 ${devstack_conn_id}= Get ControlNode Connection
629 Switch Connection ${devstack_conn_id}
630 ${cmd}= Set Variable neutron security-group-update ${SecurityGroupName} ${additional_args}
632 ${output}= Write Commands Until Prompt ${cmd} 30s
637 Neutron Security Group Rule Create
638 [Arguments] ${Security_group_name} &{Kwargs}
639 [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]} ..."
640 ${devstack_conn_id}= Get ControlNode Connection
641 Switch Connection ${devstack_conn_id}
642 Run Keyword If ${Kwargs} Log ${Kwargs}
643 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
644 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
645 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
646 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
647 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
648 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
649 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
650 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
651 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
652 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
653 ... ELSE Catenate ${cmd}
654 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
655 ... ELSE Catenate ${cmd}
656 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
657 ... ELSE Catenate ${cmd}
658 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
659 ... ELSE Catenate ${cmd}
660 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
661 ... ELSE Catenate ${cmd}
662 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
663 ... ELSE Catenate ${cmd}
664 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
665 ... ELSE Catenate ${cmd}
666 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
667 ... ELSE Catenate ${cmd}
668 ${output}= Write Commands Until Prompt ${cmd} 30s
669 ${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}
671 Should Contain ${output} Created a new security_group_rule
673 [Return] ${output} ${rule_id}
675 Create Neutron Port With Additional Params
676 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
677 [Documentation] Create Port With given additional parameters
678 ${devstack_conn_id}= Get ControlNode Connection
679 Switch Connection ${devstack_conn_id}
680 ${cmd}= Set Variable neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
682 ${OUTPUT}= Write Commands Until Prompt ${cmd} 30s
684 Should Contain ${output} Created a new port
685 ${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}
688 [Return] ${OUTPUT} ${port_id}