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 [Arguments] ${network_name}
25 [Documentation] Delete Network with neutron request.
26 ${devstack_conn_id}= Get ControlNode Connection
27 Switch Connection ${devstack_conn_id}
28 ${output}= Write Commands Until Prompt neutron -v net-delete ${network_name} 30s
31 Should Contain ${output} Deleted network: ${network_name}
34 [Arguments] ${network_name} ${subnet} ${range_ip}
35 [Documentation] Create SubNet for the Network with neutron request.
36 ${devstack_conn_id}= Get ControlNode Connection
37 Switch Connection ${devstack_conn_id}
38 ${output}= Write Commands Until Prompt neutron -v subnet-create ${network_name} ${range_ip} --name ${subnet} 30s
41 Should Contain ${output} Created a new subnet
44 [Documentation] Verifies the Gateway Ips with dump flow.
45 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
47 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
48 \ Should Contain ${output} ${GatewayIpElement}
51 [Documentation] Verifies the Dhcp Ips with dump flow.
52 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
54 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
55 \ Should Contain ${output} ${DhcpIpElement}
58 [Documentation] Verifies the Dhcp Ips with dump flow.
59 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
61 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
62 \ Should Not Contain ${output} ${DhcpIpElement}
66 [Documentation] Delete SubNet for the Network with neutron request.
68 ${devstack_conn_id}= Get ControlNode Connection
69 Switch Connection ${devstack_conn_id}
70 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
73 Should Contain ${output} Deleted subnet: ${subnet}
76 [Documentation] Verifies the Gateway Ips removed with dump flow.
77 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
79 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
80 \ Should Not Contain ${output} ${GatewayIpElement}
83 [Arguments] ${vm_name}
84 [Documentation] Delete Vm instances using instance names.
85 ${devstack_conn_id}= Get ControlNode Connection
86 Switch Connection ${devstack_conn_id}
87 ${output}= Write Commands Until Prompt nova force-delete ${vm_name} 40s
91 [Arguments] ${network_name} ${connection_id}
92 [Documentation] Retrieve the net id for the given network name to create specific vm instance
93 Switch Connection ${connection_id}
94 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | get_field 1 30s
96 ${splitted_output}= Split String ${output} ${EMPTY}
97 ${net_id}= Get from List ${splitted_output} 0
102 [Arguments] ${net_name} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano
103 [Documentation] Create X Vm Instance with the net id of the Netowrk.
104 ${devstack_conn_id}= Get ControlNode Connection
105 Switch Connection ${devstack_conn_id}
106 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
107 : FOR ${VmElement} IN @{vm_instance_names}
108 \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} 30s
110 \ Wait Until Keyword Succeeds 25s 5s Verify VM Is ACTIVE ${VmElement}
113 [Arguments] ${vm_name}
114 [Documentation] Run these commands to check whether the created vm instance is active or not.
115 ${output}= Write Commands Until Prompt nova show ${vm_name} | grep OS-EXT-STS:vm_state 30s
117 Should Contain ${output} active
120 [Arguments] ${vm_instance_names}
121 [Documentation] View Console log of the created vm instances using nova show.
122 : FOR ${VmElement} IN @{vm_instance_names}
123 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
125 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
128 Ping Vm From DHCP Namespace
129 [Arguments] ${net_name} ${vm_ip}
130 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
132 ${devstack_conn_id}= Get ControlNode Connection
133 Switch Connection ${devstack_conn_id}
134 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
136 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
139 Should Contain ${output} 64 bytes
141 Ping From DHCP Should Not Succeed
142 [Arguments] ${net_name} ${vm_ip}
143 [Documentation] Should Not Reach Vm Instance with the net id of the Netowrk.
145 ${devstack_conn_id}= Get ControlNode Connection
146 Switch Connection ${devstack_conn_id}
147 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
149 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
152 Should Not Contain ${output} 64 bytes
155 [Arguments] ${dest_vm}
156 [Documentation] Ping to the expected destination ip.
157 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm} ${OS_SYSTEM_PROMPT}
162 [Documentation] Ping to the expected destination ip.
163 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
164 Write Commands Until Prompt exit
165 Should Contain ${output} 200
168 [Documentation] Exit the vm instance.
169 ${output}= Write Commands Until Prompt exit
172 Check If Console Is VmInstance
173 [Arguments] ${console}=cirros
174 [Documentation] Check if the session has been able to login to the VM instance
175 ${output}= Write Commands Until Expected Prompt id ${OS_SYSTEM_PROMPT}
176 Should Contain ${output} ${console}
179 [Documentation] Check if the session has been able to login to the VM instance and exit the instance
180 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance cirros
181 Run Keyword If ${rcode} Write Commands Until Prompt exit
185 [Arguments] ${ip_address}
186 [Documentation] Run Ping command on the IP available as argument
187 ${output}= Write Commands Until Expected Prompt ping -c 3 ${ip_address} ${OS_SYSTEM_PROMPT}
188 Should Contain ${output} 64 bytes
190 Check Metadata Access
191 [Documentation] Try curl on the Metadataurl and check if it is okay
192 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 ${OS_SYSTEM_PROMPT}
193 Should Contain ${output} 200
195 Test Operations From Vm Instance
196 [Arguments] ${net_name} ${src_ip} ${list_of_local_dst_ips} ${l2_or_l3}=l2 ${list_of_external_dst_ips}=${NONE} ${user}=cirros
197 ... ${password}=cubswin:)
198 [Documentation] Login to the vm instance using ssh in the network.
199 ${devstack_conn_id}= Get ControlNode Connection
200 Switch Connection ${devstack_conn_id}
201 ${net_id}= Get Net Id ${net_name} ${devstack_conn_id}
202 ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh ${user}@${src_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no d:
204 ${output}= Write Commands Until Expected Prompt ${password} ${OS_SYSTEM_PROMPT}
206 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
207 Run Keyword If ${rcode} Write Commands Until Expected Prompt ifconfig ${OS_SYSTEM_PROMPT}
208 Run Keyword If ${rcode} Write Commands Until Expected Prompt route ${OS_SYSTEM_PROMPT}
209 ${dest_vm}= Get From List ${list_of_local_dst_ips} 0
211 Run Keyword If ${rcode} Check Ping ${dest_vm}
212 ${dest_dhcp}= Get From List ${list_of_local_dst_ips} 1
214 Run Keyword If ${rcode} Check Ping ${dest_dhcp}
215 ${dest_vm}= Get From List ${list_of_local_dst_ips} 2
217 Run Keyword If ${rcode} Check Ping ${dest_vm}
218 Run Keyword If ${rcode} Check Metadata Access
219 Run Keyword If '${l2_or_l3}' == 'l3' Ping Other Instances ${list_of_external_dst_ips}
220 [Teardown] Exit From Vm Console
223 [Arguments] ${list_of_external_dst_ips}
224 [Documentation] Check reachability with other network's instances.
225 ${rcode}= Run Keyword And Return Status Check If Console Is VmInstance
226 ${dest_vm}= Get From List ${list_of_external_dst_ips} 0
228 Run Keyword If ${rcode} Check Ping ${dest_vm}
229 ${dest_dhcp}= Get From List ${list_of_external_dst_ips} 1
231 Run Keyword If ${rcode} Check Ping ${dest_dhcp}
232 ${dest_vm}= Get From List ${list_of_external_dst_ips} 2
234 Run Keyword If ${rcode} Check Ping ${dest_vm}
237 [Arguments] ${router_name}
238 [Documentation] Create Router and Add Interface to the subnets.
239 ${devstack_conn_id}= Get ControlNode Connection
240 Switch Connection ${devstack_conn_id}
241 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name} 30s
243 Should Contain ${output} Created a new router
246 [Arguments] ${router_name} ${interface_name}
247 ${devstack_conn_id}= Get ControlNode Connection
248 Switch Connection ${devstack_conn_id}
249 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
251 Should Contain ${output} Added interface
254 [Arguments] ${router_name} ${interface_name}
255 [Documentation] Remove Interface to the subnets.
256 ${devstack_conn_id}= Get ControlNode Connection
257 Switch Connection ${devstack_conn_id}
258 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
260 Should Contain ${output} Removed interface from router
263 [Arguments] ${router_name}
264 [Documentation] Delete Router and 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-delete ${router_name} 60s
269 Should Contain ${output} Deleted router:
271 Get DumpFlows And Ovsconfig
272 [Arguments] ${openstack_node_ip}
273 [Documentation] Get the OvsConfig and Flow entries from OVS from the Openstack Node
274 Log ${openstack_node_ip}
275 SSHLibrary.Open Connection ${openstack_node_ip} prompt=${DEFAULT_LINUX_PROMPT}
276 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
277 SSHLibrary.Set Client Configuration timeout=${default_devstack_prompt_timeout}
278 Write Commands Until Expected Prompt sudo ovs-vsctl show ]>
279 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows br-int -OOpenFlow13 ]>
281 Get ControlNode Connection
282 ${control_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
283 Utils.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
284 SSHLibrary.Set Client Configuration timeout=30s
285 Source Password force=yes
286 [Return] ${control_conn_id}
289 [Documentation] Get the OvsConfig and Flow entries from all Openstack nodes
290 Run Keyword If 0 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_CONTROL_NODE_IP}
291 Run Keyword If 1 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_1_IP}
292 Run Keyword If 2 < ${NUM_OS_SYSTEM} Get DumpFlows And Ovsconfig ${OS_COMPUTE_2_IP}
295 [Arguments] ${vm_indices}
296 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
297 ${output}= Write Commands Until Prompt sudo ip netns list
299 : FOR ${index} IN @{vm_indices}
300 \ ${output}= Write Commands Until Prompt nova show ${index} 30s