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
14 [Arguments] ${network_name} ${additional_args}=${EMPTY}
15 [Documentation] Create Network with neutron request.
16 ${devstack_conn_id}= Get ControlNode Connection
17 Switch Connection ${devstack_conn_id}
18 ${output}= Write Commands Until Prompt neutron -v net-create ${network_name} ${additional_args} 30s
21 Should Contain ${output} Created a new network
24 [Documentation] List networks and return output with neutron client.
25 ${devstack_conn_id}= Get ControlNode Connection
26 Switch Connection ${devstack_conn_id}
27 ${output}= Write Commands Until Prompt neutron net-list 30s
33 [Documentation] List subnets and return output with neutron client.
34 ${devstack_conn_id}= Get ControlNode Connection
35 Switch Connection ${devstack_conn_id}
36 ${output}= Write Commands Until Prompt neutron subnet-list 30s
42 [Arguments] ${network_name}
43 [Documentation] Delete Network with neutron request.
44 ${devstack_conn_id}= Get ControlNode Connection
45 Switch Connection ${devstack_conn_id}
46 ${output}= Write Commands Until Prompt neutron -v net-delete ${network_name} 30s
49 Should Contain ${output} Deleted network: ${network_name}
52 [Arguments] ${network_name} ${subnet} ${range_ip}
53 [Documentation] Create SubNet for the 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 subnet-create ${network_name} ${range_ip} --name ${subnet} 30s
59 Should Contain ${output} Created a new subnet
62 [Documentation] Verifies the Gateway Ips with dump flow.
63 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
65 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
66 \ Should Contain ${output} ${GatewayIpElement}
69 [Documentation] Verifies the Dhcp Ips with dump flow.
70 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
72 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
73 \ Should Contain ${output} ${DhcpIpElement}
76 [Documentation] Verifies the Dhcp Ips with dump flow.
77 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
79 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
80 \ Should Not Contain ${output} ${DhcpIpElement}
84 [Documentation] Delete SubNet for the Network with neutron request.
86 ${devstack_conn_id}= Get ControlNode Connection
87 Switch Connection ${devstack_conn_id}
88 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
91 Should Contain ${output} Deleted subnet: ${subnet}
94 [Documentation] Verifies the Gateway Ips removed with dump flow.
95 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
97 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
98 \ Should Not Contain ${output} ${GatewayIpElement}
101 [Arguments] ${vm_name}
102 [Documentation] Delete Vm instances using instance names.
103 ${devstack_conn_id}= Get ControlNode Connection
104 Switch Connection ${devstack_conn_id}
105 ${output}= Write Commands Until Prompt nova force-delete ${vm_name} 40s
109 [Arguments] ${network_name} ${devstack_conn_id}
110 [Documentation] Retrieve the net id for the given network name to create specific vm instance
111 Switch Connection ${devstack_conn_id}
112 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | get_field 1 30s
114 ${splitted_output}= Split String ${output} ${EMPTY}
115 ${net_id}= Get from List ${splitted_output} 0
120 [Arguments] ${net_name} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano
121 [Documentation] Create X Vm Instance with the net id of the Netowrk.
122 ${devstack_conn_id}= Get ControlNode Connection
123 Switch Connection ${devstack_conn_id}
124 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
125 : FOR ${VmElement} IN @{vm_instance_names}
126 \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} 30s
128 \ Wait Until Keyword Succeeds 25s 5s Verify VM Is ACTIVE ${VmElement}
131 [Arguments] ${vm_name}
132 [Documentation] Run these commands to check whether the created vm instance is active or not.
133 ${output}= Write Commands Until Prompt nova show ${vm_name} | grep OS-EXT-STS:vm_state 30s
135 Should Contain ${output} active
138 [Arguments] ${vm_instance_names}
139 [Documentation] View Console log of the created vm instances using nova show.
140 : FOR ${VmElement} IN @{vm_instance_names}
141 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
143 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
146 Ping Vm From DHCP Namespace
147 [Arguments] ${net_name} ${vm_ip}
148 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
150 ${devstack_conn_id}= Get ControlNode Connection
151 Switch Connection ${devstack_conn_id}
152 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
154 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
157 Should Contain ${output} 64 bytes
159 Ping From DHCP Should Not Succeed
160 [Arguments] ${net_name} ${vm_ip}
161 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
163 ${devstack_conn_id}= Get ControlNode Connection
164 Switch Connection ${devstack_conn_id}
165 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
167 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
170 Should Not Contain ${output} 64 bytes
173 [Arguments] ${dest_vm}
174 [Documentation] Ping to the expected destination ip.
175 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm} ${OS_SYSTEM_PROMPT}
180 [Documentation] Ping to the expected destination ip.
181 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
182 Write Commands Until Prompt exit
183 Should Contain ${output} 200
186 [Documentation] Exit the vm instance.
187 ${output}= Write Commands Until Prompt exit
190 Check If Console Is VmInstance
191 [Arguments] ${console}=cirros
192 [Documentation] Check if the session has been able to login to the VM instance
193 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
194 Should Contain ${output} ${console}
197 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
198 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
199 Run Keyword If ${rcode} Write Commands Until Prompt exit
203 [Arguments] ${ip_address}
204 [Documentation] Run Ping command on the IP available as argument
205 ${output}= Write Commands Until Expected Prompt ping -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
206 Should Contain ${output} 64 bytes
208 Check Metadata Access
209 [Documentation] Try curl on the Metadataurl and check if it is okay
210 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
211 Should Contain ${output} 200
213 Test Operations From Vm Instance
214 [Arguments] ${net_name} ${src_ip} ${list_of_local_dst_ips} ${l2_or_l3}=l2 ${list_of_external_dst_ips}=${NONE} ${user}=cirros
215 ... ${password}=cubswin:)
216 [Documentation] Login to the vm instance using ssh in the network.
217 ${devstack_conn_id}= Get ControlNode Connection
218 Switch Connection ${devstack_conn_id}
219 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
220 ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${src_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no d:
222 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
224 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
225 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
226 Run Keyword If ${rcode} Write Commands Until Expected Prompt route ${OS_SYSTEM_PROMPT}
227 ${dest_vm}= Get From List ${list_of_local_dst_ips} 0
229 Run Keyword If ${rcode} Check Ping ${dest_vm}
230 ${dest_dhcp}= Get From List ${list_of_local_dst_ips} 1
232 Run Keyword If ${rcode} Check Ping ${dest_dhcp}
233 ${dest_vm}= Get From List ${list_of_local_dst_ips} 2
235 Run Keyword If ${rcode} Check Ping ${dest_vm}
236 Run Keyword If ${rcode} Check Metadata Access
237 Run Keyword If '${l2_or_l3}' == 'l3' Ping Other Instances ${list_of_external_dst_ips}
238 [Teardown] Exit From Vm Console
241 [Arguments] ${list_of_external_dst_ips}
242 [Documentation] Check reachability with other network's instances.
243 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
244 ${dest_vm}= Get From List ${list_of_external_dst_ips} 0
246 Run Keyword If ${rcode} Check Ping ${dest_vm}
247 ${dest_dhcp}= Get From List ${list_of_external_dst_ips} 1
249 Run Keyword If ${rcode} Check Ping ${dest_dhcp}
250 ${dest_vm}= Get From List ${list_of_external_dst_ips} 2
252 Run Keyword If ${rcode} Check Ping ${dest_vm}
255 [Arguments] ${router_name}
256 [Documentation] Create Router and Add Interface to the subnets.
257 ${devstack_conn_id}= Get ControlNode Connection
258 Switch Connection ${devstack_conn_id}
259 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name} 30s
261 Should Contain ${output} Created a new router
264 [Arguments] ${router_name} ${interface_name}
265 ${devstack_conn_id}= Get ControlNode Connection
266 Switch Connection ${devstack_conn_id}
267 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
269 Should Contain ${output} Added interface
272 [Arguments] ${router_name} ${interface_name}
273 [Documentation] Remove Interface to the subnets.
274 ${devstack_conn_id}= Get ControlNode Connection
275 Switch Connection ${devstack_conn_id}
276 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
278 Should Contain ${output} Removed interface from router
281 [Arguments] ${router_name}
282 [Documentation] Delete Router and Interface to the subnets.
283 ${devstack_conn_id}= Get ControlNode Connection
284 Switch Connection ${devstack_conn_id}
285 ${output}= Write Commands Until Prompt neutron -v router-delete ${router_name} 60s
287 Should Contain ${output} Deleted router:
289 Get DumpFlows And Ovsconfig
290 [Arguments] ${openstack_node_ip}
291 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
292 Log ${openstack_node_ip}
293 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
294 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
295 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
296 Write Commands Until Expected Prompt sudo ovs-vsctl show ]>
297 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ]>
299 Get ControlNode Connection
300 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
301 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
302 SSHLibrary.Set Client Configuration timeout=30s
303 Source Password force=yes
304 [Return] ${control_conn_id}
307 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
308 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
309 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
310 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
313 [Arguments] ${vm_indices}
314 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
315 ${output}= Write Commands Until Prompt sudo ip netns list
317 : FOR ${index} IN @{vm_indices}
318 \ ${output}= Write Commands Until Prompt nova show ${index} 30s