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
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}
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} 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 [Arguments] ${network_name}
34 [Documentation] Delete Network with neutron request.
35 ${devstack_conn_id}= Get ControlNode Connection
36 Switch Connection ${devstack_conn_id}
37 ${output}= Write Commands Until Prompt neutron -v net-delete ${network_name} 30s
40 Should Contain ${output} Deleted network: ${network_name}
43 [Arguments] ${network_name} ${subnet} ${range_ip}
44 [Documentation] Create SubNet for the Network with neutron request.
45 ${devstack_conn_id}= Get ControlNode Connection
46 Switch Connection ${devstack_conn_id}
47 ${output}= Write Commands Until Prompt neutron -v subnet-create ${network_name} ${range_ip} --name ${subnet} 30s
50 Should Contain ${output} Created a new subnet
53 [Documentation] Verifies the Gateway Ips with dump flow.
54 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
56 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
57 \ Should Contain ${output} ${GatewayIpElement}
60 [Documentation] Verifies the Dhcp Ips with dump flow.
61 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
63 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
64 \ Should Contain ${output} ${DhcpIpElement}
67 [Documentation] Verifies the Dhcp Ips with dump flow.
68 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
70 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
71 \ Should Not Contain ${output} ${DhcpIpElement}
75 [Documentation] Delete SubNet for the Network with neutron request.
77 ${devstack_conn_id}= Get ControlNode Connection
78 Switch Connection ${devstack_conn_id}
79 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
82 Should Contain ${output} Deleted subnet: ${subnet}
85 [Documentation] Verifies the Gateway Ips removed with dump flow.
86 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
88 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
89 \ Should Not Contain ${output} ${GatewayIpElement}
92 [Arguments] ${vm_name}
93 [Documentation] Delete Vm instances using instance names.
94 ${devstack_conn_id}= Get ControlNode Connection
95 Switch Connection ${devstack_conn_id}
96 ${output}= Write Commands Until Prompt nova force-delete ${vm_name} 40s
100 [Arguments] ${network_name} ${devstack_conn_id}
101 [Documentation] Retrieve the net id for the given network name to create specific vm instance
102 Switch Connection ${devstack_conn_id}
103 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | get_field 1 30s
105 ${splitted_output}= Split String ${output} ${EMPTY}
106 ${net_id}= Get from List ${splitted_output} 0
111 [Arguments] ${net_name} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano
112 [Documentation] Create X Vm Instance with the net id of the Netowrk.
113 ${devstack_conn_id}= Get ControlNode Connection
114 Switch Connection ${devstack_conn_id}
115 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
116 : FOR ${VmElement} IN @{vm_instance_names}
117 \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} 30s
119 \ Wait Until Keyword Succeeds 25s 5s Verify VM Is ACTIVE ${VmElement}
122 [Arguments] ${vm_name}
123 [Documentation] Run these commands to check whether the created vm instance is active or not.
124 ${output}= Write Commands Until Prompt nova show ${vm_name} | grep OS-EXT-STS:vm_state 30s
126 Should Contain ${output} active
129 [Arguments] ${vm_instance_names}
130 [Documentation] View Console log of the created vm instances using nova show.
131 : FOR ${VmElement} IN @{vm_instance_names}
132 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
134 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
137 Ping Vm From DHCP Namespace
138 [Arguments] ${net_name} ${vm_ip}
139 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
141 ${devstack_conn_id}= Get ControlNode Connection
142 Switch Connection ${devstack_conn_id}
143 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
145 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
148 Should Contain ${output} 64 bytes
150 Ping From DHCP Should Not Succeed
151 [Arguments] ${net_name} ${vm_ip}
152 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
154 ${devstack_conn_id}= Get ControlNode Connection
155 Switch Connection ${devstack_conn_id}
156 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
158 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
161 Should Not Contain ${output} 64 bytes
164 [Arguments] ${dest_vm}
165 [Documentation] Ping to the expected destination ip.
166 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm} ${OS_SYSTEM_PROMPT}
171 [Documentation] Ping to the expected destination ip.
172 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
173 Write Commands Until Prompt exit
174 Should Contain ${output} 200
177 [Documentation] Exit the vm instance.
178 ${output}= Write Commands Until Prompt exit
181 Check If Console Is VmInstance
182 [Arguments] ${console}=cirros
183 [Documentation] Check if the session has been able to login to the VM instance
184 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
185 Should Contain ${output} ${console}
188 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
189 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
190 Run Keyword If ${rcode} Write Commands Until Prompt exit
194 [Arguments] ${ip_address}
195 [Documentation] Run Ping command on the IP available as argument
196 ${output}= Write Commands Until Expected Prompt ping -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
197 Should Contain ${output} 64 bytes
199 Check Metadata Access
200 [Documentation] Try curl on the Metadataurl and check if it is okay
201 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
202 Should Contain ${output} 200
204 Test Operations From Vm Instance
205 [Arguments] ${net_name} ${src_ip} ${list_of_local_dst_ips} ${l2_or_l3}=l2 ${list_of_external_dst_ips}=${NONE} ${user}=cirros
206 ... ${password}=cubswin:)
207 [Documentation] Login to the vm instance using ssh in the network.
208 ${devstack_conn_id}= Get ControlNode Connection
209 Switch Connection ${devstack_conn_id}
210 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
211 ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${src_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no d:
213 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
215 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
216 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
217 Run Keyword If ${rcode} Write Commands Until Expected Prompt route ${OS_SYSTEM_PROMPT}
218 ${dest_vm}= Get From List ${list_of_local_dst_ips} 0
220 Run Keyword If ${rcode} Check Ping ${dest_vm}
221 ${dest_dhcp}= Get From List ${list_of_local_dst_ips} 1
223 Run Keyword If ${rcode} Check Ping ${dest_dhcp}
224 ${dest_vm}= Get From List ${list_of_local_dst_ips} 2
226 Run Keyword If ${rcode} Check Ping ${dest_vm}
227 Run Keyword If ${rcode} Check Metadata Access
228 Run Keyword If '${l2_or_l3}' == 'l3' Ping Other Instances ${list_of_external_dst_ips}
229 [Teardown] Exit From Vm Console
232 [Arguments] ${list_of_external_dst_ips}
233 [Documentation] Check reachability with other network's instances.
234 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
235 ${dest_vm}= Get From List ${list_of_external_dst_ips} 0
237 Run Keyword If ${rcode} Check Ping ${dest_vm}
238 ${dest_dhcp}= Get From List ${list_of_external_dst_ips} 1
240 Run Keyword If ${rcode} Check Ping ${dest_dhcp}
241 ${dest_vm}= Get From List ${list_of_external_dst_ips} 2
243 Run Keyword If ${rcode} Check Ping ${dest_vm}
246 [Arguments] ${router_name}
247 [Documentation] Create Router and Add Interface to the subnets.
248 ${devstack_conn_id}= Get ControlNode Connection
249 Switch Connection ${devstack_conn_id}
250 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name} 30s
252 Should Contain ${output} Created a new router
255 [Arguments] ${router_name} ${interface_name}
256 ${devstack_conn_id}= Get ControlNode Connection
257 Switch Connection ${devstack_conn_id}
258 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
260 Should Contain ${output} Added interface
263 [Arguments] ${router_name} ${interface_name}
264 [Documentation] Remove Interface to the subnets.
265 ${devstack_conn_id}= Get ControlNode Connection
266 Switch Connection ${devstack_conn_id}
267 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
269 Should Contain ${output} Removed interface from router
272 [Arguments] ${router_name}
273 [Documentation] Delete Router and 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-delete ${router_name} 60s
278 Should Contain ${output} Deleted router:
280 Get DumpFlows And Ovsconfig
281 [Arguments] ${openstack_node_ip}
282 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
283 Log ${openstack_node_ip}
284 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
285 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
286 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
287 Write Commands Until Expected Prompt sudo ovs-vsctl show ]>
288 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ]>
290 Get ControlNode Connection
291 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
292 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
293 SSHLibrary.Set Client Configuration timeout=30s
294 Source Password force=yes
295 [Return] ${control_conn_id}
298 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
299 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
300 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
301 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
304 [Arguments] ${vm_indices}
305 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
306 ${output}= Write Commands Until Prompt sudo ip netns list
308 : FOR ${index} IN @{vm_indices}
309 \ ${output}= Write Commands Until Prompt nova show ${index} 30s