2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
5 Resource DataModels.robot
7 Resource SSHKeywords.robot
8 Resource L2GatewayOperations.robot
9 Resource ../variables/Variables.robot
10 Variables ../variables/netvirt/Modules.py
14 [Arguments] ${force}=no ${source_pwd}=yes
15 [Documentation] Sourcing the Openstack PAsswords for neutron configurations
16 Run Keyword If '${source_pwd}' == 'yes' or '${force}' == 'yes' Write Commands Until Prompt cd ${DEVSTACK_DEPLOY_PATH}; source openrc admin admin
18 Get Tenant ID From Security Group
19 [Documentation] Returns tenant ID by reading it from existing default security-group.
20 ${devstack_conn_id}= Get ControlNode Connection
21 Switch Connection ${devstack_conn_id}
22 ${output}= Write Commands Until Prompt openstack security group show default | grep "| tenant_id" | awk '{print $4}'
26 Get Tenant ID From Network
27 [Arguments] ${network_uuid}
28 [Documentation] Returns tenant ID by reading it from existing network.
29 ${resp}= Get_From_Uri uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/ accept=${ACCEPT_EMPTY} session=session
30 ${tenant_id}= Utils.Extract Value From Content ${resp} /network/0/tenant-id strip
34 [Arguments] ${network_name} ${additional_args}=${EMPTY} ${verbose}=TRUE
35 [Documentation] Create Network with neutron request.
36 ${devstack_conn_id}= Get ControlNode Connection
37 Switch Connection ${devstack_conn_id}
38 ${output}= Write Commands Until Prompt openstack network create ${network_name} ${additional_args} 30s
40 Should Contain ${output} ${OS_CMD_SUCCESS}
44 [Arguments] ${network_name} ${additional_args}=${EMPTY}
45 [Documentation] Update Network with neutron request.
46 ${devstack_conn_id}= Get ControlNode Connection
47 Switch Connection ${devstack_conn_id}
48 ${cmd}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v net-update ${network_name} ${additional_args} openstack network set ${network_name} ${additional_args}
49 ${output}= Write Commands Until Prompt ${cmd} 30s
55 [Arguments] ${network_name}
56 [Documentation] Show Network with neutron request.
57 ${devstack_conn_id}= Get ControlNode Connection
58 Switch Connection ${devstack_conn_id}
59 ${output}= Write Commands Until Prompt openstack network show ${network_name} 30s
65 [Documentation] List networks and return output with neutron client.
66 ${devstack_conn_id}= Get ControlNode Connection
67 Switch Connection ${devstack_conn_id}
68 ${output}= Write Commands Until Prompt openstack network list 30s
74 [Documentation] List subnets and return output with neutron client.
75 ${devstack_conn_id}= Get ControlNode Connection
76 Switch Connection ${devstack_conn_id}
77 ${output}= Write Commands Until Prompt openstack subnet list 30s
83 [Arguments] ${network_name}
84 [Documentation] Delete Network with neutron request.
85 ${devstack_conn_id}= Get ControlNode Connection
86 Switch Connection ${devstack_conn_id}
87 ${output}= Write Commands Until Prompt openstack network delete ${network_name} 30s
90 Should Contain ${output} ${OS_CMD_SUCCESS}
93 [Arguments] ${network_name} ${subnet} ${range_ip} ${additional_args}=${EMPTY}
94 [Documentation] Create SubNet for the Network with neutron request.
95 ${devstack_conn_id}= Get ControlNode Connection
96 Switch Connection ${devstack_conn_id}
97 ${output}= Write Commands Until Prompt openstack subnet create --network ${network_name} --subnet-range ${range_ip} ${subnet} ${additional_args} 30s
100 Should Contain ${output} ${OS_CMD_SUCCESS}
103 [Arguments] ${subnet_name} ${additional_args}=${EMPTY}
104 [Documentation] Update subnet with neutron request.
105 ${devstack_conn_id}= Get ControlNode Connection
106 Switch Connection ${devstack_conn_id}
107 ${cmd}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v subnet-update ${subnet_name} ${additional_args} openstack subnet set ${subnet_name} ${additional_args}
108 ${output}= Write Commands Until Prompt ${cmd} 30s
114 [Arguments] ${subnet_name}
115 [Documentation] Show subnet with neutron request.
116 ${devstack_conn_id}= Get ControlNode Connection
117 Switch Connection ${devstack_conn_id}
118 ${output}= Write Commands Until Prompt openstack subnet show ${subnet_name} 30s
124 [Arguments] ${network_name} ${port_name} ${sg}=default ${additional_args}=${EMPTY} ${allowed_address_pairs}=${EMPTY}
125 [Documentation] Create Port with neutron request.
126 ${devstack_conn_id}= Get ControlNode Connection
127 Switch Connection ${devstack_conn_id}
128 # if allowed_address_pairs is not empty we need to create the arguments to pass to the port create command. They are
129 # in a different format with the neutron vs openstack cli.
130 ${address_pair_length}= Get Length ${allowed_address_pairs}
131 ${allowed_pairs_argv}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' and '${address_pair_length}'=='2' --allowed-address-pairs type=dict list=true ip_address=@{allowed_address_pairs}[0] ip_address=@{allowed_address_pairs}[1]
132 ${allowed_pairs_argv}= Set Variable If '${OPENSTACK_BRANCH}'!='stable/newton' and '${address_pair_length}'=='2' --allowed-address ip-address=@{allowed_address_pairs}[0] --allowed-address ip-address=@{allowed_address_pairs}[1] ${allowed_pairs_argv}
133 ${allowed_pairs_argv}= Set Variable If '${address_pair_length}'=='0' ${EMPTY} ${allowed_pairs_argv}
134 ${cmd}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v port-create ${network_name} --name ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv} openstack port create --network ${network_name} ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv}
135 ${output}= Write Commands Until Prompt ${cmd} 30s
138 Should Contain ${output} ${OS_CMD_SUCCESS}
141 [Arguments] ${port_name} ${additional_args}=${EMPTY}
142 [Documentation] Update port with neutron request.
143 ${devstack_conn_id}= Get ControlNode Connection
144 Switch Connection ${devstack_conn_id}
145 ${output}= Write Commands Until Prompt openstack port set ${port_name} ${additional_args} 30s
151 [Arguments] ${port_name}
152 [Documentation] Show port with neutron request.
153 ${devstack_conn_id}= Get ControlNode Connection
154 Switch Connection ${devstack_conn_id}
155 ${output}= Write Commands Until Prompt openstack port show ${port_name} 30s
161 [Arguments] ${port_name}
162 [Documentation] Delete Port with neutron request.
163 ${devstack_conn_id}= Get ControlNode Connection
164 Switch Connection ${devstack_conn_id}
165 ${output}= Write Commands Until Prompt openstack port delete ${port_name} 30s
168 Should Contain ${output} ${OS_CMD_SUCCESS}
171 [Documentation] List ports and return output with neutron client.
172 ${devstack_conn_id}= Get ControlNode Connection
173 Switch Connection ${devstack_conn_id}
174 ${output}= Write Commands Until Prompt openstack port list 30s
180 [Documentation] List VMs and return output with nova client.
181 ${devstack_conn_id}= Get ControlNode Connection
182 Switch Connection ${devstack_conn_id}
183 #TODO Change to Openstak CLI once the problem with Ocata is solved
184 ${output}= Write Commands Until Prompt nova list 30s
189 Create And Associate Floating IPs
190 [Arguments] ${external_net} @{vm_list}
191 [Documentation] Create and associate floating IPs to VMs with nova request
192 ${devstack_conn_id}= Get ControlNode Connection
193 Switch Connection ${devstack_conn_id}
194 ${ip_list}= Create List @{EMPTY}
195 : FOR ${vm} IN @{vm_list}
196 \ ${output}= Write Commands Until Prompt openstack floating ip create ${external_net} 30s
198 \ @{ip} Get Regexp Matches ${output} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
199 \ ${ip_length} Get Length ${ip}
200 \ Run Keyword If ${ip_length}>0 Append To List ${ip_list} @{ip}[0]
201 \ ... ELSE Append To List ${ip_list} None
202 \ ${output}= Write Commands Until Prompt openstack server add floating ip ${vm} @{ip}[0] 30s
207 [Documentation] Verifies the Gateway Ips with dump flow.
208 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
210 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
211 \ Should Contain ${output} ${GatewayIpElement}
214 [Documentation] Verifies the Dhcp Ips with dump flow.
215 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
217 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
218 \ Should Contain ${output} ${DhcpIpElement}
221 [Documentation] Verifies the Dhcp Ips with dump flow.
222 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
224 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
225 \ Should Not Contain ${output} ${DhcpIpElement}
228 [Arguments] ${subnet}
229 [Documentation] Delete SubNet for the Network with neutron request.
231 ${devstack_conn_id}= Get ControlNode Connection
232 Switch Connection ${devstack_conn_id}
233 ${output}= Write Commands Until Prompt openstack subnet delete ${subnet}
236 Should Contain ${output} ${OS_CMD_SUCCESS}
238 Verify No Gateway Ips
239 [Documentation] Verifies the Gateway Ips removed with dump flow.
240 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
242 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
243 \ Should Not Contain ${output} ${GatewayIpElement}
246 [Arguments] ${vm_name}
247 [Documentation] Delete Vm instances using instance names.
248 ${devstack_conn_id}= Get ControlNode Connection
249 Switch Connection ${devstack_conn_id}
250 ${output}= Write Commands Until Prompt openstack server delete ${vm_name} 40s
254 [Arguments] ${network_name} ${devstack_conn_id}
255 [Documentation] Retrieve the net id for the given network name to create specific vm instance
256 Switch Connection ${devstack_conn_id}
257 ${output}= Write Commands Until Prompt openstack network list | grep "${network_name}" | awk '{print $2}' 30s
259 ${splitted_output}= Split String ${output} ${EMPTY}
260 ${net_id}= Get from List ${splitted_output} 0
265 [Arguments] ${subnet_name} ${devstack_conn_id}
266 [Documentation] Retrieve the subnet id for the given subnet name
267 Switch Connection ${devstack_conn_id}
268 ${output}= Write Commands Until Prompt openstack subnet show "${subnet_name}" | grep " id " | awk '{print $4}' 30s
270 ${splitted_output}= Split String ${output} ${EMPTY}
271 ${subnet_id}= Get from List ${splitted_output} 0
273 [Return] ${subnet_id}
276 [Arguments] ${port_name} ${devstack_conn_id}
277 [Documentation] Retrieve the port id for the given port name to attach specific vm instance to a particular port
278 Switch Connection ${devstack_conn_id}
279 ${output}= Write Commands Until Prompt openstack port list | grep "${port_name}" | awk '{print $2}' 30s
281 ${splitted_output}= Split String ${output} ${EMPTY}
282 ${port_id}= Get from List ${splitted_output} 0
287 [Arguments] ${router1} ${devstack_conn_id}
288 [Documentation] Retrieve the router id for the given router name
289 Switch Connection ${devstack_conn_id}
290 ${output}= Write Commands Until Prompt openstack router list -f table | grep "${router1}" | awk '{print $2}' 30s
292 ${splitted_output}= Split String ${output} ${EMPTY}
293 ${router_id}= Get from List ${splitted_output} 0
295 [Return] ${router_id}
298 [Arguments] ${net_name} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
299 [Documentation] Create X Vm Instance with the net id of the Netowrk.
300 ${devstack_conn_id}= Get ControlNode Connection
301 Switch Connection ${devstack_conn_id}
302 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
303 : FOR ${VmElement} IN @{vm_instance_names}
304 \ ${output}= Write Commands Until Prompt openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-group ${sg} 30s
307 Create Vm Instance With Port
308 [Arguments] ${port_name} ${vm_instance_name} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
309 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
310 ${devstack_conn_id}= Get ControlNode Connection
311 Switch Connection ${devstack_conn_id}
312 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
313 ${output}= Write Commands Until Prompt openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-groups ${sg} 30s
316 Create Vm Instance With Ports
317 [Arguments] ${port_name} ${port2_name} ${vm_instance_name} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
318 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
319 ${devstack_conn_id}= Get ControlNode Connection
320 Switch Connection ${devstack_conn_id}
321 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
322 ${port2_id}= Get Port Id ${port2_name} ${devstack_conn_id}
323 ${output}= Write Commands Until Prompt openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --nic port-id=${port2_id} ${vm_instance_name} --security-group ${sg} 30s
326 Create Vm Instance With Port On Compute Node
327 [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
328 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
329 ${devstack_conn_id}= Get ControlNode Connection
330 Switch Connection ${devstack_conn_id}
331 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
332 ${hostname_compute_node}= Run Command On Remote System ${compute_node} hostname
333 ${output}= Write Commands Until Prompt openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --security-group ${sg} --availability-zone nova:${hostname_compute_node} ${vm_instance_name} 30s
337 [Arguments] ${vm_name}
338 [Documentation] Run these commands to check whether the created vm instance is active or not.
339 ${devstack_conn_id}= Get ControlNode Connection
340 Switch Connection ${devstack_conn_id}
341 #TODO Change to Openstack CLI Command once the Ocata Issue is resolved
342 ${output}= Write Commands Until Prompt nova show ${vm_name} | grep OS-EXT-STS:vm_state 30s
344 Should Contain ${output} active
346 Collect VM IP Addresses
347 [Arguments] ${fail_on_none} @{vm_list}
348 [Documentation] Using nova console-log on the provided ${vm_list} to search for the string "obtained" which
349 ... correlates to the instance receiving it's IP address via DHCP. Also retrieved is the ip of the nameserver
350 ... if available in the console-log output. The keyword will also return a list of the learned ips as it
351 ... finds them in the console log output, and will have "None" for Vms that no ip was found.
352 ${devstack_conn_id}= Get ControlNode Connection
353 Switch Connection ${devstack_conn_id}
354 ${ip_list} Create List @{EMPTY}
355 : FOR ${vm} IN @{vm_list}
356 \ ${vm_ip_line}= Write Commands Until Prompt openstack console log show ${vm} | grep -i "obtained" 30s
358 \ @{vm_ip} Get Regexp Matches ${vm_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
359 \ ${vm_ip_length} Get Length ${vm_ip}
360 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip}[0]
361 \ ... ELSE Append To List ${ip_list} None
362 \ ${dhcp_ip_line}= Write Commands Until Prompt openstack console log show ${vm} | grep "^nameserver" 30s
363 \ Log ${dhcp_ip_line}
364 \ ${dhcp_ip} Get Regexp Matches ${dhcp_ip_line} [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
365 \ ${dhcp_ip_length} Get Length ${dhcp_ip}
366 \ Run Keyword If ${dhcp_ip_length}<=0 Append To List ${dhcp_ip} None
368 ${dhcp_length} Get Length ${dhcp_ip}
369 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${ip_list} None
370 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${dhcp_ip} None
371 Should Be True ${dhcp_length} <= 1
372 Return From Keyword If ${dhcp_length}==0 ${ip_list} ${EMPTY}
373 [Return] ${ip_list} ${dhcp_ip}
375 Collect VM IPv6 SLAAC Addresses
376 [Arguments] ${fail_on_none} ${prefix} @{vm_list}
377 [Documentation] Using nova console-log on the provided ${vm_list} to search for the string "inet6" which
378 ... correlates to the instance generated IPv6 address, based on the ${prefix} received from ODL (SLAAC mode).
379 ${devstack_conn_id}= Get ControlNode Connection
380 Switch Connection ${devstack_conn_id}
381 ${ip_list} Create List @{EMPTY}
382 : FOR ${vm} IN @{vm_list}
384 \ ${vm_ip_line}= Write Commands Until Prompt nova console-log ${vm} | grep -i "inet6" 30s
386 \ @{vm_ip_list} Get Regexp Matches ${vm_ip_line} ${prefix}
387 \ ${vm_ip_length} Get Length ${vm_ip_list}
388 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip_list}[0]
389 \ ... ELSE Append To List ${ip_list} None
391 Run Keyword If '${fail_on_none}' == 'true' Should Not Contain ${ip_list} None
396 [Arguments] ${vm_instance_names}
397 [Documentation] View Console log of the created vm instances using nova show.
398 : FOR ${VmElement} IN @{vm_instance_names}
399 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
401 \ ${output}= Write Commands Until Prompt openstack console log show ${VmElement}
404 Ping Vm From DHCP Namespace
405 [Arguments] ${net_name} ${vm_ip}
406 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
408 ${devstack_conn_id}= Get ControlNode Connection
409 Switch Connection ${devstack_conn_id}
410 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
412 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
415 Should Contain ${output} 64 bytes
417 Ping From DHCP Should Not Succeed
418 [Arguments] ${net_name} ${vm_ip}
419 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
420 Return From Keyword If "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
422 ${devstack_conn_id}= Get ControlNode Connection
423 Switch Connection ${devstack_conn_id}
424 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
426 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
429 Should Not Contain ${output} 64 bytes
431 Ping Vm From Control Node
432 [Arguments] ${vm_floating_ip} ${additional_args}=${EMPTY}
433 [Documentation] Ping VM floating IP from control node
434 Log ${vm_floating_ip}
435 ${devstack_conn_id}= Get ControlNode Connection
436 Switch Connection ${devstack_conn_id}
437 ${output}= Write Commands Until Prompt ping ${additional_args} -c 3 ${vm_floating_ip} 20s
440 Should Contain ${output} 64 bytes
443 [Arguments] ${dest_vm_ip}
444 [Documentation] Ping to the expected destination ip.
445 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm_ip} ${OS_SYSTEM_PROMPT}
450 [Documentation] Ping to the expected destination ip.
451 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
452 Write Commands Until Prompt exit
453 Should Contain ${output} 200
456 [Documentation] Exit the vm instance.
457 ${output}= Write Commands Until Prompt exit
460 Check If Console Is VmInstance
461 [Arguments] ${console}=cirros
462 [Documentation] Check if the session has been able to login to the VM instance
463 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
464 Should Contain ${output} ${console}
467 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
468 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
469 Run Keyword If ${rcode} Write Commands Until Prompt exit
472 [Arguments] ${ip_address} ${ttl}=64
473 [Documentation] Run Ping command on the IP available as argument
474 ${ethertype}= Get Regexp Matches ${ip_address} ${IP_REGEX}
475 ${output}= Run Keyword If ${ethertype} Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
476 ... ELSE Write Commands Until Expected Prompt ping6 -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
477 Should Contain ${output} 64 bytes
480 [Arguments] ${ip_address} ${ttl}=64
481 [Documentation] Run Ping command to the IP given as argument, executing 3 times and expecting NOT to see "64 bytes"
482 ${output}= Write Commands Until Expected Prompt ping -t ${ttl} -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
483 Should Not Contain ${output} 64 bytes
485 Check Metadata Access
486 [Documentation] Try curl on the Metadataurl and check if it is okay
487 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
488 Should Contain ${output} 200
490 Execute Command on VM Instance
491 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
492 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
493 ${devstack_conn_id} = Get ControlNode Connection
494 Switch Connection ${devstack_conn_id}
495 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
497 ${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:
499 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
501 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
502 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
503 [Teardown] Exit From Vm Console
506 Test Operations From Vm Instance
507 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:) ${ttl}=64
508 ... ${ping_should_succeed}=True ${check_metadata}=True
509 [Documentation] Login to the vm instance using ssh in the network.
510 ${devstack_conn_id}= Get ControlNode Connection
511 Switch Connection ${devstack_conn_id}
513 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
514 ${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:
516 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
518 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
519 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
520 Run Keyword If ${rcode} Write Commands Until Expected Prompt route -n ${OS_SYSTEM_PROMPT}
521 Run Keyword If ${rcode} Write Commands Until Expected Prompt route -A inet6 ${OS_SYSTEM_PROMPT}
522 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
523 Run Keyword If ${rcode} Write Commands Until Expected Prompt ip -6 neigh ${OS_SYSTEM_PROMPT}
524 : FOR ${dest_ip} IN @{dest_ips}
526 \ ${string_empty}= Run Keyword And Return Status Should Be Empty ${dest_ip}
527 \ Run Keyword If ${string_empty} Continue For Loop
528 \ Run Keyword If ${rcode} and "${ping_should_succeed}" == "True" Check Ping ${dest_ip} ttl=${ttl}
529 \ ... ELSE Check No Ping ${dest_ip} ttl=${ttl}
530 ${ethertype}= Get Regexp Matches ${src_ip} ${IP_REGEX}
531 Run Keyword If ${rcode} and "${check_metadata}" and ${ethertype} == "True" Check Metadata Access
532 [Teardown] Exit From Vm Console
534 Test Netcat Operations From Vm Instance
535 [Arguments] ${net_name} ${vm_ip} ${dest_ip} ${additional_args}=${EMPTY} ${port}=12345 ${user}=cirros
536 ... ${password}=cubswin:)
537 [Documentation] Use Netcat to test TCP/UDP connections to the controller
538 ${client_data} Set Variable Test Client Data
539 ${server_data} Set Variable Test Server Data
540 ${devstack_conn_id}= Get ControlNode Connection
541 Switch Connection ${devstack_conn_id}
543 ${output}= Write Commands Until Prompt ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
545 ${output}= Write Commands Until Prompt sudo netstat -nlap | grep ${port}
547 ${nc_output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo echo "${client_data}" | nc -v -w 5 ${additional_args} ${dest_ip} ${port}
549 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo route -n
551 ${output}= Execute Command on VM Instance ${net_name} ${vm_ip} sudo arp -an
553 Should Match Regexp ${nc_output} ${server_data}
556 [Arguments] ${list_of_external_dst_ips}
557 [Documentation] Check reachability with other network's instances.
558 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
559 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
561 \ Check Ping ${dest_ip}
564 [Arguments] ${router_name}
565 [Documentation] Create Router and Add Interface to the subnets.
566 ${devstack_conn_id}= Get ControlNode Connection
567 Switch Connection ${devstack_conn_id}
568 ${output}= Write Commands Until Prompt openstack router create -f table ${router_name} 30s
570 Should Contain ${output} ${OS_CMD_SUCCESS}
573 [Documentation] List Router and return output with neutron client.
574 ${devstack_conn_id}= Get ControlNode Connection
575 Switch Connection ${devstack_conn_id}
576 ${output}= Write Commands Until Prompt openstack router list -f value 30s
582 [Arguments] ${router_name} ${interface_name}
583 ${devstack_conn_id}= Get ControlNode Connection
584 Switch Connection ${devstack_conn_id}
585 ${output}= Write Commands Until Prompt openstack router add subnet ${router_name} ${interface_name}
587 Should Contain ${output} ${OS_CMD_SUCCESS}
589 Show Router Interface
590 [Arguments] ${router_name}
591 [Documentation] List Router interface associated with given Router and return output with neutron client.
592 ${devstack_conn_id}= Get ControlNode Connection
593 Switch Connection ${devstack_conn_id}
594 ${output}= Write Commands Until Prompt openstack port list --router ${router_name} -f value 30s
600 [Arguments] ${router_name} ${external_network_name}
601 ${devstack_conn_id}= Get ControlNode Connection
602 Switch Connection ${devstack_conn_id}
603 ${cmd}= Set Variable If '${OPENSTACK_BRANCH}'=='stable/newton' neutron -v router-gateway-set ${router_name} ${external_network_name} openstack router set ${router_name} --external-gateway ${external_network_name}
604 ${output}= Write Commands Until Prompt ${cmd} 30s
606 Should Contain ${output} ${OS_CMD_SUCCESS}
609 [Arguments] ${router_name} ${interface_name}
610 [Documentation] Remove Interface to the subnets.
611 ${devstack_conn_id}= Get ControlNode Connection
612 Switch Connection ${devstack_conn_id}
613 ${output}= Write Commands Until Prompt openstack router remove subnet ${router_name} ${interface_name}
615 Should Contain ${output} ${OS_CMD_SUCCESS}
618 [Arguments] ${router_name} ${cmd}
619 [Documentation] Update the router with the command. Router name and command should be passed as argument.
620 ${devstack_conn_id} = Get ControlNode Connection
621 Switch Connection ${devstack_conn_id}
622 ${output} = Write Commands Until Prompt openstack router set ${router_name} ${cmd} 30s
624 Should Contain ${output} ${OS_CMD_SUCCESS}
627 [Arguments] ${router_name} ${options}
628 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
629 ${devstack_conn_id} = Get ControlNode Connection
630 Switch Connection ${devstack_conn_id}
631 ${output} = Write Commands Until Prompt openstack router show ${router_name} 30s
636 [Arguments] ${router_name}
637 [Documentation] Delete Router and Interface to the subnets.
638 ${devstack_conn_id}= Get ControlNode Connection
639 Switch Connection ${devstack_conn_id}
640 ${output}= Write Commands Until Prompt openstack router delete ${router_name} 60s
642 Should Contain ${output} ${OS_CMD_SUCCESS}
644 Get DumpFlows And Ovsconfig
645 [Arguments] ${openstack_node_ip}
646 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
647 Log ${openstack_node_ip}
648 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
649 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
650 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
651 Write Commands Until Expected Prompt ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
652 Write Commands Until Expected Prompt ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
653 Write Commands Until Expected Prompt ip route ${DEFAULT_LINUX_PROMPT_STRICT}
654 Write Commands Until Expected Prompt arp -an ${DEFAULT_LINUX_PROMPT_STRICT}
655 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ${DEFAULT_LINUX_PROMPT_STRICT}
656 @{lines} Split To Lines ${nslist}
657 : FOR ${line} IN @{lines}
658 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ${DEFAULT_LINUX_PROMPT_STRICT}
659 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ${DEFAULT_LINUX_PROMPT_STRICT}
660 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ${DEFAULT_LINUX_PROMPT_STRICT}
661 Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
662 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
663 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
664 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
665 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
666 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
668 Get Karaf Log Type From Test Start
669 [Arguments] ${ip} ${test_name} ${type} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
670 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
671 ${cmd} Set Variable sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
672 ${output} Run Command On Controller ${ip} ${cmd} ${user} ${password} ${prompt}
675 Get Karaf Log Types From Test Start
676 [Arguments] ${ip} ${test_name} ${types} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
677 ... ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
678 : FOR ${type} IN @{types}
679 \ Get Karaf Log Type From Test Start ${ip} ${test_name} ${type} ${user} ${password}
680 \ ... ${prompt} ${log_file}
682 Get Karaf Log Events From Test Start
683 [Arguments] ${test_name} ${user}=${ODL_SYSTEM_USER} ${password}=${ODL_SYSTEM_PASSWORD} ${prompt}=${ODL_SYSTEM_PROMPT}
684 ${log_types} = Create List ERROR WARN Exception
685 Run Keyword If 0 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_IP} ${test_name} ${log_types}
686 Run Keyword If 1 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_2_IP} ${test_name} ${log_types}
687 Run Keyword If 2 < ${NUM_ODL_SYSTEM} Get Karaf Log Types From Test Start ${ODL_SYSTEM_3_IP} ${test_name} ${log_types}
689 Get ControlNode Connection
690 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
691 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
692 SSHLibrary.Set Client Configuration timeout=30s
693 Source Password force=yes
694 [Return] ${control_conn_id}
697 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
698 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
699 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
700 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
702 Get Test Teardown Debugs
703 [Arguments] ${test_name}=${TEST_NAME}
705 Run Keyword And Ignore Error Get Model Dump ${HA_PROXY_IP} ${netvirt_data_models}
706 Get Karaf Log Events From Test Start ${test_name}
708 Get Suite Teardown Debugs
710 Get Model Dump ${HA_PROXY_IP} ${netvirt_data_models}
713 [Arguments] @{vm_indices}
714 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
715 ${devstack_conn_id}= Get ControlNode Connection
716 Switch Connection ${devstack_conn_id}
717 ${output}= Write Commands Until Prompt sudo ip netns list
719 : FOR ${index} IN @{vm_indices}
720 \ ${output}= Write Commands Until Prompt nova show ${index} 30s
728 Create Security Group
729 [Arguments] ${sg_name} ${desc}
730 ${devstack_conn_id}= Get ControlNode Connection
731 Switch Connection ${devstack_conn_id}
732 ${output}= Write Commands Until Prompt openstack security group create ${sg_name} --description ${desc} 40s
736 [Arguments] ${direction} ${protocol} ${min_port} ${max_port} ${remote_ip} ${sg_name}
737 ${devstack_conn_id}= Get ControlNode Connection
738 Switch Connection ${devstack_conn_id}
739 ${output}= Write Commands Until Prompt openstack security group rule create --${direction} --protocol ${protocol} --dst-port ${min_port}:${max_port} ${sg_name}
742 Neutron Security Group Show
743 [Arguments] ${SecurityGroupRuleName}
744 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
745 ${devstack_conn_id}= Get ControlNode Connection
746 Switch Connection ${devstack_conn_id}
747 ${cmd}= Set Variable openstack security group show ${SecurityGroupRuleName}
749 ${output}= Write Commands Until Prompt ${cmd} 30s
755 [Arguments] ${PortName}
756 [Documentation] Display the port configuration that belong to a given neutron port
757 ${devstack_conn_id}= Get ControlNode Connection
758 Switch Connection ${devstack_conn_id}
759 ${cmd}= Set Variable openstack port show ${PortName}
761 ${output}= Write Commands Until Prompt ${cmd} 30s
766 Neutron Security Group Create
767 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
768 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
769 ${devstack_conn_id}= Get ControlNode Connection
770 Switch Connection ${devstack_conn_id}
771 ${cmd}= Set Variable openstack security group create ${SecurityGroupName} ${additional_args}
773 ${output}= Write Commands Until Prompt ${cmd} 30s
775 Should Contain ${output} ${OS_CMD_SUCCESS}
776 ${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}
779 [Return] ${output} ${sgp_id}
781 Neutron Security Group Update
782 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
783 [Documentation] Updating security groups
784 ${devstack_conn_id}= Get ControlNode Connection
785 Switch Connection ${devstack_conn_id}
786 ${cmd}= Set Variable openstack security group set ${SecurityGroupName} ${additional_args}
788 ${output}= Write Commands Until Prompt ${cmd} 30s
794 [Arguments] ${sg_name}
795 [Documentation] Delete Security group
796 ${devstack_conn_id}= Get ControlNode Connection
797 Switch Connection ${devstack_conn_id}
798 ${output}= Write Commands Until Prompt openstack security group delete ${sg_name} 40s
800 Should Contain ${output} ${OS_CMD_SUCCESS}
803 Neutron Security Group Rule Create
804 [Arguments] ${Security_group_name} &{Kwargs}
805 [Documentation] Creates neutron security rule with Openstack CLI with or without optional params, here security group name is mandatory args, rule with optional params can be created by passing the optional args values ex: direction=${INGRESS_EGRESS}, Then these optional params are catenated with mandatory args, example of usage: "Neutron Security Group Rule Create ${SGP_SSH} direction=${RULE_PARAMS[0]} ethertype=${RULE_PARAMS[1]} ..."
806 ${devstack_conn_id}= Get ControlNode Connection
807 Switch Connection ${devstack_conn_id}
808 Run Keyword If ${Kwargs} Log ${Kwargs}
809 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
810 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
811 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
812 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
813 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
814 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
815 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
816 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
817 ${cmd}= Set Variable openstack security group rule create ${Security_group_name}
818 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
819 ... ELSE Catenate ${cmd}
820 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --${direction}
821 ... ELSE Catenate ${cmd}
822 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
823 ... ELSE Catenate ${cmd}
824 ${cmd}= Run Keyword If '${port_range_min}'!='None' and '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_min}:${port_range_max}
825 ... ELSE IF '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_max}
826 ... ELSE IF '${port_range_min}'!='None' Catenate ${cmd} --dst-port ${port_range_min}
827 ... ELSE Catenate ${cmd}
828 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
829 ... ELSE Catenate ${cmd}
830 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote-group ${remote_group_id}
831 ... ELSE Catenate ${cmd}
832 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --src-ip ${remote_ip_prefix}
833 ... ELSE Catenate ${cmd}
834 ${output}= Write Commands Until Prompt ${cmd} 30s
835 ${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}
837 Should Contain ${output} ${OS_CMD_SUCCESS}
839 [Return] ${output} ${rule_id}
841 Neutron Security Group Rule Create Legacy Cli
842 [Arguments] ${Security_group_name} &{Kwargs}
843 [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]} ..."
844 ${devstack_conn_id}= Get ControlNode Connection
845 Switch Connection ${devstack_conn_id}
846 Run Keyword If ${Kwargs} Log ${Kwargs}
847 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
848 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
849 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
850 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
851 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
852 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
853 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
854 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
855 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
856 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
857 ... ELSE Catenate ${cmd}
858 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
859 ... ELSE Catenate ${cmd}
860 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
861 ... ELSE Catenate ${cmd}
862 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
863 ... ELSE Catenate ${cmd}
864 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
865 ... ELSE Catenate ${cmd}
866 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
867 ... ELSE Catenate ${cmd}
868 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
869 ... ELSE Catenate ${cmd}
870 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
871 ... ELSE Catenate ${cmd}
872 ${output}= Write Commands Until Prompt ${cmd} 30s
873 ${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}
875 Should Contain ${output} Created a new security_group_rule
877 [Return] ${output} ${rule_id}
879 Security Group Create Without Default Security Rules
880 [Arguments] ${sg_name} ${additional_args}=${EMPTY}
881 [Documentation] Create Neutron Security Group with no default rules, using specified name and optional arguments.
882 Neutron Security Group Create ${sg_name} ${additional_args}
883 Delete All Security Group Rules ${sg_name}
885 Delete All Security Group Rules
886 [Arguments] ${sg_name}
887 [Documentation] Delete all security rules from a specified security group
888 ${devstack_conn_id}= Get ControlNode Connection
889 Switch Connection ${devstack_conn_id}
890 ${sg_rules_output}= Write Commands Until Prompt openstack security group rule list ${sg_name} -cID -fvalue
891 Log ${sg_rules_output}
892 @{sg_rules}= Split String ${sg_rules_output} \n
893 : FOR ${rule} IN @{sg_rules}
894 \ ${output}= Write Commands Until Prompt openstack security group rule delete ${rule}
898 Create Neutron Port With Additional Params
899 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
900 [Documentation] Create Port With given additional parameters
901 ${devstack_conn_id}= Get ControlNode Connection
902 Switch Connection ${devstack_conn_id}
903 ${cmd}= Set Variable neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
905 ${OUTPUT}= Write Commands Until Prompt ${cmd} 30s
907 Should Contain ${output} ${OS_CMD_SUCCESS}
908 ${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}
911 [Return] ${OUTPUT} ${port_id}
914 [Arguments] ${portName_list}
915 [Documentation] Retrieve the port MacAddr for the given list of port name and return the MAC address list.
916 ${devstack_conn_id}= Get ControlNode Connection
917 Switch Connection ${devstack_conn_id}
918 ${MacAddr-list} Create List
919 : FOR ${portName} IN @{portName_list}
920 \ ${macAddr}= OpenStackOperations.Get Port Mac ${portName} ${devstack_conn_id}
921 \ Append To List ${MacAddr-list} ${macAddr}
922 [Return] ${MacAddr-list}
925 [Arguments] ${port_name}
926 [Documentation] Keyword would return the IP of the ${port_name} received.
927 Switch Connection ${devstack_conn_id}
928 ${output}= Write Commands Until Prompt neutron port-list | grep "${port_name}" | awk '{print $11}' | awk -F "\\"" '{print $2}' 30s
930 ${splitted_output}= Split String ${output} ${EMPTY}
931 ${port_ip}= Get from List ${splitted_output} 0
936 [Arguments] ${port_name} ${conn_id}=${devstack_conn_id}
937 [Documentation] Keyword would return the MAC ID of the ${port_name} received.
938 Switch Connection ${conn_id}
939 ${output}= Write Commands Until Prompt openstack port show ${port_name} | grep mac_address | awk '{print $4}' 30s
941 ${splitted_output}= Split String ${output} ${EMPTY}
942 ${port_mac}= Get from List ${splitted_output} 0
947 [Arguments] ${bridge_name} ${intf_name} ${gw_name}
948 [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
949 Switch Connection ${devstack_conn_id}
950 ${l2gw_output}= Write Commands Until Prompt ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name} 30s
952 [Return] ${l2gw_output}
954 Create L2Gateway Connection
955 [Arguments] ${gw_name} ${net_name}
956 [Documentation] Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
957 Switch Connection ${devstack_conn_id}
958 ${l2gw_output}= Write Commands Until Prompt ${L2GW_CONN_CREATE} ${gw_name} ${net_name} 30s
960 [Return] ${l2gw_output}
963 [Documentation] Keyword to return all the L2 Gateways available (Using Neutron CLI).
964 Switch Connection ${devstack_conn_id}
965 ${output}= Write Commands Until Prompt ${L2GW_GET_YAML} 30s
968 Get All L2Gateway Connection
969 [Documentation] Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
970 Switch Connection ${devstack_conn_id}
971 ${output}= Write Commands Until Prompt ${L2GW_GET_CONN_YAML} 30s
976 [Documentation] Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
977 Switch Connection ${devstack_conn_id}
978 ${output}= Write Commands Until Prompt ${L2GW_SHOW} ${gw_id} 30s
983 [Arguments] ${l2gw_name}
984 [Documentation] Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
985 Switch Connection ${devstack_conn_id}
986 ${output}= Write Commands Until Prompt ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}' 30s
988 ${splitted_output}= Split String ${output} ${EMPTY}
989 ${l2gw_id}= Get from List ${splitted_output} 0
993 Get L2gw Connection Id
994 [Arguments] ${l2gw_name}
995 [Documentation] Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
996 Switch Connection ${devstack_conn_id}
997 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${l2gw_name}
998 ${output}= Write Commands Until Prompt ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}' 30s
1000 ${splitted_output}= Split String ${output} ${EMPTY}
1001 ${l2gw_conn_id}= Get from List ${splitted_output} 0
1003 [Return] ${l2gw_conn_id}
1005 Neutron Port List Rest
1006 [Documentation] Keyword to get all ports details in Neutron (Using REST).
1007 ${resp} = RequestsLibrary.Get Request session ${PORT_URL}
1009 Should Be Equal As Strings ${resp.status_code} 200
1010 [Return] ${resp.content}
1012 Get Neutron Port Rest
1013 [Arguments] ${port_id}
1014 [Documentation] Keyword to get the specific port details in Neutron (Using REST).
1015 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id}
1017 Should Be Equal As Strings ${resp.status_code} 200
1018 [Return] ${resp.content}
1021 [Arguments] ${port_id} ${json_data}
1022 [Documentation] Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
1024 ${resp} = RequestsLibrary.Put Request session ${CONFIG_API}/${GET_PORT_URL}/${port_id} ${json_data}
1026 Should Be Equal As Strings ${resp.status_code} 200
1027 [Return] ${resp.content}
1029 Create And Configure Security Group
1030 [Arguments] ${sg-name}
1031 [Documentation] Create Security Group with given name, and default allow rules for TCP/UDP/ICMP protocols.
1032 Neutron Security Group Create ${sg-name}
1033 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
1034 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
1035 Neutron Security Group Rule Create ${sg-name} direction=ingress protocol=icmp remote_ip_prefix=0.0.0.0/0
1036 Neutron Security Group Rule Create ${sg-name} direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0
1037 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
1038 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
1040 Add Security Group To VM
1041 [Arguments] ${vm} ${sg}
1042 [Documentation] Add the security group provided to the given VM.
1043 ${devstack_conn_id}= Get ControlNode Connection
1044 Switch Connection ${devstack_conn_id}
1045 ${output}= Write Commands Until Prompt openstack server add security group ${vm} ${sg}
1049 Create SFC Flow Classifier
1050 [Arguments] ${name} ${src_ip} ${dest_ip} ${protocol} ${dest_port} ${neutron_src_port}
1051 [Documentation] Create a flow classifier for SFC
1052 ${devstack_conn_id}= Get ControlNode Connection
1053 Switch Connection ${devstack_conn_id}
1054 ${cmd}= Set Variable neutron flow-classifier-create --ethertype IPv4 --source-ip-prefix ${src_ip}/32 --destination-ip-prefix ${dest_ip}/32 --protocol ${protocol} --destination-port ${dest_port}:${dest_port} --logical-source-port ${neutron_src_port} ${name}
1056 ${output}= Write Commands Until Prompt ${cmd} 30s
1059 Should Contain ${output} Created a new flow_classifier
1062 Delete SFC Flow Classifier
1064 [Documentation] Delete a SFC flow classifier
1065 ${devstack_conn_id}= Get ControlNode Connection
1066 Switch Connection ${devstack_conn_id}
1067 ${cmd}= Set Variable neutron flow-classifier-delete ${name}
1069 ${output}= Write Commands Until Prompt ${cmd} 30s
1072 Should Contain ${output} Deleted flow_classifier
1075 Create SFC Port Pair
1076 [Arguments] ${name} ${port_in} ${port_out}
1077 [Documentation] Creates a neutron port pair for SFC
1078 ${devstack_conn_id}= Get ControlNode Connection
1079 Switch Connection ${devstack_conn_id}
1080 ${cmd}= Set Variable neutron port-pair-create --ingress=${port_in} --egress=${port_out} ${name}
1082 ${output}= Write Commands Until Prompt ${cmd} 30s
1085 Should Contain ${output} Created a new port_pair
1088 Delete SFC Port Pair
1090 [Documentation] Delete a SFC port pair
1091 ${devstack_conn_id}= Get ControlNode Connection
1092 Switch Connection ${devstack_conn_id}
1093 ${cmd}= Set Variable neutron port-pair-delete ${name}
1095 ${output}= Write Commands Until Prompt ${cmd} 30s
1098 Should Contain ${output} Deleted port_pair
1101 Create SFC Port Pair Group
1102 [Arguments] ${name} ${port_pair}
1103 [Documentation] Creates a port pair group with a single port pair for SFC
1104 ${devstack_conn_id}= Get ControlNode Connection
1105 Switch Connection ${devstack_conn_id}
1106 ${cmd}= Set Variable neutron port-pair-group-create --port-pair ${port_pair} ${name}
1108 ${output}= Write Commands Until Prompt ${cmd} 30s
1111 Should Contain ${output} Created a new port_pair_group
1114 Create SFC Port Pair Group With Two Pairs
1115 [Arguments] ${name} ${port_pair1} ${port_pair2}
1116 [Documentation] Creates a port pair group with two port pairs for SFC
1117 ${devstack_conn_id}= Get ControlNode Connection
1118 Switch Connection ${devstack_conn_id}
1119 ${cmd}= Set Variable neutron port-pair-group-create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name}
1121 ${output}= Write Commands Until Prompt ${cmd} 30s
1124 Should Contain ${output} Created a new port_pair_group
1127 Delete SFC Port Pair Group
1129 [Documentation] Delete a SFC port pair group
1130 ${devstack_conn_id}= Get ControlNode Connection
1131 Switch Connection ${devstack_conn_id}
1132 ${cmd}= Set Variable neutron port-pair-group-delete ${name}
1134 ${output}= Write Commands Until Prompt ${cmd} 30s
1137 Should Contain ${output} Deleted port_pair_group
1140 Create SFC Port Chain
1141 [Arguments] ${name} ${pg1} ${pg2} ${fc}
1142 [Documentation] Creates a port pair chain with two port groups and a singel classifier.
1143 ${devstack_conn_id}= Get ControlNode Connection
1144 Switch Connection ${devstack_conn_id}
1145 ${cmd}= Set Variable neutron port-chain-create --port-pair-group ${pg1} --port-pair-group ${pg2} --flow-classifier ${fc} ${name}
1147 ${output}= Write Commands Until Prompt ${cmd} 30s
1150 Should Contain ${output} Created a new port_chain
1153 Delete SFC Port Chain
1155 [Documentation] Delete a SFC port chain
1156 ${devstack_conn_id}= Get ControlNode Connection
1157 Switch Connection ${devstack_conn_id}
1158 ${cmd}= Set Variable neutron port-chain-delete ${name}
1160 ${output}= Write Commands Until Prompt ${cmd} 30s
1163 Should Contain ${output} Deleted port_chain
1167 [Arguments] ${vm_name}
1168 [Documentation] Reboot NOVA VM
1169 ${devstack_conn_id}= Get ControlNode Connection
1170 Switch Connection ${devstack_conn_id}
1171 ${output}= Write Commands Until Prompt openstack server reboot --wait ${vm_name} 30s
1173 Wait Until Keyword Succeeds 35s 10s Verify VM Is ACTIVE ${vm_name}
1176 Remove RSA Key From KnowHosts
1177 [Arguments] ${vm_ip}
1178 [Documentation] Remove RSA
1179 ${devstack_conn_id}= Get ControlNode Connection
1180 Switch Connection ${devstack_conn_id}
1181 ${output}= Write Commands Until Prompt sudo cat /root/.ssh/known_hosts 30s
1183 ${output}= Write Commands Until Prompt sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ${vm_ip} 30s
1185 ${output}= Write Commands Until Prompt sudo cat "/root/.ssh/known_hosts" 30s
1187 Wait For Routes To Propogate
1188 [Arguments] ${networks} ${subnets}
1189 [Documentation] Check propagated routes
1190 ${devstack_conn_id} = Get ControlNode Connection
1191 Switch Connection ${devstack_conn_id}
1192 : FOR ${INDEX} IN RANGE 0 1
1193 \ ${net_id}= Get Net Id @{networks}[${INDEX}] ${devstack_conn_id}
1194 \ ${is_ipv6}= Get Regexp Matches @{subnets}[${INDEX}] ${IP6_REGEX}
1195 \ ${length}= Get Length ${is_ipv6}
1196 \ ${cmd}= Set Variable If ${length} == 0 ip route ip -6 route
1197 \ ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ${cmd} ]>
1198 \ Should Contain ${output} @{subnets}[${INDEX}]