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} = RequestsLibrary.Get Request session ${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/
26 ${matches} = Get Lines Containing String ${resp.content} tenant-id
27 ${matches}= Fetch From Right ${matches} :
28 ${tenant_id}= Strip String ${matches} characters=}]"
32 [Arguments] ${network_name} ${additional_args}=${EMPTY} ${verbose}=TRUE
33 [Documentation] Create Network with neutron request.
34 ${devstack_conn_id}= Get ControlNode Connection
35 Switch Connection ${devstack_conn_id}
36 ${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}'
37 ${output}= Write Commands Until Prompt ${command} 30s
42 [Documentation] List networks and return output with neutron client.
43 ${devstack_conn_id}= Get ControlNode Connection
44 Switch Connection ${devstack_conn_id}
45 ${output}= Write Commands Until Prompt neutron net-list 30s
51 [Documentation] List subnets and return output with neutron client.
52 ${devstack_conn_id}= Get ControlNode Connection
53 Switch Connection ${devstack_conn_id}
54 ${output}= Write Commands Until Prompt neutron subnet-list 30s
60 [Arguments] ${network_name}
61 [Documentation] Delete Network with neutron request.
62 ${devstack_conn_id}= Get ControlNode Connection
63 Switch Connection ${devstack_conn_id}
64 ${output}= Write Commands Until Prompt neutron -v net-delete ${network_name} 30s
67 Should Match Regexp ${output} Deleted network: ${network_name}|Deleted network\\(s\\): ${network_name}
70 [Arguments] ${network_name} ${subnet} ${range_ip} ${additional_args}=${EMPTY}
71 [Documentation] Create SubNet for the Network with neutron request.
72 ${devstack_conn_id}= Get ControlNode Connection
73 Switch Connection ${devstack_conn_id}
74 ${output}= Write Commands Until Prompt neutron -v subnet-create ${network_name} ${range_ip} --name ${subnet} ${additional_args} 30s
77 Should Contain ${output} Created a new subnet
80 [Arguments] ${network_name} ${port_name} ${sg}=default
81 [Documentation] Create Port with neutron request.
82 ${devstack_conn_id}= Get ControlNode Connection
83 Switch Connection ${devstack_conn_id}
84 ${output}= Write Commands Until Prompt neutron -v port-create ${network_name} --name ${port_name} --security-group ${sg} 30s
87 Should Contain ${output} Created a new port
90 [Arguments] ${port_name}
91 [Documentation] Delete Port with neutron request.
92 ${devstack_conn_id}= Get ControlNode Connection
93 Switch Connection ${devstack_conn_id}
94 ${output}= Write Commands Until Prompt neutron -v port-delete ${port_name} 30s
97 Should Contain ${output} Deleted port: ${port_name}
100 [Documentation] List ports and return output with neutron client.
101 ${devstack_conn_id}= Get ControlNode Connection
102 Switch Connection ${devstack_conn_id}
103 ${output}= Write Commands Until Prompt neutron port-list 30s
108 Create And Associate Floating IPs
109 [Arguments] ${external_net} @{vm_list}
110 [Documentation] Create and associate floating IPs to VMs with nova request
111 ${devstack_conn_id}= Get ControlNode Connection
112 Switch Connection ${devstack_conn_id}
113 ${ip_list}= Create List @{EMPTY}
114 : FOR ${vm} IN @{vm_list}
115 \ ${output}= Write Commands Until Prompt nova floating-ip-create ${external_net} | grep "${external_net}" 30s
117 \ @{output_words} Split String ${output}
118 \ Append To List ${ip_list} @{output_words}[3]
119 \ ${output}= Write Commands Until Prompt nova floating-ip-associate ${vm} @{output_words}[3] 30s
124 [Documentation] Verifies the Gateway Ips with dump flow.
125 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
127 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
128 \ Should Contain ${output} ${GatewayIpElement}
131 [Documentation] Verifies the Dhcp Ips with dump flow.
132 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
134 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
135 \ Should Contain ${output} ${DhcpIpElement}
138 [Documentation] Verifies the Dhcp Ips with dump flow.
139 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
141 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
142 \ Should Not Contain ${output} ${DhcpIpElement}
145 [Arguments] ${subnet}
146 [Documentation] Delete SubNet for the Network with neutron request.
148 ${devstack_conn_id}= Get ControlNode Connection
149 Switch Connection ${devstack_conn_id}
150 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
153 Should Match Regexp ${output} Deleted subnet: ${subnet}|Deleted subnet\\(s\\): ${subnet}
155 Verify No Gateway Ips
156 [Documentation] Verifies the Gateway Ips removed with dump flow.
157 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
159 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
160 \ Should Not Contain ${output} ${GatewayIpElement}
163 [Arguments] ${vm_name}
164 [Documentation] Delete Vm instances using instance names.
165 ${devstack_conn_id}= Get ControlNode Connection
166 Switch Connection ${devstack_conn_id}
167 ${output}= Write Commands Until Prompt nova force-delete ${vm_name} 40s
171 [Arguments] ${network_name} ${devstack_conn_id}
172 [Documentation] Retrieve the net id for the given network name to create specific vm instance
173 Switch Connection ${devstack_conn_id}
174 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | awk '{print $2}' 30s
176 ${splitted_output}= Split String ${output} ${EMPTY}
177 ${net_id}= Get from List ${splitted_output} 0
182 [Arguments] ${port_name} ${devstack_conn_id}
183 [Documentation] Retrieve the port id for the given port name to attach specific vm instance to a particular port
184 Switch Connection ${devstack_conn_id}
185 ${output}= Write Commands Until Prompt neutron port-list | grep "${port_name}" | awk '{print $2}' 30s
187 ${splitted_output}= Split String ${output} ${EMPTY}
188 ${port_id}= Get from List ${splitted_output} 0
193 [Arguments] ${router1} ${devstack_conn_id}
194 [Documentation] Retrieve the net id for the given network name to create specific vm instance
195 Switch Connection ${devstack_conn_id}
196 ${output}= Write Commands Until Prompt neutron router-list | grep "${router1}" | awk '{print $2}' 30s
198 ${splitted_output}= Split String ${output} ${EMPTY}
199 ${router_id}= Get from List ${splitted_output} 0
201 [Return] ${router_id}
204 [Arguments] ${net_name} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
205 [Documentation] Create X Vm Instance with the net id of the Netowrk.
206 ${devstack_conn_id}= Get ControlNode Connection
207 Switch Connection ${devstack_conn_id}
208 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
209 : FOR ${VmElement} IN @{vm_instance_names}
210 \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-groups ${sg} 30s
213 Create Vm Instance With Port On Compute Node
214 [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
215 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
216 ${devstack_conn_id}= Get ControlNode Connection
217 Switch Connection ${devstack_conn_id}
218 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
219 ${hostname_compute_node}= Run Command On Remote System ${compute_node} hostname
220 ${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
222 Wait Until Keyword Succeeds 25s 5s Verify VM Is ACTIVE ${vm_instance_name}
225 [Arguments] ${vm_name}
226 [Documentation] Run these commands to check whether the created vm instance is active or not.
227 ${devstack_conn_id}= Get ControlNode Connection
228 Switch Connection ${devstack_conn_id}
229 ${output}= Write Commands Until Prompt nova show ${vm_name} | grep OS-EXT-STS:vm_state 30s
231 Should Contain ${output} active
233 Verify VMs Received DHCP Lease
234 [Arguments] @{vm_list}
235 [Documentation] Using nova console-log on the provided ${vm_list} to search for the string "obtained" which
236 ... correlates to the instance receiving it's IP address via DHCP. This should provide a good indication
237 ... that the instance is fully up and ready.
238 ${devstack_conn_id}= Get ControlNode Connection
239 Switch Connection ${devstack_conn_id}
240 ${ip_list} Create List
241 : FOR ${vm} IN @{vm_list}
242 \ ${output}= Write Commands Until Prompt nova console-log ${vm} | grep -i "obtained" 30s
243 \ ${dhcp_ip_line}= Write Commands Until Prompt nova console-log ${vm} | grep "^nameserver" 30s
245 \ @{output_words} Split String ${output}
246 \ @{dhcp_output_words} Split String ${dhcp_ip_line}
247 \ Should Contain ${output} obtained
248 \ Append To List ${ip_list} @{output_words}[2]
249 [Return] ${ip_list} @{dhcp_output_words}[1]
252 [Arguments] ${vm_instance_names}
253 [Documentation] View Console log of the created vm instances using nova show.
254 : FOR ${VmElement} IN @{vm_instance_names}
255 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
257 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
260 Ping Vm From DHCP Namespace
261 [Arguments] ${net_name} ${vm_ip}
262 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
264 ${devstack_conn_id}= Get ControlNode Connection
265 Switch Connection ${devstack_conn_id}
266 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
268 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
271 Should Contain ${output} 64 bytes
273 Ping From DHCP Should Not Succeed
274 [Arguments] ${net_name} ${vm_ip}
275 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
277 ${devstack_conn_id}= Get ControlNode Connection
278 Switch Connection ${devstack_conn_id}
279 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
281 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
284 Should Not Contain ${output} 64 bytes
286 Ping Vm From Control Node
287 [Arguments] ${vm_floating_ip}
288 [Documentation] Ping VM floating IP from control node
289 Log ${vm_floating_ip}
290 ${devstack_conn_id}= Get ControlNode Connection
291 Switch Connection ${devstack_conn_id}
292 ${output}= Write Commands Until Prompt ping -c 3 ${vm_floating_ip} 20s
295 Should Contain ${output} 64 bytes
298 [Arguments] ${dest_vm_ip}
299 [Documentation] Ping to the expected destination ip.
300 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm_ip} ${OS_SYSTEM_PROMPT}
305 [Documentation] Ping to the expected destination ip.
306 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
307 Write Commands Until Prompt exit
308 Should Contain ${output} 200
311 [Documentation] Exit the vm instance.
312 ${output}= Write Commands Until Prompt exit
315 Check If Console Is VmInstance
316 [Arguments] ${console}=cirros
317 [Documentation] Check if the session has been able to login to the VM instance
318 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
319 Should Contain ${output} ${console}
322 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
323 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
324 Run Keyword If ${rcode} Write Commands Until Prompt exit
328 [Arguments] ${ip_address}
329 [Documentation] Run Ping command on the IP available as argument
330 ${output}= Write Commands Until Expected Prompt ping -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
331 Should Contain ${output} 64 bytes
333 Check Metadata Access
334 [Documentation] Try curl on the Metadataurl and check if it is okay
335 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
336 Should Contain ${output} 200
338 Execute Command on VM Instance
339 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
340 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
341 ${devstack_conn_id} = Get ControlNode Connection
342 Switch Connection ${devstack_conn_id}
343 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
345 ${output} = Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${vm_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no d:
347 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
349 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
350 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
351 [Teardown] Exit From Vm Console
354 Test Operations From Vm Instance
355 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:)
356 [Documentation] Login to the vm instance using ssh in the network.
357 ${devstack_conn_id}= Get ControlNode Connection
358 Switch Connection ${devstack_conn_id}
360 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
361 ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no ${user}@${src_ip} d:
363 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
365 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
366 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
367 Run Keyword If ${rcode} Write Commands Until Expected Prompt route ${OS_SYSTEM_PROMPT}
368 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
369 : FOR ${dest_ip} IN @{dest_ips}
371 \ ${string_empty}= Run Keyword And Return Status Should Be Empty ${dest_ip}
372 \ Run Keyword If ${string_empty} Continue For Loop
373 \ Run Keyword If ${rcode} Check Ping ${dest_ip}
374 Run Keyword If ${rcode} Check Metadata Access
375 [Teardown] Exit From Vm Console
378 [Arguments] ${list_of_external_dst_ips}
379 [Documentation] Check reachability with other network's instances.
380 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
381 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
383 \ Check Ping ${dest_ip}
386 [Arguments] ${router_name}
387 [Documentation] Create Router and Add Interface to the subnets.
388 ${devstack_conn_id}= Get ControlNode Connection
389 Switch Connection ${devstack_conn_id}
390 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name} 30s
392 Should Contain ${output} Created a new router
395 [Arguments] ${router_name} ${interface_name}
396 ${devstack_conn_id}= Get ControlNode Connection
397 Switch Connection ${devstack_conn_id}
398 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
400 Should Contain ${output} Added interface
403 [Arguments] ${router_name} ${network_name}
404 ${devstack_conn_id}= Get ControlNode Connection
405 Switch Connection ${devstack_conn_id}
406 ${output}= Write Commands Until Prompt neutron -v router-gateway-set ${router_name} ${network_name}
408 Should Contain ${output} Set gateway
411 [Arguments] ${router_name} ${interface_name}
412 [Documentation] Remove Interface to the subnets.
413 ${devstack_conn_id}= Get ControlNode Connection
414 Switch Connection ${devstack_conn_id}
415 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
417 Should Contain ${output} Removed interface from router
420 [Arguments] ${router_name} ${cmd}
421 [Documentation] Update the router with the command. Router name and command should be passed as argument.
422 ${devstack_conn_id} = Get ControlNode Connection
423 Switch Connection ${devstack_conn_id}
424 ${output} = Write Commands Until Prompt neutron router-update ${router_name} ${cmd} 30s
426 Should Contain ${output} Updated
429 [Arguments] ${router_name} ${options}
430 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
431 ${devstack_conn_id} = Get ControlNode Connection
432 Switch Connection ${devstack_conn_id}
433 ${output} = Write Commands Until Prompt neutron router-show ${router_name} ${options} 30s
438 [Arguments] ${router_name}
439 [Documentation] Delete Router and Interface to the subnets.
440 ${devstack_conn_id}= Get ControlNode Connection
441 Switch Connection ${devstack_conn_id}
442 ${output}= Write Commands Until Prompt neutron -v router-delete ${router_name} 60s
444 Should Match Regexp ${output} Deleted router: ${router_name}|Deleted router\\(s\\): ${router_name}
446 Get DumpFlows And Ovsconfig
447 [Arguments] ${openstack_node_ip}
448 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
449 Log ${openstack_node_ip}
450 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
451 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
452 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
453 Write Commands Until Expected Prompt ip -o link ]>
454 Write Commands Until Expected Prompt ip -o addr ]>
455 Write Commands Until Expected Prompt ip route ]>
456 Write Commands Until Expected Prompt arp -an ]>
457 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ]>
458 @{lines} Split To Lines ${nslist}
459 : FOR ${line} IN @{lines}
460 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ]>
461 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ]>
462 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ]>
463 Write Commands Until Expected Prompt sudo ovs-vsctl show ]>
464 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ]>
465 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ]>
466 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ]>
467 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ]>
468 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ]>
470 Get ControlNode Connection
471 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
472 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
473 SSHLibrary.Set Client Configuration timeout=30s
474 Source Password force=yes
475 [Return] ${control_conn_id}
478 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
479 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
480 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
481 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
484 [Arguments] ${vm_indices}
485 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
486 ${devstack_conn_id}= Get ControlNode Connection
487 Switch Connection ${devstack_conn_id}
488 ${output}= Write Commands Until Prompt sudo ip netns list
490 : FOR ${index} IN @{vm_indices}
491 \ ${output}= Write Commands Until Prompt nova show ${index} 30s
498 Create Security Group
499 [Arguments] ${sg_name} ${desc}
500 ${devstack_conn_id}= Get ControlNode Connection
501 Switch Connection ${devstack_conn_id}
502 ${output}= Write Commands Until Prompt nova secgroup-create ${sg_name} ${desc} 40s
506 [Arguments] ${direction} ${protocol} ${min_port} ${max_port} ${remote_ip} ${sg_name}
507 ${devstack_conn_id}= Get ControlNode Connection
508 Switch Connection ${devstack_conn_id}
509 ${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}
512 Neutron Security Group Show
513 [Arguments] ${SecurityGroupRuleName} ${additional_args}=${EMPTY}
514 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
515 ${devstack_conn_id}= Get ControlNode Connection
516 Switch Connection ${devstack_conn_id}
517 ${cmd}= Set Variable neutron security-group-show ${SecurityGroupRuleName} ${additional_args}
519 ${output}= Write Commands Until Prompt ${cmd} 30s
525 [Arguments] ${PortName} ${additional_args}=${EMPTY}
526 [Documentation] Display the port configuration that belong to a given neutron port
527 ${devstack_conn_id}= Get ControlNode Connection
528 Switch Connection ${devstack_conn_id}
529 ${cmd}= Set Variable neutron port-show ${PortName} ${additional_args}
531 ${output}= Write Commands Until Prompt ${cmd} 30s
536 Neutron Security Group Create
537 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
538 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
539 ${devstack_conn_id}= Get ControlNode Connection
540 Switch Connection ${devstack_conn_id}
541 ${cmd}= Set Variable neutron security-group-create ${SecurityGroupName} ${additional_args}
543 ${output}= Write Commands Until Prompt ${cmd} 30s
545 Should Contain ${output} Created a new security_group
546 ${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}
549 [Return] ${output} ${sgp_id}
551 Neutron Security Group Update
552 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
553 [Documentation] Updating security groups
554 ${devstack_conn_id}= Get ControlNode Connection
555 Switch Connection ${devstack_conn_id}
556 ${cmd}= Set Variable neutron security-group-update ${SecurityGroupName} ${additional_args}
558 ${output}= Write Commands Until Prompt ${cmd} 30s
563 Neutron Security Group Rule Create
564 [Arguments] ${Security_group_name} &{Kwargs}
565 [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]} ..."
566 ${devstack_conn_id}= Get ControlNode Connection
567 Switch Connection ${devstack_conn_id}
568 Run Keyword If ${Kwargs} Log ${Kwargs}
569 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
570 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
571 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
572 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
573 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
574 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
575 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
576 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
577 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
578 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
579 ... ELSE Catenate ${cmd}
580 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
581 ... ELSE Catenate ${cmd}
582 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
583 ... ELSE Catenate ${cmd}
584 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
585 ... ELSE Catenate ${cmd}
586 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
587 ... ELSE Catenate ${cmd}
588 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
589 ... ELSE Catenate ${cmd}
590 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
591 ... ELSE Catenate ${cmd}
592 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
593 ... ELSE Catenate ${cmd}
594 ${output}= Write Commands Until Prompt ${cmd} 30s
595 ${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}
597 Should Contain ${output} Created a new security_group_rule
599 [Return] ${output} ${rule_id}
601 Create Neutron Port With Additional Params
602 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
603 [Documentation] Create Port With given additional parameters
604 ${devstack_conn_id}= Get ControlNode Connection
605 Switch Connection ${devstack_conn_id}
606 ${cmd}= Set Variable neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
608 ${OUTPUT}= Write Commands Until Prompt ${cmd} 30s
610 Should Contain ${output} Created a new port
611 ${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}
614 [Return] ${OUTPUT} ${port_id}