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
105 Create And Associate Floating IPs
106 [Arguments] ${external_net} @{vm_list}
107 [Documentation] Create and associate floating IPs to VMs with nova request
108 ${devstack_conn_id}= Get ControlNode Connection
109 Switch Connection ${devstack_conn_id}
110 ${ip_list}= Create List @{EMPTY}
111 : FOR ${vm} IN @{vm_list}
112 \ ${output}= Write Commands Until Prompt nova floating-ip-create ${external_net} | grep "${external_net}" 30s
114 \ @{output_words} Split String ${output}
115 \ Append To List ${ip_list} @{output_words}[3]
116 \ ${output}= Write Commands Until Prompt nova floating-ip-associate ${vm} @{output_words}[3] 30s
121 [Documentation] Verifies the Gateway Ips with dump flow.
122 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
124 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
125 \ Should Contain ${output} ${GatewayIpElement}
128 [Documentation] Verifies the Dhcp Ips with dump flow.
129 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
131 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
132 \ Should Contain ${output} ${DhcpIpElement}
135 [Documentation] Verifies the Dhcp Ips with dump flow.
136 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
138 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
139 \ Should Not Contain ${output} ${DhcpIpElement}
142 [Arguments] ${subnet}
143 [Documentation] Delete SubNet for the Network with neutron request.
145 ${devstack_conn_id}= Get ControlNode Connection
146 Switch Connection ${devstack_conn_id}
147 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
150 Should Match Regexp ${output} Deleted subnet: ${subnet}|Deleted subnet\\(s\\): ${subnet}
152 Verify No Gateway Ips
153 [Documentation] Verifies the Gateway Ips removed with dump flow.
154 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
156 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
157 \ Should Not Contain ${output} ${GatewayIpElement}
160 [Arguments] ${vm_name}
161 [Documentation] Delete Vm instances using instance names.
162 ${devstack_conn_id}= Get ControlNode Connection
163 Switch Connection ${devstack_conn_id}
164 ${output}= Write Commands Until Prompt nova force-delete ${vm_name} 40s
168 [Arguments] ${network_name} ${devstack_conn_id}
169 [Documentation] Retrieve the net id for the given network name to create specific vm instance
170 Switch Connection ${devstack_conn_id}
171 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | awk '{print $2}' 30s
173 ${splitted_output}= Split String ${output} ${EMPTY}
174 ${net_id}= Get from List ${splitted_output} 0
179 [Arguments] ${port_name} ${devstack_conn_id}
180 [Documentation] Retrieve the port id for the given port name to attach specific vm instance to a particular port
181 Switch Connection ${devstack_conn_id}
182 ${output}= Write Commands Until Prompt neutron port-list | grep "${port_name}" | awk '{print $2}' 30s
184 ${splitted_output}= Split String ${output} ${EMPTY}
185 ${port_id}= Get from List ${splitted_output} 0
190 [Arguments] ${router1} ${devstack_conn_id}
191 [Documentation] Retrieve the net id for the given network name to create specific vm instance
192 Switch Connection ${devstack_conn_id}
193 ${output}= Write Commands Until Prompt neutron router-list | grep "${router1}" | awk '{print $2}' 30s
195 ${splitted_output}= Split String ${output} ${EMPTY}
196 ${router_id}= Get from List ${splitted_output} 0
198 [Return] ${router_id}
201 [Arguments] ${net_name} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
202 [Documentation] Create X Vm Instance with the net id of the Netowrk.
203 ${devstack_conn_id}= Get ControlNode Connection
204 Switch Connection ${devstack_conn_id}
205 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
206 : FOR ${VmElement} IN @{vm_instance_names}
207 \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-groups ${sg} 30s
210 Create Vm Instance With Port On Compute Node
211 [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
212 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
213 ${devstack_conn_id}= Get ControlNode Connection
214 Switch Connection ${devstack_conn_id}
215 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
216 ${hostname_compute_node}= Run Command On Remote System ${compute_node} hostname
217 ${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
219 Wait Until Keyword Succeeds 25s 5s Verify VM Is ACTIVE ${vm_instance_name}
222 [Arguments] ${vm_name}
223 [Documentation] Run these commands to check whether the created vm instance is active or not.
224 ${devstack_conn_id}= Get ControlNode Connection
225 Switch Connection ${devstack_conn_id}
226 ${output}= Write Commands Until Prompt nova show ${vm_name} | grep OS-EXT-STS:vm_state 30s
228 Should Contain ${output} active
230 Verify VMs Received DHCP Lease
231 [Arguments] @{vm_list}
232 [Documentation] Using nova console-log on the provided ${vm_list} to search for the string "obtained" which
233 ... correlates to the instance receiving it's IP address via DHCP. This should provide a good indication
234 ... that the instance is fully up and ready.
235 ${devstack_conn_id}= Get ControlNode Connection
236 Switch Connection ${devstack_conn_id}
237 ${ip_list} Create List
238 : FOR ${vm} IN @{vm_list}
239 \ ${output}= Write Commands Until Prompt nova console-log ${vm} | grep -i "obtained" 30s
240 \ ${dhcp_ip_line}= Write Commands Until Prompt nova console-log ${vm} | grep "^nameserver" 30s
242 \ @{output_words} Split String ${output}
243 \ @{dhcp_output_words} Split String ${dhcp_ip_line}
244 \ Should Contain ${output} obtained
245 \ Append To List ${ip_list} @{output_words}[2]
246 [Return] ${ip_list} @{dhcp_output_words}[1]
249 [Arguments] ${vm_instance_names}
250 [Documentation] View Console log of the created vm instances using nova show.
251 : FOR ${VmElement} IN @{vm_instance_names}
252 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
254 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
257 Ping Vm From DHCP Namespace
258 [Arguments] ${net_name} ${vm_ip}
259 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
261 ${devstack_conn_id}= Get ControlNode Connection
262 Switch Connection ${devstack_conn_id}
263 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
265 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
268 Should Contain ${output} 64 bytes
270 Ping From DHCP Should Not Succeed
271 [Arguments] ${net_name} ${vm_ip}
272 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
274 ${devstack_conn_id}= Get ControlNode Connection
275 Switch Connection ${devstack_conn_id}
276 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
278 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
281 Should Not Contain ${output} 64 bytes
283 Ping Vm From Control Node
284 [Arguments] ${vm_floating_ip}
285 [Documentation] Ping VM floating IP from control node
286 Log ${vm_floating_ip}
287 ${devstack_conn_id}= Get ControlNode Connection
288 Switch Connection ${devstack_conn_id}
289 ${output}= Write Commands Until Prompt ping -c 3 ${vm_floating_ip} 20s
292 Should Contain ${output} 64 bytes
295 [Arguments] ${dest_vm_ip}
296 [Documentation] Ping to the expected destination ip.
297 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm_ip} ${OS_SYSTEM_PROMPT}
302 [Documentation] Ping to the expected destination ip.
303 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
304 Write Commands Until Prompt exit
305 Should Contain ${output} 200
308 [Documentation] Exit the vm instance.
309 ${output}= Write Commands Until Prompt exit
312 Check If Console Is VmInstance
313 [Arguments] ${console}=cirros
314 [Documentation] Check if the session has been able to login to the VM instance
315 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
316 Should Contain ${output} ${console}
319 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
320 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
321 Run Keyword If ${rcode} Write Commands Until Prompt exit
325 [Arguments] ${ip_address}
326 [Documentation] Run Ping command on the IP available as argument
327 ${output}= Write Commands Until Expected Prompt ping -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
328 Should Contain ${output} 64 bytes
330 Check Metadata Access
331 [Documentation] Try curl on the Metadataurl and check if it is okay
332 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
333 Should Contain ${output} 200
335 Execute Command on VM Instance
336 [Arguments] ${net_name} ${vm_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
337 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
338 ${devstack_conn_id} = Get ControlNode Connection
339 Switch Connection ${devstack_conn_id}
340 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
342 ${output} = Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${vm_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no d:
344 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
346 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
347 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
348 [Teardown] Exit From Vm Console
351 Test Operations From Vm Instance
352 [Arguments] ${net_name} ${src_ip} ${dest_ips} ${user}=cirros ${password}=cubswin:)
353 [Documentation] Login to the vm instance using ssh in the network.
354 ${devstack_conn_id}= Get ControlNode Connection
355 Switch Connection ${devstack_conn_id}
357 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
358 ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no ${user}@${src_ip} d:
360 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
362 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
363 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
364 Run Keyword If ${rcode} Write Commands Until Expected Prompt route ${OS_SYSTEM_PROMPT}
365 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
366 : FOR ${dest_ip} IN @{dest_ips}
368 \ ${string_empty}= Run Keyword And Return Status Should Be Empty ${dest_ip}
369 \ Run Keyword If ${string_empty} Continue For Loop
370 \ Run Keyword If ${rcode} Check Ping ${dest_ip}
371 Run Keyword If ${rcode} Check Metadata Access
372 [Teardown] Exit From Vm Console
375 [Arguments] ${list_of_external_dst_ips}
376 [Documentation] Check reachability with other network's instances.
377 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
378 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
380 \ Check Ping ${dest_ip}
383 [Arguments] ${router_name}
384 [Documentation] Create Router and Add Interface to the subnets.
385 ${devstack_conn_id}= Get ControlNode Connection
386 Switch Connection ${devstack_conn_id}
387 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name} 30s
389 Should Contain ${output} Created a new router
392 [Arguments] ${router_name} ${interface_name}
393 ${devstack_conn_id}= Get ControlNode Connection
394 Switch Connection ${devstack_conn_id}
395 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
397 Should Contain ${output} Added interface
400 [Arguments] ${router_name} ${network_name}
401 ${devstack_conn_id}= Get ControlNode Connection
402 Switch Connection ${devstack_conn_id}
403 ${output}= Write Commands Until Prompt neutron -v router-gateway-set ${router_name} ${network_name}
405 Should Contain ${output} Set gateway
408 [Arguments] ${router_name} ${interface_name}
409 [Documentation] Remove Interface to the subnets.
410 ${devstack_conn_id}= Get ControlNode Connection
411 Switch Connection ${devstack_conn_id}
412 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
414 Should Contain ${output} Removed interface from router
417 [Arguments] ${router_name} ${cmd}
418 [Documentation] Update the router with the command. Router name and command should be passed as argument.
419 ${devstack_conn_id} = Get ControlNode Connection
420 Switch Connection ${devstack_conn_id}
421 ${output} = Write Commands Until Prompt neutron router-update ${router_name} ${cmd} 30s
423 Should Contain ${output} Updated
426 [Arguments] ${router_name} ${options}
427 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
428 ${devstack_conn_id} = Get ControlNode Connection
429 Switch Connection ${devstack_conn_id}
430 ${output} = Write Commands Until Prompt neutron router-show ${router_name} ${options} 30s
435 [Arguments] ${router_name}
436 [Documentation] Delete Router and Interface to the subnets.
437 ${devstack_conn_id}= Get ControlNode Connection
438 Switch Connection ${devstack_conn_id}
439 ${output}= Write Commands Until Prompt neutron -v router-delete ${router_name} 60s
441 Should Match Regexp ${output} Deleted router: ${router_name}|Deleted router\\(s\\): ${router_name}
443 Get DumpFlows And Ovsconfig
444 [Arguments] ${openstack_node_ip}
445 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
446 Log ${openstack_node_ip}
447 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
448 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
449 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
450 Write Commands Until Expected Prompt ip -o link ]>
451 Write Commands Until Expected Prompt ip -o addr ]>
452 Write Commands Until Expected Prompt ip route ]>
453 Write Commands Until Expected Prompt arp -an ]>
454 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ]>
455 @{lines} Split To Lines ${nslist}
456 : FOR ${line} IN @{lines}
457 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ]>
458 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ]>
459 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ]>
460 Write Commands Until Expected Prompt sudo ovs-vsctl show ]>
461 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ]>
462 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ]>
463 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ]>
464 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ]>
465 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ]>
467 Get ControlNode Connection
468 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
469 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
470 SSHLibrary.Set Client Configuration timeout=30s
471 Source Password force=yes
472 [Return] ${control_conn_id}
475 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
476 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
477 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
478 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
481 [Arguments] @{vm_indices}
482 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
483 ${devstack_conn_id}= Get ControlNode Connection
484 Switch Connection ${devstack_conn_id}
485 ${output}= Write Commands Until Prompt sudo ip netns list
487 : FOR ${index} IN @{vm_indices}
488 \ ${output}= Write Commands Until Prompt nova show ${index} 30s
495 Create Security Group
496 [Arguments] ${sg_name} ${desc}
497 ${devstack_conn_id}= Get ControlNode Connection
498 Switch Connection ${devstack_conn_id}
499 ${output}= Write Commands Until Prompt nova secgroup-create ${sg_name} ${desc} 40s
503 [Arguments] ${direction} ${protocol} ${min_port} ${max_port} ${remote_ip} ${sg_name}
504 ${devstack_conn_id}= Get ControlNode Connection
505 Switch Connection ${devstack_conn_id}
506 ${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}
509 Neutron Security Group Show
510 [Arguments] ${SecurityGroupRuleName} ${additional_args}=${EMPTY}
511 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
512 ${devstack_conn_id}= Get ControlNode Connection
513 Switch Connection ${devstack_conn_id}
514 ${cmd}= Set Variable neutron security-group-show ${SecurityGroupRuleName} ${additional_args}
516 ${output}= Write Commands Until Prompt ${cmd} 30s
522 [Arguments] ${PortName} ${additional_args}=${EMPTY}
523 [Documentation] Display the port configuration that belong to a given neutron port
524 ${devstack_conn_id}= Get ControlNode Connection
525 Switch Connection ${devstack_conn_id}
526 ${cmd}= Set Variable neutron port-show ${PortName} ${additional_args}
528 ${output}= Write Commands Until Prompt ${cmd} 30s
533 Neutron Security Group Create
534 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
535 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
536 ${devstack_conn_id}= Get ControlNode Connection
537 Switch Connection ${devstack_conn_id}
538 ${cmd}= Set Variable neutron security-group-create ${SecurityGroupName} ${additional_args}
540 ${output}= Write Commands Until Prompt ${cmd} 30s
542 Should Contain ${output} Created a new security_group
543 ${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}
546 [Return] ${output} ${sgp_id}
548 Neutron Security Group Update
549 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
550 [Documentation] Updating security groups
551 ${devstack_conn_id}= Get ControlNode Connection
552 Switch Connection ${devstack_conn_id}
553 ${cmd}= Set Variable neutron security-group-update ${SecurityGroupName} ${additional_args}
555 ${output}= Write Commands Until Prompt ${cmd} 30s
560 Neutron Security Group Rule Create
561 [Arguments] ${Security_group_name} &{Kwargs}
562 [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]} ..."
563 ${devstack_conn_id}= Get ControlNode Connection
564 Switch Connection ${devstack_conn_id}
565 Run Keyword If ${Kwargs} Log ${Kwargs}
566 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
567 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
568 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
569 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
570 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
571 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
572 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
573 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
574 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
575 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
576 ... ELSE Catenate ${cmd}
577 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
578 ... ELSE Catenate ${cmd}
579 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
580 ... ELSE Catenate ${cmd}
581 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
582 ... ELSE Catenate ${cmd}
583 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
584 ... ELSE Catenate ${cmd}
585 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
586 ... ELSE Catenate ${cmd}
587 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
588 ... ELSE Catenate ${cmd}
589 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
590 ... ELSE Catenate ${cmd}
591 ${output}= Write Commands Until Prompt ${cmd} 30s
592 ${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}
594 Should Contain ${output} Created a new security_group_rule
596 [Return] ${output} ${rule_id}
598 Create Neutron Port With Additional Params
599 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
600 [Documentation] Create Port With given additional parameters
601 ${devstack_conn_id}= Get ControlNode Connection
602 Switch Connection ${devstack_conn_id}
603 ${cmd}= Set Variable neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
605 ${OUTPUT}= Write Commands Until Prompt ${cmd} 30s
607 Should Contain ${output} Created a new port
608 ${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}
611 [Return] ${OUTPUT} ${port_id}