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] ${network_name} ${devstack_path}=/opt/stack/new/devstack
10 [Documentation] Create Network with neutron request.
11 ${output}= Write Commands Until Prompt cd ${devstack_path} && cat localrc
13 ${output}= Write Commands Until Prompt source openrc admin admin
15 ${output}= Write Commands Until Prompt neutron -v net-create ${network_name}
17 Should Contain ${output} Created a new network
20 [Arguments] ${network_name}
21 [Documentation] Delete Network with neutron request.
22 ${output}= Write Commands Until Prompt neutron -v net-delete ${network_name}
24 Should Contain ${output} Deleted network: ${network_name}
27 [Arguments] ${network_name} ${subnet} ${range_ip}
28 [Documentation] Create SubNet for the Network with neutron request.
29 ${output}= Write Commands Until Prompt neutron -v subnet-create ${network_name} ${range_ip} --name ${subnet}
31 Should Contain ${output} Created a new subnet
34 [Documentation] Verifies the Gateway Ips with dump flow.
35 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
37 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
38 \ Should Contain ${output} ${GatewayIpElement}
41 [Documentation] Verifies the Dhcp Ips with dump flow.
42 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
44 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
45 \ Should Contain ${output} ${DhcpIpElement}
48 [Documentation] Verifies the Dhcp Ips with dump flow.
49 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
51 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
52 \ Should Not Contain ${output} ${DhcpIpElement}
56 [Documentation] Delete SubNet for the Network with neutron request.
58 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
60 Should Contain ${output} Deleted subnet: ${subnet}
63 [Documentation] Verifies the Gateway Ips removed with dump flow.
64 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
66 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
67 \ Should Not Contain ${output} ${GatewayIpElement}
70 [Arguments] ${net_id} ${network_name}
71 [Documentation] Create Vm Instance with the net id of the Netowrk.
72 ${VmElement}= Set Variable If "${network_name}"=="net1_network" MyFirstInstance MySecondInstance
73 ${output}= Write Commands Until Prompt nova boot --image cirros-0.3.4-x86_64-uec --flavor m1.tiny --nic net-id=${net_id} ${VmElement}
77 [Arguments] ${vm_name}
78 [Documentation] Delete Vm instances using instance names.
79 ${output}= Write Commands Until Prompt nova delete ${vm_name}
83 [Arguments] ${network_name}
84 [Documentation] Retrieve the net id for the given network name to create specific vm instance
85 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | get_field 1
87 ${splitted_output}= Split String ${output} ${EMPTY}
88 ${net_id}= Get from List ${splitted_output} 0
93 [Arguments] ${net_id} ${vm_instance_names} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.tiny
94 [Documentation] Create Four Vm Instance with the net id of the Netowrk.
95 : FOR ${VmElement} IN @{vm_instance_names}
96 \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement}
100 [Arguments] ${vm_instance_names}
101 [Documentation] View Console log of the created vm instances using nova show.
102 : FOR ${VmElement} IN @{vm_instance_names}
103 \ ${output}= Write Commands Until Prompt nova show ${VmElement}
105 \ ${output}= Write Commands Until Prompt nova console-log ${VmElement}
108 Ping Vm From DHCP Namespace
109 [Arguments] ${net_id} ${vm_ip}
110 [Documentation] Reach all Vm Instance with the net id of the Netowrk.
112 ${output}= Write Commands Until Prompt sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip} 20s
117 [Arguments] ${dest_vm}
118 [Documentation] Ping to the expected destination ip.
119 ${output}= Write Commands Until Expected Prompt ping -c 3 ${dest_vm} $
124 [Documentation] Ping to the expected destination ip.
125 ${output}= Write Commands Until Expected Prompt curl -i http://169.254.169.254 $
126 Write Commands Until Prompt exit
127 Should Contain ${output} 200
130 [Documentation] Exit the vm instance.
131 ${output}= Write Commands Until Prompt exit
135 [Arguments] ${net_id} ${vm_ip} ${user}=cirros ${password}=cubswin:) ${key_file}=test.pem
136 [Documentation] Login to the vm instance using ssh in the network.
137 ${output}= Write Commands Until Expected Prompt sudo ip netns exec qdhcp-${net_id} ssh -i ${key_file} ${user}@${vm_ip} (yes/no)?
139 ${output}= Write Commands Until Expected Prompt yes d:
141 ${output}= Write Commands Until Expected Prompt ${password} $
143 ${output}= Write Commands Until Expected Prompt ifconfig $
145 ${output}= Write Commands Until Expected Prompt route $
149 [Arguments] ${router_name}
150 [Documentation] Create Router and Add Interface to the subnets.
151 ${output}= Write Commands Until Prompt neutron -v router-create ${router_name}
152 Should Contain ${output} Created a new router
155 [Arguments] ${router_name} ${interface_name}
156 ${output}= Write Commands Until Prompt neutron -v router-interface-add ${router_name} ${interface_name}
157 Should Contain ${output} Added interface
160 [Arguments] ${router_name} ${interface_name}
161 [Documentation] Remove Interface to the subnets.
162 ${output}= Write Commands Until Prompt neutron -v router-interface-delete ${router_name} ${interface_name}
163 Should Contain ${output} Removed interface from router
166 [Arguments] ${router_name}
167 [Documentation] Delete Router and Interface to the subnets.
168 ${output}= Write Commands Until Prompt neutron -v router-delete ${router_name}
169 Should Contain ${output} Deleted router:
172 [Arguments] ${vm_indices}
173 [Documentation] Run these commands for debugging, it can list state of VM instances and ip information in control node
174 ${output}= Write Commands Until Prompt sudo ip netns list
176 : FOR ${index} IN @{vm_indices}
177 \ ${output}= Write Commands Until Prompt nova show ${index}