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
18 ... neutron security-group-show default | grep "| tenant_id" | awk '{print $4}'
23 [Arguments] ${network_name} ${additional_args}=${EMPTY} ${verbose}=TRUE
24 [Documentation] Create Network with neutron request.
25 ${devstack_conn_id}= Get ControlNode Connection
26 Switch Connection ${devstack_conn_id}
27 ${command} Set Variable If "${verbose}" == "TRUE" neutron -v net-create ${network_name} ${additional_args}
28 ... neutron net-create ${network_name} ${additional_args} | grep -w id | awk '{print $4}'
29 ${output}= Write Commands Until Prompt ${command} 30s
34 [Documentation] List networks and return output with neutron client.
35 ${devstack_conn_id}= Get ControlNode Connection
36 Switch Connection ${devstack_conn_id}
37 ${output}= Write Commands Until Prompt neutron net-list 30s
43 [Documentation] List subnets and return output with neutron client.
44 ${devstack_conn_id}= Get ControlNode Connection
45 Switch Connection ${devstack_conn_id}
46 ${output}= Write Commands Until Prompt neutron subnet-list 30s
52 [Arguments] ${network_name}
53 [Documentation] Delete Network with neutron request.
54 ${devstack_conn_id}= Get ControlNode Connection
55 Switch Connection ${devstack_conn_id}
56 ${output}= Write Commands Until Prompt neutron -v net-delete ${network_name} 30s
59 Should Contain ${output} Deleted network: ${network_name}
62 [Arguments] ${network_name} ${subnet} ${range_ip}
63 [Documentation] Create SubNet for the Network with neutron request.
64 ${devstack_conn_id}= Get ControlNode Connection
65 Switch Connection ${devstack_conn_id}
66 ${output}= Write Commands Until Prompt neutron -v subnet-create ${network_name} ${range_ip} --name ${subnet} 30s
69 Should Contain ${output} Created a new subnet
72 [Arguments] ${network_name} ${port_name}
73 [Documentation] Create Port with neutron request.
74 ${devstack_conn_id}= Get ControlNode Connection
75 Switch Connection ${devstack_conn_id}
76 ${output}= Write Commands Until Prompt neutron -v port-create ${network_name} --name ${port_name} 30s
79 Should Contain ${output} Created a new port
82 [Documentation] Verifies the Gateway Ips with dump flow.
83 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
85 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
86 \ Should Contain ${output} ${GatewayIpElement}
89 [Documentation] Verifies the Dhcp Ips with dump flow.
90 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
92 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
93 \ Should Contain ${output} ${DhcpIpElement}
96 [Documentation] Verifies the Dhcp Ips with dump flow.
97 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
99 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
100 \ Should Not Contain ${output} ${DhcpIpElement}
103 [Arguments] ${subnet}
104 [Documentation] Delete SubNet for the Network with neutron request.
106 ${devstack_conn_id}= Get ControlNode Connection
107 Switch Connection ${devstack_conn_id}
108 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
111 Should Contain ${output} Deleted subnet: ${subnet}
113 Verify No Gateway Ips
114 [Documentation] Verifies the Gateway Ips removed with dump flow.
115 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
117 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
118 \ Should Not Contain ${output} ${GatewayIpElement}
121 [Arguments] ${vm_name}
122 [Documentation] Delete Vm instances using instance names.
123 ${devstack_conn_id}= Get ControlNode Connection
124 Switch Connection ${devstack_conn_id}
125 ${output}= Write Commands Until Prompt nova force-delete ${vm_name} 40s
129 [Arguments] ${network_name} ${devstack_conn_id}
130 [Documentation] Retrieve the net id for the given network name to create specific vm instance
131 Switch Connection ${devstack_conn_id}
132 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | get_field 1 30s
134 ${splitted_output}= Split String ${output} ${EMPTY}
135 ${net_id}= Get from List ${splitted_output} 0
140 [Arguments] ${net_name} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano
141 [Documentation] Create X Vm Instance with the net id of the Netowrk.
142 ${devstack_conn_id}= Get ControlNode Connection
143 Switch Connection ${devstack_conn_id}
144 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
145 : FOR ${VmElement} IN @{vm_instance_names}
146 \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} 30s
148 \ Wait Until Keyword Succeeds 25s 5s Verify VM Is ACTIVE ${VmElement}
151 [Arguments] ${vm_name}
152 [Documentation] Run these commands to check whether the created vm instance is active or not.
153 ${output}= Write Commands Until Prompt nova show ${vm_name} | grep OS-EXT-STS:vm_state 30s
155 Should Contain ${output} active
158 [Arguments] ${vm_instance_names}
159 [Documentation] View Console log of the created vm instances using nova show.
160 : FOR ${VmElement} IN @{vm_instance_names}
161 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
163 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
166 Ping Vm From DHCP Namespace
167 [Arguments] ${net_name} ${vm_ip}
168 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
170 ${devstack_conn_id}= Get ControlNode Connection
171 Switch Connection ${devstack_conn_id}
172 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
174 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
177 Should Contain ${output} 64 bytes
179 Ping From DHCP Should Not Succeed
180 [Arguments] ${net_name} ${vm_ip}
181 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
183 ${devstack_conn_id}= Get ControlNode Connection
184 Switch Connection ${devstack_conn_id}
185 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
187 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
190 Should Not Contain ${output} 64 bytes
193 [Arguments] ${dest_vm}
194 [Documentation] Ping to the expected destination ip.
195 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm} ${OS_SYSTEM_PROMPT}
200 [Documentation] Ping to the expected destination ip.
201 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
202 Write Commands Until Prompt exit
203 Should Contain ${output} 200
206 [Documentation] Exit the vm instance.
207 ${output}= Write Commands Until Prompt exit
210 Check If Console Is VmInstance
211 [Arguments] ${console}=cirros
212 [Documentation] Check if the session has been able to login to the VM instance
213 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
214 Should Contain ${output} ${console}
217 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
218 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
219 Run Keyword If ${rcode} Write Commands Until Prompt exit
223 [Arguments] ${ip_address}
224 [Documentation] Run Ping command on the IP available as argument
225 ${output}= Write Commands Until Expected Prompt ping -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
226 Should Contain ${output} 64 bytes
228 Check Metadata Access
229 [Documentation] Try curl on the Metadataurl and check if it is okay
230 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
231 Should Contain ${output} 200
233 Test Operations From Vm Instance
234 [Arguments] ${net_name} ${src_ip} ${list_of_local_dst_ips} ${l2_or_l3}=l2 ${list_of_external_dst_ips}=${NONE} ${user}=cirros
235 ... ${password}=cubswin:)
236 [Documentation] Login to the vm instance using ssh in the network.
237 ${devstack_conn_id}= Get ControlNode Connection
238 Switch Connection ${devstack_conn_id}
239 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
240 ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${src_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no d:
242 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
244 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
245 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
246 Run Keyword If ${rcode} Write Commands Until Expected Prompt route ${OS_SYSTEM_PROMPT}
247 ${dest_vm}= Get From List ${list_of_local_dst_ips} 0
249 Run Keyword If ${rcode} Check Ping ${dest_vm}
250 ${dest_dhcp}= Get From List ${list_of_local_dst_ips} 1
252 Run Keyword If ${rcode} Check Ping ${dest_dhcp}
253 ${dest_vm}= Get From List ${list_of_local_dst_ips} 2
255 Run Keyword If ${rcode} Check Ping ${dest_vm}
256 Run Keyword If ${rcode} Check Metadata Access
257 Run Keyword If '${l2_or_l3}' == 'l3' Ping Other Instances ${list_of_external_dst_ips}
258 [Teardown] Exit From Vm Console
261 [Arguments] ${list_of_external_dst_ips}
262 [Documentation] Check reachability with other network's instances.
263 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
264 ${dest_vm}= Get From List ${list_of_external_dst_ips} 0
266 Run Keyword If ${rcode} Check Ping ${dest_vm}
267 ${dest_dhcp}= Get From List ${list_of_external_dst_ips} 1
269 Run Keyword If ${rcode} Check Ping ${dest_dhcp}
270 ${dest_vm}= Get From List ${list_of_external_dst_ips} 2
272 Run Keyword If ${rcode} Check Ping ${dest_vm}
275 [Arguments] ${router_name}
276 [Documentation] Create Router and Add Interface to the subnets.
277 ${devstack_conn_id}= Get ControlNode Connection
278 Switch Connection ${devstack_conn_id}
279 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name} 30s
281 Should Contain ${output} Created a new router
284 [Arguments] ${router_name} ${interface_name}
285 ${devstack_conn_id}= Get ControlNode Connection
286 Switch Connection ${devstack_conn_id}
287 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
289 Should Contain ${output} Added interface
292 [Arguments] ${router_name} ${interface_name}
293 [Documentation] Remove Interface to the subnets.
294 ${devstack_conn_id}= Get ControlNode Connection
295 Switch Connection ${devstack_conn_id}
296 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
298 Should Contain ${output} Removed interface from router
301 [Arguments] ${router_name}
302 [Documentation] Delete Router and Interface to the subnets.
303 ${devstack_conn_id}= Get ControlNode Connection
304 Switch Connection ${devstack_conn_id}
305 ${output}= Write Commands Until Prompt neutron -v router-delete ${router_name} 60s
307 Should Contain ${output} Deleted router:
309 Get DumpFlows And Ovsconfig
310 [Arguments] ${openstack_node_ip}
311 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
312 Log ${openstack_node_ip}
313 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
314 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
315 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
316 Write Commands Until Expected Prompt sudo ovs-vsctl show ]>
317 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ]>
319 Get ControlNode Connection
320 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
321 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
322 SSHLibrary.Set Client Configuration timeout=30s
323 Source Password force=yes
324 [Return] ${control_conn_id}
327 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
328 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
329 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
330 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
333 [Arguments] ${vm_indices}
334 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
335 ${output}= Write Commands Until Prompt sudo ip netns list
337 : FOR ${index} IN @{vm_indices}
338 \ ${output}= Write Commands Until Prompt nova show ${index} 30s