2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
5 Variables ../variables/Variables.py
9 [Arguments] ${force}=no ${source_pwd}=yes
10 [Documentation] Sourcing the Openstack PAsswords for neutron configurations
11 Run Keyword If '${source_pwd}' == 'yes' or '${force}' == 'yes' Write Commands Until Prompt cd ${DEVSTACK_DEPLOY_PATH}; source openrc admin admin
13 Get Tenant ID From Security Group
14 [Documentation] Returns tenant ID by reading it from existing default security-group.
15 ${devstack_conn_id}= Get ControlNode Connection
16 Switch Connection ${devstack_conn_id}
17 ${output}= Write Commands Until Prompt neutron security-group-show default | grep "| tenant_id" | awk '{print $4}'
21 Get Tenant ID From Network
22 [Arguments] ${network_uuid}
23 [Documentation] Returns tenant ID by reading it from existing network.
24 ${resp}= Get_From_Uri uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/ accept=${ACCEPT_EMPTY} session=session
25 ${tenant_id}= Utils.Extract Value From Content ${resp} /network/0/tenant-id strip
29 [Arguments] ${network_name} ${additional_args}=${EMPTY} ${verbose}=TRUE
30 [Documentation] Create Network with neutron request.
31 ${devstack_conn_id}= Get ControlNode Connection
32 Switch Connection ${devstack_conn_id}
33 ${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}'
34 ${output}= Write Commands Until Prompt ${command} 30s
39 [Documentation] List networks and return output with neutron client.
40 ${devstack_conn_id}= Get ControlNode Connection
41 Switch Connection ${devstack_conn_id}
42 ${output}= Write Commands Until Prompt neutron net-list 30s
48 [Documentation] List subnets and return output with neutron client.
49 ${devstack_conn_id}= Get ControlNode Connection
50 Switch Connection ${devstack_conn_id}
51 ${output}= Write Commands Until Prompt neutron subnet-list 30s
57 [Arguments] ${network_name}
58 [Documentation] Delete Network with neutron request.
59 ${devstack_conn_id}= Get ControlNode Connection
60 Switch Connection ${devstack_conn_id}
61 ${output}= Write Commands Until Prompt neutron -v net-delete ${network_name} 30s
64 Should Match Regexp ${output} Deleted network: ${network_name}|Deleted network\\(s\\): ${network_name}
67 [Arguments] ${network_name} ${subnet} ${range_ip} ${additional_args}=${EMPTY}
68 [Documentation] Create SubNet for the Network with neutron request.
69 ${devstack_conn_id}= Get ControlNode Connection
70 Switch Connection ${devstack_conn_id}
71 ${output}= Write Commands Until Prompt neutron -v subnet-create ${network_name} ${range_ip} --name ${subnet} ${additional_args} 30s
74 Should Contain ${output} Created a new subnet
77 [Arguments] ${network_name} ${port_name} ${sg}=default
78 [Documentation] Create Port with neutron request.
79 ${devstack_conn_id}= Get ControlNode Connection
80 Switch Connection ${devstack_conn_id}
81 ${output}= Write Commands Until Prompt neutron -v port-create ${network_name} --name ${port_name} --security-group ${sg} 30s
84 Should Contain ${output} Created a new port
87 [Arguments] ${port_name}
88 [Documentation] Delete Port with neutron request.
89 ${devstack_conn_id}= Get ControlNode Connection
90 Switch Connection ${devstack_conn_id}
91 ${output}= Write Commands Until Prompt neutron -v port-delete ${port_name} 30s
94 Should Match Regexp ${output} Deleted port: ${port_name}|Deleted port\\(s\\): ${port_name}
97 [Documentation] List ports and return output with neutron client.
98 ${devstack_conn_id}= Get ControlNode Connection
99 Switch Connection ${devstack_conn_id}
100 ${output}= Write Commands Until Prompt neutron port-list 30s
106 [Documentation] List VMs and return output with nova client.
107 ${devstack_conn_id}= Get ControlNode Connection
108 Switch Connection ${devstack_conn_id}
109 ${output}= Write Commands Until Prompt nova list 30s
114 Create And Associate Floating IPs
115 [Arguments] ${external_net} @{vm_list}
116 [Documentation] Create and associate floating IPs to VMs with nova request
117 ${devstack_conn_id}= Get ControlNode Connection
118 Switch Connection ${devstack_conn_id}
119 ${ip_list}= Create List @{EMPTY}
120 : FOR ${vm} IN @{vm_list}
121 \ ${output}= Write Commands Until Prompt nova floating-ip-create ${external_net} | grep "${external_net}" 30s
123 \ @{output_words} Split String ${output}
124 \ Append To List ${ip_list} @{output_words}[3]
125 \ ${output}= Write Commands Until Prompt nova floating-ip-associate ${vm} @{output_words}[3] 30s
130 [Documentation] Verifies the Gateway Ips with dump flow.
131 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
133 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
134 \ Should Contain ${output} ${GatewayIpElement}
137 [Documentation] Verifies the Dhcp Ips with dump flow.
138 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
140 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
141 \ Should Contain ${output} ${DhcpIpElement}
144 [Documentation] Verifies the Dhcp Ips with dump flow.
145 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
147 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
148 \ Should Not Contain ${output} ${DhcpIpElement}
151 [Arguments] ${subnet}
152 [Documentation] Delete SubNet for the Network with neutron request.
154 ${devstack_conn_id}= Get ControlNode Connection
155 Switch Connection ${devstack_conn_id}
156 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
159 Should Match Regexp ${output} Deleted subnet: ${subnet}|Deleted subnet\\(s\\): ${subnet}
161 Verify No Gateway Ips
162 [Documentation] Verifies the Gateway Ips removed with dump flow.
163 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
165 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
166 \ Should Not Contain ${output} ${GatewayIpElement}
169 [Arguments] ${vm_name}
170 [Documentation] Delete Vm instances using instance names.
171 ${devstack_conn_id}= Get ControlNode Connection
172 Switch Connection ${devstack_conn_id}
173 ${output}= Write Commands Until Prompt nova force-delete ${vm_name} 40s
177 [Arguments] ${network_name} ${devstack_conn_id}
178 [Documentation] Retrieve the net id for the given network name to create specific vm instance
179 Switch Connection ${devstack_conn_id}
180 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | awk '{print $2}' 30s
182 ${splitted_output}= Split String ${output} ${EMPTY}
183 ${net_id}= Get from List ${splitted_output} 0
188 [Arguments] ${port_name} ${devstack_conn_id}
189 [Documentation] Retrieve the port id for the given port name to attach specific vm instance to a particular port
190 Switch Connection ${devstack_conn_id}
191 ${output}= Write Commands Until Prompt neutron port-list | grep "${port_name}" | awk '{print $2}' 30s
193 ${splitted_output}= Split String ${output} ${EMPTY}
194 ${port_id}= Get from List ${splitted_output} 0
199 [Arguments] ${router1} ${devstack_conn_id}
200 [Documentation] Retrieve the net id for the given network name to create specific vm instance
201 Switch Connection ${devstack_conn_id}
202 ${output}= Write Commands Until Prompt neutron router-list | grep "${router1}" | awk '{print $2}' 30s
204 ${splitted_output}= Split String ${output} ${EMPTY}
205 ${router_id}= Get from List ${splitted_output} 0
207 [Return] ${router_id}
210 [Arguments] ${net_name} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
211 [Documentation] Create X Vm Instance with the net id of the Netowrk.
212 ${devstack_conn_id}= Get ControlNode Connection
213 Switch Connection ${devstack_conn_id}
214 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
215 : FOR ${VmElement} IN @{vm_instance_names}
216 \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-groups ${sg} 30s
219 Create Vm Instance With Port On Compute Node
220 [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
221 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
222 ${devstack_conn_id}= Get ControlNode Connection
223 Switch Connection ${devstack_conn_id}
224 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
225 ${hostname_compute_node}= Run Command On Remote System ${compute_node} hostname
226 ${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
228 Wait Until Keyword Succeeds 25s 5s Verify VM Is ACTIVE ${vm_instance_name}
231 [Arguments] ${vm_name}
232 [Documentation] Run these commands to check whether the created vm instance is active or not.
233 ${devstack_conn_id}= Get ControlNode Connection
234 Switch Connection ${devstack_conn_id}
235 ${output}= Write Commands Until Prompt nova show ${vm_name} | grep OS-EXT-STS:vm_state 30s
237 Should Contain ${output} active
239 Verify VMs Received DHCP Lease
240 [Arguments] @{vm_list}
241 [Documentation] Using nova console-log on the provided ${vm_list} to search for the string "obtained" which
242 ... correlates to the instance receiving it's IP address via DHCP. This should provide a good indication
243 ... that the instance is fully up and ready.
244 ${devstack_conn_id}= Get ControlNode Connection
245 Switch Connection ${devstack_conn_id}
246 ${ip_list} Create List @{EMPTY}
247 ${dhcp_ip} Create List @{EMPTY}
248 : FOR ${vm} IN @{vm_list}
249 \ ${vm_ip_line}= Write Commands Until Prompt nova console-log ${vm} | grep -i "obtained" 30s
251 \ @{vm_ip} Get Regexp Matches ${vm_ip_line} [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}
252 \ ${vm_ip_length} Get Length ${vm_ip}
253 \ Run Keyword If ${vm_ip_length}>0 Append To List ${ip_list} @{vm_ip}[0]
254 \ ${dhcp_ip_line}= Write Commands Until Prompt nova console-log ${vm} | grep "^nameserver" 30s
255 \ Log ${dhcp_ip_line}
256 \ @{dhcp_ip} Get Regexp Matches ${dhcp_ip_line} [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}
258 ${dhcp_length} Get Length ${dhcp_ip}
259 Return From Keyword If ${dhcp_length}==0 ${ip_list} ${EMPTY}
260 [Return] ${ip_list} @{dhcp_ip}[0]
263 [Arguments] ${vm_instance_names}
264 [Documentation] View Console log of the created vm instances using nova show.
265 : FOR ${VmElement} IN @{vm_instance_names}
266 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
268 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
271 Ping Vm From DHCP Namespace
272 [Arguments] ${net_name} ${vm_ip}
273 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
275 ${devstack_conn_id}= Get ControlNode Connection
276 Switch Connection ${devstack_conn_id}
277 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
279 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
282 Should Contain ${output} 64 bytes
284 Ping From DHCP Should Not Succeed
285 [Arguments] ${net_name} ${vm_ip}
286 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
288 ${devstack_conn_id}= Get ControlNode Connection
289 Switch Connection ${devstack_conn_id}
290 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
292 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
295 Should Not Contain ${output} 64 bytes
297 Ping Vm From Control Node
298 [Arguments] ${vm_floating_ip}
299 [Documentation] Ping VM floating IP from control node
300 Log ${vm_floating_ip}
301 ${devstack_conn_id}= Get ControlNode Connection
302 Switch Connection ${devstack_conn_id}
303 ${output}= Write Commands Until Prompt ping -c 3 ${vm_floating_ip} 20s
306 Should Contain ${output} 64 bytes
309 [Arguments] ${dest_vm_ip}
310 [Documentation] Ping to the expected destination ip.
311 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm_ip} ${OS_SYSTEM_PROMPT}
316 [Documentation] Ping to the expected destination ip.
317 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
318 Write Commands Until Prompt exit
319 Should Contain ${output} 200
322 [Documentation] Exit the vm instance.
323 ${output}= Write Commands Until Prompt exit
326 Check If Console Is VmInstance
327 [Arguments] ${console}=cirros
328 [Documentation] Check if the session has been able to login to the VM instance
329 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
330 Should Contain ${output} ${console}
333 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
334 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
335 Run Keyword If ${rcode} Write Commands Until Prompt exit
339 [Arguments] ${ip_address}
340 [Documentation] Run Ping command on the IP available as argument
341 ${output}= Write Commands Until Expected Prompt ping -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
342 Should Contain ${output} 64 bytes
344 Check Metadata Access
345 [Documentation] Try curl on the Metadataurl and check if it is okay
346 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
347 Should Contain ${output} 200
349 Execute Command on VM Instance
350 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
351 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
352 ${devstack_conn_id} = Get ControlNode Connection
353 Switch Connection ${devstack_conn_id}
354 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
356 ${output} = Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${vm_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no d:
358 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
360 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
361 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
362 [Teardown] Exit From Vm Console
365 Test Operations From Vm Instance
366 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:)
367 [Documentation] Login to the vm instance using ssh in the network.
368 ${devstack_conn_id}= Get ControlNode Connection
369 Switch Connection ${devstack_conn_id}
371 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
372 ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no ${user}@${src_ip} d:
374 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
376 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
377 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
378 Run Keyword If ${rcode} Write Commands Until Expected Prompt route ${OS_SYSTEM_PROMPT}
379 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
380 : FOR ${dest_ip} IN @{dest_ips}
382 \ ${string_empty}= Run Keyword And Return Status Should Be Empty ${dest_ip}
383 \ Run Keyword If ${string_empty} Continue For Loop
384 \ Run Keyword If ${rcode} Check Ping ${dest_ip}
385 Run Keyword If ${rcode} Check Metadata Access
386 [Teardown] Exit From Vm Console
389 [Arguments] ${list_of_external_dst_ips}
390 [Documentation] Check reachability with other network's instances.
391 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
392 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
394 \ Check Ping ${dest_ip}
397 [Arguments] ${router_name}
398 [Documentation] Create Router and Add Interface to the subnets.
399 ${devstack_conn_id}= Get ControlNode Connection
400 Switch Connection ${devstack_conn_id}
401 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name} 30s
403 Should Contain ${output} Created a new router
406 [Arguments] ${router_name} ${interface_name}
407 ${devstack_conn_id}= Get ControlNode Connection
408 Switch Connection ${devstack_conn_id}
409 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
411 Should Contain ${output} Added interface
414 [Arguments] ${router_name} ${network_name}
415 ${devstack_conn_id}= Get ControlNode Connection
416 Switch Connection ${devstack_conn_id}
417 ${output}= Write Commands Until Prompt neutron -v router-gateway-set ${router_name} ${network_name}
419 Should Contain ${output} Set gateway
422 [Arguments] ${router_name} ${interface_name}
423 [Documentation] Remove Interface to the subnets.
424 ${devstack_conn_id}= Get ControlNode Connection
425 Switch Connection ${devstack_conn_id}
426 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
428 Should Contain ${output} Removed interface from router
431 [Arguments] ${router_name} ${cmd}
432 [Documentation] Update the router with the command. Router name and command should be passed as argument.
433 ${devstack_conn_id} = Get ControlNode Connection
434 Switch Connection ${devstack_conn_id}
435 ${output} = Write Commands Until Prompt neutron router-update ${router_name} ${cmd} 30s
437 Should Contain ${output} Updated
440 [Arguments] ${router_name} ${options}
441 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
442 ${devstack_conn_id} = Get ControlNode Connection
443 Switch Connection ${devstack_conn_id}
444 ${output} = Write Commands Until Prompt neutron router-show ${router_name} ${options} 30s
449 [Arguments] ${router_name}
450 [Documentation] Delete Router and Interface to the subnets.
451 ${devstack_conn_id}= Get ControlNode Connection
452 Switch Connection ${devstack_conn_id}
453 ${output}= Write Commands Until Prompt neutron -v router-delete ${router_name} 60s
455 Should Match Regexp ${output} Deleted router: ${router_name}|Deleted router\\(s\\): ${router_name}
457 Get DumpFlows And Ovsconfig
458 [Arguments] ${openstack_node_ip}
459 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
460 Log ${openstack_node_ip}
461 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
462 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
463 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
464 Write Commands Until Expected Prompt ip -o link ]>
465 Write Commands Until Expected Prompt ip -o addr ]>
466 Write Commands Until Expected Prompt ip route ]>
467 Write Commands Until Expected Prompt arp -an ]>
468 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ]>
469 @{lines} Split To Lines ${nslist}
470 : FOR ${line} IN @{lines}
471 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ]>
472 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ]>
473 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ]>
474 Write Commands Until Expected Prompt sudo ovs-vsctl show ]>
475 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ]>
476 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ]>
477 Write Commands Until Expected Prompt sudo ovs-ofctl dump-ports-desc br-int -OOpenFlow13 ]>
478 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ]>
479 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ]>
480 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ]>
482 Get ControlNode Connection
483 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
484 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
485 SSHLibrary.Set Client Configuration timeout=30s
486 Source Password force=yes
487 [Return] ${control_conn_id}
490 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
491 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
492 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
493 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
496 [Arguments] @{vm_indices}
497 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
498 ${devstack_conn_id}= Get ControlNode Connection
499 Switch Connection ${devstack_conn_id}
500 ${output}= Write Commands Until Prompt sudo ip netns list
502 : FOR ${index} IN @{vm_indices}
503 \ ${output}= Write Commands Until Prompt nova show ${index} 30s
511 Create Security Group
512 [Arguments] ${sg_name} ${desc}
513 ${devstack_conn_id}= Get ControlNode Connection
514 Switch Connection ${devstack_conn_id}
515 ${output}= Write Commands Until Prompt nova secgroup-create ${sg_name} ${desc} 40s
519 [Arguments] ${direction} ${protocol} ${min_port} ${max_port} ${remote_ip} ${sg_name}
520 ${devstack_conn_id}= Get ControlNode Connection
521 Switch Connection ${devstack_conn_id}
522 ${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}
525 Neutron Security Group Show
526 [Arguments] ${SecurityGroupRuleName} ${additional_args}=${EMPTY}
527 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
528 ${devstack_conn_id}= Get ControlNode Connection
529 Switch Connection ${devstack_conn_id}
530 ${cmd}= Set Variable neutron security-group-show ${SecurityGroupRuleName} ${additional_args}
532 ${output}= Write Commands Until Prompt ${cmd} 30s
538 [Arguments] ${PortName} ${additional_args}=${EMPTY}
539 [Documentation] Display the port configuration that belong to a given neutron port
540 ${devstack_conn_id}= Get ControlNode Connection
541 Switch Connection ${devstack_conn_id}
542 ${cmd}= Set Variable neutron port-show ${PortName} ${additional_args}
544 ${output}= Write Commands Until Prompt ${cmd} 30s
549 Neutron Security Group Create
550 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
551 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
552 ${devstack_conn_id}= Get ControlNode Connection
553 Switch Connection ${devstack_conn_id}
554 ${cmd}= Set Variable neutron security-group-create ${SecurityGroupName} ${additional_args}
556 ${output}= Write Commands Until Prompt ${cmd} 30s
558 Should Contain ${output} Created a new security_group
559 ${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}
562 [Return] ${output} ${sgp_id}
564 Neutron Security Group Update
565 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
566 [Documentation] Updating security groups
567 ${devstack_conn_id}= Get ControlNode Connection
568 Switch Connection ${devstack_conn_id}
569 ${cmd}= Set Variable neutron security-group-update ${SecurityGroupName} ${additional_args}
571 ${output}= Write Commands Until Prompt ${cmd} 30s
576 Neutron Security Group Rule Create
577 [Arguments] ${Security_group_name} &{Kwargs}
578 [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]} ..."
579 ${devstack_conn_id}= Get ControlNode Connection
580 Switch Connection ${devstack_conn_id}
581 Run Keyword If ${Kwargs} Log ${Kwargs}
582 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
583 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
584 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
585 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
586 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
587 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
588 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
589 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
590 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
591 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
592 ... ELSE Catenate ${cmd}
593 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
594 ... ELSE Catenate ${cmd}
595 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
596 ... ELSE Catenate ${cmd}
597 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
598 ... ELSE Catenate ${cmd}
599 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
600 ... ELSE Catenate ${cmd}
601 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
602 ... ELSE Catenate ${cmd}
603 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
604 ... ELSE Catenate ${cmd}
605 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
606 ... ELSE Catenate ${cmd}
607 ${output}= Write Commands Until Prompt ${cmd} 30s
608 ${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}
610 Should Contain ${output} Created a new security_group_rule
612 [Return] ${output} ${rule_id}
614 Create Neutron Port With Additional Params
615 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
616 [Documentation] Create Port With given additional parameters
617 ${devstack_conn_id}= Get ControlNode Connection
618 Switch Connection ${devstack_conn_id}
619 ${cmd}= Set Variable neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
621 ${OUTPUT}= Write Commands Until Prompt ${cmd} 30s
623 Should Contain ${output} Created a new port
624 ${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}
627 [Return] ${OUTPUT} ${port_id}