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}
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} 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
109 [Documentation] Verifies the Gateway Ips with dump flow.
110 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
112 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
113 \ Should Contain ${output} ${GatewayIpElement}
116 [Documentation] Verifies the Dhcp Ips with dump flow.
117 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
119 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
120 \ Should Contain ${output} ${DhcpIpElement}
123 [Documentation] Verifies the Dhcp Ips with dump flow.
124 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
126 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
127 \ Should Not Contain ${output} ${DhcpIpElement}
130 [Arguments] ${subnet}
131 [Documentation] Delete SubNet for the Network with neutron request.
133 ${devstack_conn_id}= Get ControlNode Connection
134 Switch Connection ${devstack_conn_id}
135 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
138 Should Match Regexp ${output} Deleted subnet: ${subnet}|Deleted subnet\\(s\\): ${subnet}
140 Verify No Gateway Ips
141 [Documentation] Verifies the Gateway Ips removed with dump flow.
142 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
144 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
145 \ Should Not Contain ${output} ${GatewayIpElement}
148 [Arguments] ${vm_name}
149 [Documentation] Delete Vm instances using instance names.
150 ${devstack_conn_id}= Get ControlNode Connection
151 Switch Connection ${devstack_conn_id}
152 ${output}= Write Commands Until Prompt nova force-delete ${vm_name} 40s
156 [Arguments] ${network_name} ${devstack_conn_id}
157 [Documentation] Retrieve the net id for the given network name to create specific vm instance
158 Switch Connection ${devstack_conn_id}
159 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | awk '{print $2}' 30s
161 ${splitted_output}= Split String ${output} ${EMPTY}
162 ${net_id}= Get from List ${splitted_output} 0
167 [Arguments] ${port_name} ${devstack_conn_id}
168 [Documentation] Retrieve the port id for the given port name to attach specific vm instance to a particular port
169 Switch Connection ${devstack_conn_id}
170 ${output}= Write Commands Until Prompt neutron port-list | grep "${port_name}" | awk '{print $2}' 30s
172 ${splitted_output}= Split String ${output} ${EMPTY}
173 ${port_id}= Get from List ${splitted_output} 0
178 [Arguments] ${router1} ${devstack_conn_id}
179 [Documentation] Retrieve the net id for the given network name to create specific vm instance
180 Switch Connection ${devstack_conn_id}
181 ${output}= Write Commands Until Prompt neutron router-list | grep "${router1}" | awk '{print $2}' 30s
183 ${splitted_output}= Split String ${output} ${EMPTY}
184 ${router_id}= Get from List ${splitted_output} 0
186 [Return] ${router_id}
189 [Arguments] ${net_name} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
190 [Documentation] Create X Vm Instance with the net id of the Netowrk.
191 ${devstack_conn_id}= Get ControlNode Connection
192 Switch Connection ${devstack_conn_id}
193 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
194 : FOR ${VmElement} IN @{vm_instance_names}
195 \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-groups ${sg} 30s
198 Create Vm Instance With Port On Compute Node
199 [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default
200 [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node}
201 ${devstack_conn_id}= Get ControlNode Connection
202 Switch Connection ${devstack_conn_id}
203 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
204 ${hostname_compute_node}= Run Command On Remote System ${compute_node} hostname
205 ${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
207 Wait Until Keyword Succeeds 25s 5s Verify VM Is ACTIVE ${vm_instance_name}
210 [Arguments] ${vm_name}
211 [Documentation] Run these commands to check whether the created vm instance is active or not.
212 ${devstack_conn_id}= Get ControlNode Connection
213 Switch Connection ${devstack_conn_id}
214 ${output}= Write Commands Until Prompt nova show ${vm_name} | grep OS-EXT-STS:vm_state 30s
216 Should Contain ${output} active
218 Verify VMs Received DHCP Lease
219 [Arguments] @{vm_list}
220 [Documentation] Using nova console-log on the provided ${vm_name} to search for the string "obtained" which
221 ... correlates to the instance receiving it's IP address via DHCP. This should provide a good indication
222 ... that the instance is fully up and ready.
223 ${devstack_conn_id}= Get ControlNode Connection
224 Switch Connection ${devstack_conn_id}
225 : FOR ${vm} IN @{vm_list}
226 \ ${output}= Write Commands Until Prompt nova console-log ${vm} | grep -i "obtained" 30s
228 \ Should Contain ${output} obtained
231 [Arguments] ${vm_instance_names}
232 [Documentation] View Console log of the created vm instances using nova show.
233 : FOR ${VmElement} IN @{vm_instance_names}
234 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
236 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
239 Ping Vm From DHCP Namespace
240 [Arguments] ${net_name} ${vm_ip}
241 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
243 ${devstack_conn_id}= Get ControlNode Connection
244 Switch Connection ${devstack_conn_id}
245 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
247 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
250 Should Contain ${output} 64 bytes
252 Ping From DHCP Should Not Succeed
253 [Arguments] ${net_name} ${vm_ip}
254 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
256 ${devstack_conn_id}= Get ControlNode Connection
257 Switch Connection ${devstack_conn_id}
258 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
260 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
263 Should Not Contain ${output} 64 bytes
266 [Arguments] ${dest_vm}
267 [Documentation] Ping to the expected destination ip.
268 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm} ${OS_SYSTEM_PROMPT}
273 [Documentation] Ping to the expected destination ip.
274 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
275 Write Commands Until Prompt exit
276 Should Contain ${output} 200
279 [Documentation] Exit the vm instance.
280 ${output}= Write Commands Until Prompt exit
283 Check If Console Is VmInstance
284 [Arguments] ${console}=cirros
285 [Documentation] Check if the session has been able to login to the VM instance
286 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
287 Should Contain ${output} ${console}
290 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
291 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
292 Run Keyword If ${rcode} Write Commands Until Prompt exit
296 [Arguments] ${ip_address}
297 [Documentation] Run Ping command on the IP available as argument
298 ${output}= Write Commands Until Expected Prompt ping -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
299 Should Contain ${output} 64 bytes
301 Check Metadata Access
302 [Documentation] Try curl on the Metadataurl and check if it is okay
303 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
304 Should Contain ${output} 200
306 Execute Command on VM Instance
307 [Arguments] ${net_name} ${src_ip} ${cmd} ${user}=cirros ${password}=cubswin:)
308 [Documentation] Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
309 ${devstack_conn_id} = Get ControlNode Connection
310 Switch Connection ${devstack_conn_id}
311 ${net_id} = Get Net Id ${net_name} ${devstack_conn_id}
312 ${output} = Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${src_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no d:
314 ${output} = Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
316 ${rcode} = Run Keyword And Return Status Check If Console Is VmInstance
317 ${output} = Run Keyword If ${rcode} Write Commands Until Expected Prompt ${cmd} ${OS_SYSTEM_PROMPT}
318 [Teardown] Exit From Vm Console
321 Test Operations From Vm Instance
322 [Arguments] ${net_name} ${src_ip} ${list_of_local_dst_ips} ${l2_or_l3}=l2 ${list_of_external_dst_ips}=${NONE} ${user}=cirros
323 ... ${password}=cubswin:)
324 [Documentation] Login to the vm instance using ssh in the network.
325 ${devstack_conn_id}= Get ControlNode Connection
326 Switch Connection ${devstack_conn_id}
327 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
328 ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${src_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no d:
330 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
332 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
333 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
334 Run Keyword If ${rcode} Write Commands Until Expected Prompt route ${OS_SYSTEM_PROMPT}
335 Run Keyword If ${rcode} Write Commands Until Expected Prompt arp -an ${OS_SYSTEM_PROMPT}
336 : FOR ${dest_ip} IN @{list_of_local_dst_ips}
338 \ Run Keyword If ${rcode} Check Ping ${dest_ip}
339 Run Keyword If ${rcode} Check Metadata Access
340 Run Keyword If '${l2_or_l3}' == 'l3' Ping Other Instances ${list_of_external_dst_ips}
341 [Teardown] Exit From Vm Console
344 [Arguments] ${list_of_external_dst_ips}
345 [Documentation] Check reachability with other network's instances.
346 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
347 : FOR ${dest_ip} IN @{list_of_external_dst_ips}
349 \ Run Keyword If ${rcode} Check Ping ${dest_ip}
352 [Arguments] ${router_name}
353 [Documentation] Create Router and Add Interface to the subnets.
354 ${devstack_conn_id}= Get ControlNode Connection
355 Switch Connection ${devstack_conn_id}
356 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name} 30s
358 Should Contain ${output} Created a new router
361 [Arguments] ${router_name} ${interface_name}
362 ${devstack_conn_id}= Get ControlNode Connection
363 Switch Connection ${devstack_conn_id}
364 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
366 Should Contain ${output} Added interface
369 [Arguments] ${router_name} ${interface_name}
370 [Documentation] Remove Interface to the subnets.
371 ${devstack_conn_id}= Get ControlNode Connection
372 Switch Connection ${devstack_conn_id}
373 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
375 Should Contain ${output} Removed interface from router
378 [Arguments] ${router_name} ${cmd}
379 [Documentation] Update the router with the command. Router name and command should be passed as argument.
380 ${devstack_conn_id} = Get ControlNode Connection
381 Switch Connection ${devstack_conn_id}
382 ${output} = Write Commands Until Prompt neutron router-update ${router_name} ${cmd} 30s
384 Should Contain ${output} Updated
387 [Arguments] ${router_name} ${options}
388 [Documentation] Show information of a given router. Router name and optional fields should be sent as arguments.
389 ${devstack_conn_id} = Get ControlNode Connection
390 Switch Connection ${devstack_conn_id}
391 ${output} = Write Commands Until Prompt neutron router-show ${router_name} ${options} 30s
396 [Arguments] ${router_name}
397 [Documentation] Delete Router and Interface to the subnets.
398 ${devstack_conn_id}= Get ControlNode Connection
399 Switch Connection ${devstack_conn_id}
400 ${output}= Write Commands Until Prompt neutron -v router-delete ${router_name} 60s
402 Should Contain ${output} Deleted router:
404 Get DumpFlows And Ovsconfig
405 [Arguments] ${openstack_node_ip}
406 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
407 Log ${openstack_node_ip}
408 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
409 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
410 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
411 Write Commands Until Expected Prompt ip -o link ]>
412 Write Commands Until Expected Prompt ip -o addr ]>
413 Write Commands Until Expected Prompt ip route ]>
414 Write Commands Until Expected Prompt arp -an ]>
415 ${nslist}= Write Commands Until Expected Prompt ip netns list | awk '{print $1}' ]>
416 @{lines} Split To Lines ${nslist}
417 : FOR ${line} IN @{lines}
418 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o link ]>
419 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip -o addr ]>
420 \ Write Commands Until Expected Prompt sudo ip netns exec ${line} ip route ]>
421 Write Commands Until Expected Prompt sudo ovs-vsctl show ]>
422 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ]>
423 Write Commands Until Expected Prompt sudo ovs-ofctl show br-int -OOpenFlow13 ]>
424 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ]>
425 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups br-int -OOpenFlow13 ]>
426 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13 ]>
428 Get ControlNode Connection
429 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
430 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
431 SSHLibrary.Set Client Configuration timeout=30s
432 Source Password force=yes
433 [Return] ${control_conn_id}
436 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
437 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
438 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
439 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
442 [Arguments] ${vm_indices}
443 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
444 ${devstack_conn_id}= Get ControlNode Connection
445 Switch Connection ${devstack_conn_id}
446 ${output}= Write Commands Until Prompt sudo ip netns list
448 : FOR ${index} IN @{vm_indices}
449 \ ${output}= Write Commands Until Prompt nova show ${index} 30s
456 Create Security Group
457 [Arguments] ${sg_name} ${desc}
458 ${devstack_conn_id}= Get ControlNode Connection
459 Switch Connection ${devstack_conn_id}
460 ${output}= Write Commands Until Prompt nova secgroup-create ${sg_name} ${desc} 40s
464 [Arguments] ${direction} ${protocol} ${min_port} ${max_port} ${remote_ip} ${sg_name}
465 ${devstack_conn_id}= Get ControlNode Connection
466 Switch Connection ${devstack_conn_id}
467 ${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}
470 Neutron Security Group Show
471 [Arguments] ${SecurityGroupRuleName} ${additional_args}=${EMPTY}
472 [Documentation] Displays the neutron security group configurations that belongs to a given neutron security group name
473 ${devstack_conn_id}= Get ControlNode Connection
474 Switch Connection ${devstack_conn_id}
475 ${cmd}= Set Variable neutron security-group-show ${SecurityGroupRuleName} ${additional_args}
477 ${output}= Write Commands Until Prompt ${cmd} 30s
483 [Arguments] ${PortName} ${additional_args}=${EMPTY}
484 [Documentation] Display the port configuration that belong to a given neutron port
485 ${devstack_conn_id}= Get ControlNode Connection
486 Switch Connection ${devstack_conn_id}
487 ${cmd}= Set Variable neutron port-show ${PortName} ${additional_args}
489 ${output}= Write Commands Until Prompt ${cmd} 30s
494 Neutron Security Group Create
495 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
496 [Documentation] Create a security group with specified name ,description & protocol value according to security group template
497 ${devstack_conn_id}= Get ControlNode Connection
498 Switch Connection ${devstack_conn_id}
499 ${cmd}= Set Variable neutron security-group-create ${SecurityGroupName} ${additional_args}
501 ${output}= Write Commands Until Prompt ${cmd} 30s
503 Should Contain ${output} Created a new security_group
504 ${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}
507 [Return] ${output} ${sgp_id}
509 Neutron Security Group Update
510 [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
511 [Documentation] Updating security groups
512 ${devstack_conn_id}= Get ControlNode Connection
513 Switch Connection ${devstack_conn_id}
514 ${cmd}= Set Variable neutron security-group-update ${SecurityGroupName} ${additional_args}
516 ${output}= Write Commands Until Prompt ${cmd} 30s
521 Neutron Security Group Rule Create
522 [Arguments] ${Security_group_name} &{Kwargs}
523 [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]} ..."
524 ${devstack_conn_id}= Get ControlNode Connection
525 Switch Connection ${devstack_conn_id}
526 Run Keyword If ${Kwargs} Log ${Kwargs}
527 ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
528 ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
529 ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
530 ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
531 ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
532 ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
533 ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
534 ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
535 ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
536 ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
537 ... ELSE Catenate ${cmd}
538 ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
539 ... ELSE Catenate ${cmd}
540 ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
541 ... ELSE Catenate ${cmd}
542 ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
543 ... ELSE Catenate ${cmd}
544 ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
545 ... ELSE Catenate ${cmd}
546 ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
547 ... ELSE Catenate ${cmd}
548 ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
549 ... ELSE Catenate ${cmd}
550 ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
551 ... ELSE Catenate ${cmd}
552 ${output}= Write Commands Until Prompt ${cmd} 30s
553 ${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}
555 Should Contain ${output} Created a new security_group_rule
557 [Return] ${output} ${rule_id}
559 Create Neutron Port With Additional Params
560 [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
561 [Documentation] Create Port With given additional parameters
562 ${devstack_conn_id}= Get ControlNode Connection
563 Switch Connection ${devstack_conn_id}
564 ${cmd}= Set Variable neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
566 ${OUTPUT}= Write Commands Until Prompt ${cmd} 30s
568 Should Contain ${output} Created a new port
569 ${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}
572 [Return] ${OUTPUT} ${port_id}