Place config_functest.yaml outside the functest repo
[functest.git] / testcases / VIM / OpenStack / CI / libraries / test_openstack.sh
1 #
2 # Script to test clean_openstack.py
3 #
4 # Author:
5 #    jose.lausuch@ericsson.com
6 #
7
8 if [ -z $OS_AUTH_URL ]; then
9     echo "Source credentials first"
10     exit 1
11 fi
12
13 echo "Using following credentials:"
14 env | grep OS
15
16 #################################
17 echo "Creating keystone stuff.."
18 #################################
19 keystone tenant-create --name tenant_test1
20 keystone tenant-create --name tenant_test2
21 tenant1_id=$(keystone tenant-list | grep tenant_test1 | awk '{print $2}')
22 tenant2_id=$(keystone tenant-list | grep tenant_test2 | awk '{print $2}')
23 keystone user-create --name user_test11 --tenant $tenant1_id
24 keystone user-create --name user_test12 --tenant $tenant1_id
25 keystone user-create --name user_test13 --tenant $tenant1_id
26 keystone user-create --name user_test21 --tenant $tenant2_id
27 keystone user-create --name user_test22 --tenant $tenant2_id
28
29
30 #################################
31 echo "Creating glance stuff.."
32 #################################
33 wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
34 glance image-create --name image_test1 --disk-format qcow2 --container-format bare < cirros-0.3.4-x86_64-disk.img
35 glance image-create --name image_test2 --disk-format qcow2 --container-format bare < cirros-0.3.4-x86_64-disk.img
36 #glance image-create --name test --visibility public --disk-format qcow2 --container-format bare --file cirros-0.3.4-x86_64-disk.img
37
38
39 #################################
40 echo "Creating cinder stuff.."
41 #################################
42 cinder create --display_name volume-test1 1
43 cinder create --display_name volume-test2 2
44
45
46 #################################
47 echo "Creating NEUTRON stuff.."
48 #################################
49 echo "1. Create Networks."
50 neutron net-create net-test1
51 neutron net-create net-test2
52
53 echo "2. Create subnets."
54 neutron subnet-create --name subnet-test11 --allocation-pool start=10.7.0.2,end=10.7.0.253 --gateway 10.7.0.254 net-test1 10.7.0.0/24
55 neutron subnet-create --name subnet-test21 --allocation-pool start=10.6.0.2,end=10.6.0.253 --gateway 10.6.0.254 net-test2 10.6.0.0/24
56
57 echo "3. Create Ports."
58 neutron port-create --name port-test11 --fixed-ip ip_address=10.7.0.10 net-test1
59 neutron port-create --name port-test21 --fixed-ip ip_address=10.6.0.60 net-test2
60
61
62 echo "4. Create Routers."
63 neutron router-create router-test1
64 neutron router-create router-test2
65 router1_id=$(neutron router-list | grep router-test1 | awk '{print $2}')
66 router1_id=$(neutron router-list | grep router-test2 | awk '{print $2}')
67
68 neutron router-gateway-set router-test1 net04_ext
69 neutron router-gateway-set router-test2 net04_ext
70
71 neutron router-interface-add router-test1 subnet-test11
72 neutron router-interface-add router-test2 subnet-test21
73
74 echo "5. Floating IPs."
75 neutron floatingip-create net04_ext
76 neutron floatingip-create net04_ext
77 neutron floatingip-create net04_ext
78 neutron floatingip-create net04_ext
79
80 floating_ip1_id=$(neutron floatingip-list | awk 'FNR == 4 {print}' | awk '{print $2}')
81 floating_ip2_id=$(neutron floatingip-list | awk 'FNR == 5 {print}' | awk '{print $2}')
82 floating_ip3_id=$(neutron floatingip-list | awk 'FNR == 6 {print}' | awk '{print $2}')
83 floating_ip4_id=$(neutron floatingip-list | awk 'FNR == 7 {print}' | awk '{print $2}')
84
85 floating_ip1=$(neutron floatingip-list | awk 'FNR == 4 {print}' | awk '{print $5}')
86 floating_ip2=$(neutron floatingip-list | awk 'FNR == 5 {print}' | awk '{print $5}')
87 floating_ip3=$(neutron floatingip-list | awk 'FNR == 6 {print}' | awk '{print $5}')
88 floating_ip4=$(neutron floatingip-list | awk 'FNR == 7 {print}' | awk '{print $5}')
89
90 #################################
91 echo "Creating NOVA stuff.."
92 #################################
93 net1_id=$(neutron net-list | grep net-test1 | awk '{print $2}')
94 net2_id=$(neutron net-list | grep net-test2 | awk '{print $2}')
95
96 nova boot --flavor 2 --image image_test1 --nic net-id=$net1_id nova-test11
97 nova boot --flavor 2 --image image_test1 --nic net-id=$net1_id nova-test12
98 nova boot --flavor 2 --image image_test2 --nic net-id=$net2_id nova-test21
99 nova boot --flavor 2 --image image_test2 --nic net-id=$net2_id nova-test22
100
101 vm1_id=$(nova list | grep nova-test11 | awk '{print $2}')
102 vm2_id=$(nova list | grep nova-test12 | awk '{print $2}')
103 vm3_id=$(nova list | grep nova-test21 | awk '{print $2}')
104 vm4_id=$(nova list | grep nova-test22 | awk '{print $2}')
105
106 nova floating-ip-associate $vm1_id $floating_ip1
107 nova floating-ip-associate $vm2_id $floating_ip2
108 nova floating-ip-associate $vm3_id $floating_ip3
109 nova floating-ip-associate $vm4_id $floating_ip4
110
111 #neutron floatingip-associate  --fixed-ip-address $floating_ip2 <PORT>