remove "print" in tempest to avoid having a message "None" in the output
[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 # All rights reserved. This program and the accompanying materials
9 # are made available under the terms of the Apache License, Version 2.0
10 # which accompanies this distribution, and is available at
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13
14 if [ -z $OS_AUTH_URL ]; then
15     echo "Source credentials first"
16     exit 1
17 fi
18
19 echo "Using following credentials:"
20 env | grep OS
21
22 #################################
23 echo "Creating keystone stuff.."
24 #################################
25 keystone tenant-create --name tenant_test1
26 keystone tenant-create --name tenant_test2
27 tenant1_id=$(keystone tenant-list | grep tenant_test1 | awk '{print $2}')
28 tenant2_id=$(keystone tenant-list | grep tenant_test2 | awk '{print $2}')
29 keystone user-create --name user_test11 --tenant $tenant1_id
30 keystone user-create --name user_test12 --tenant $tenant1_id
31 keystone user-create --name user_test13 --tenant $tenant1_id
32 keystone user-create --name user_test21 --tenant $tenant2_id
33 keystone user-create --name user_test22 --tenant $tenant2_id
34
35
36 #################################
37 echo "Creating glance stuff.."
38 #################################
39 wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
40 glance image-create --name image_test1 --disk-format qcow2 --container-format bare < cirros-0.3.4-x86_64-disk.img
41 glance image-create --name image_test2 --disk-format qcow2 --container-format bare < cirros-0.3.4-x86_64-disk.img
42 #glance image-create --name test --visibility public --disk-format qcow2 --container-format bare --file cirros-0.3.4-x86_64-disk.img
43
44
45 #################################
46 echo "Creating cinder stuff.."
47 #################################
48 cinder create --display_name volume-test1 1
49 cinder create --display_name volume-test2 2
50
51
52 #################################
53 echo "Creating NEUTRON stuff.."
54 #################################
55 echo "1. Create Networks."
56 neutron net-create net-test1
57 neutron net-create net-test2
58
59 echo "2. Create subnets."
60 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
61 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
62
63 echo "3. Create Ports."
64 neutron port-create --name port-test11 --fixed-ip ip_address=10.7.0.10 net-test1
65 neutron port-create --name port-test21 --fixed-ip ip_address=10.6.0.60 net-test2
66
67
68 echo "4. Create Routers."
69 neutron router-create router-test1
70 neutron router-create router-test2
71 router1_id=$(neutron router-list | grep router-test1 | awk '{print $2}')
72 router1_id=$(neutron router-list | grep router-test2 | awk '{print $2}')
73
74 neutron router-gateway-set router-test1 net04_ext
75 neutron router-gateway-set router-test2 net04_ext
76
77 neutron router-interface-add router-test1 subnet-test11
78 neutron router-interface-add router-test2 subnet-test21
79
80 echo "5. Floating IPs."
81 neutron floatingip-create net04_ext
82 neutron floatingip-create net04_ext
83 neutron floatingip-create net04_ext
84 neutron floatingip-create net04_ext
85
86 floating_ip1_id=$(neutron floatingip-list | awk 'FNR == 4 {print}' | awk '{print $2}')
87 floating_ip2_id=$(neutron floatingip-list | awk 'FNR == 5 {print}' | awk '{print $2}')
88 floating_ip3_id=$(neutron floatingip-list | awk 'FNR == 6 {print}' | awk '{print $2}')
89 floating_ip4_id=$(neutron floatingip-list | awk 'FNR == 7 {print}' | awk '{print $2}')
90
91 floating_ip1=$(neutron floatingip-list | awk 'FNR == 4 {print}' | awk '{print $5}')
92 floating_ip2=$(neutron floatingip-list | awk 'FNR == 5 {print}' | awk '{print $5}')
93 floating_ip3=$(neutron floatingip-list | awk 'FNR == 6 {print}' | awk '{print $5}')
94 floating_ip4=$(neutron floatingip-list | awk 'FNR == 7 {print}' | awk '{print $5}')
95
96 #################################
97 echo "Creating NOVA stuff.."
98 #################################
99 net1_id=$(neutron net-list | grep net-test1 | awk '{print $2}')
100 net2_id=$(neutron net-list | grep net-test2 | awk '{print $2}')
101
102 nova boot --flavor 2 --image image_test1 --nic net-id=$net1_id nova-test11
103 nova boot --flavor 2 --image image_test1 --nic net-id=$net1_id nova-test12
104 nova boot --flavor 2 --image image_test2 --nic net-id=$net2_id nova-test21
105 nova boot --flavor 2 --image image_test2 --nic net-id=$net2_id nova-test22
106
107 vm1_id=$(nova list | grep nova-test11 | awk '{print $2}')
108 vm2_id=$(nova list | grep nova-test12 | awk '{print $2}')
109 vm3_id=$(nova list | grep nova-test21 | awk '{print $2}')
110 vm4_id=$(nova list | grep nova-test22 | awk '{print $2}')
111
112 nova floating-ip-associate $vm1_id $floating_ip1
113 nova floating-ip-associate $vm2_id $floating_ip2
114 nova floating-ip-associate $vm3_id $floating_ip3
115 nova floating-ip-associate $vm4_id $floating_ip4
116
117 #neutron floatingip-associate  --fixed-ip-address $floating_ip2 <PORT>