summaryrefslogtreecommitdiffstats
path: root/testcases/VIM/OpenStack/CI/libraries/test_openstack.sh
blob: fa1f0fa04a4c5718793c72ad7a0ee15655a132f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight 
#
# Script to test clean_openstack.py
#
# Author:
#    jose.lausuch@ericsson.com
#
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#

if [ -z $OS_AUTH_URL ]; then
    echo "Source credentials first"
    exit 1
fi

echo "Using following credentials:"
env | grep OS

#################################
echo "Creating keystone stuff.."
#################################
keystone tenant-create --name tenant_test1
keystone tenant-create --name tenant_test2
tenant1_id=$(keystone tenant-list | grep tenant_test1 | awk '{print $2}')
tenant2_id=$(keystone tenant-list | grep tenant_test2 | awk '{print $2}')
keystone user-create --name user_test11 --tenant $tenant1_id
keystone user-create --name user_test12 --tenant $tenant1_id
keystone user-create --name user_test13 --tenant $tenant1_id
keystone user-create --name user_test21 --tenant $tenant2_id
keystone user-create --name user_test22 --tenant $tenant2_id


#################################
echo "Creating glance stuff.."
#################################
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
glance image-create --name image_test1 --disk-format qcow2 --container-format bare < cirros-0.3.4-x86_64-disk.img
glance image-create --name image_test2 --disk-format qcow2 --container-format bare < cirros-0.3.4-x86_64-disk.img
#glance image-create --name test --visibility public --disk-format qcow2 --container-format bare --file cirros-0.3.4-x86_64-disk.img


#################################
echo "Creating cinder stuff.."
#################################
cinder create --display_name volume-test1 1
cinder create --display_name volume-test2 2


#################################
echo "Creating NEUTRON stuff.."
#################################
echo "1. Create Networks."
neutron net-create net-test1
neutron net-create net-test2

echo "2. Create subnets."
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
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

echo "3. Create Ports."
neutron port-create --name port-test11 --fixed-ip ip_address=10.7.0.10 net-test1
neutron port-create --name port-test21 --fixed-ip ip_address=10.6.0.60 net-test2


echo "4. Create Routers."
neutron router-create router-test1
neutron router-create router-test2
router1_id=$(neutron router-list | grep router-test1 | awk '{print $2}')
router1_id=$(neutron router-list | grep router-test2 | awk '{print $2}')

neutron router-gateway-set router-test1 net04_ext
neutron router-gateway-set router-test2 net04_ext

neutron router-interface-add router-test1 subnet-test11
neutron router-interface-add router-test2 subnet-test21

echo "5. Floating IPs."
neutron floatingip-create net04_ext
neutron floatingip-create net04_ext
neutron floatingip-create net04_ext
neutron floatingip-create net04_ext

floating_ip1_id=$(neutron floatingip-list | awk 'FNR == 4 {print}' | awk '{print $2}')
floating_ip2_id=$(neutron floatingip-list | awk 'FNR == 5 {print}' | awk '{print $2}')
floating_ip3_id=$(neutron floatingip-list | awk 'FNR == 6 {print}' | awk '{print $2}')
floating_ip4_id=$(neutron floatingip-list | awk 'FNR == 7 {print}' | awk '{print $2}')

floating_ip1=$(neutron floatingip-list | awk 'FNR == 4 {print}' | awk '{print $5}')
floating_ip2=$(neutron floatingip-list | awk 'FNR == 5 {print}' | awk '{print $5}')
floating_ip3=$(neutron floatingip-list | awk 'FNR == 6 {print}' | awk '{print $5}')
floating_ip4=$(neutron floatingip-list | awk 'FNR == 7 {print}' | awk '{print $5}')

#################################
echo "Creating NOVA stuff.."
#################################
net1_id=$(neutron net-list | grep net-test1 | awk '{print $2}')
net2_id=$(neutron net-list | grep net-test2 | awk '{print $2}')

nova boot --flavor 2 --image image_test1 --nic net-id=$net1_id nova-test11
nova boot --flavor 2 --image image_test1 --nic net-id=$net1_id nova-test12
nova boot --flavor 2 --image image_test2 --nic net-id=$net2_id nova-test21
nova boot --flavor 2 --image image_test2 --nic net-id=$net2_id nova-test22

vm1_id=$(nova list | grep nova-test11 | awk '{print $2}')
vm2_id=$(nova list | grep nova-test12 | awk '{print $2}')
vm3_id=$(nova list | grep nova-test21 | awk '{print $2}')
vm4_id=$(nova list | grep nova-test22 | awk '{print $2}')

nova floating-ip-associate $vm1_id $floating_ip1
nova floating-ip-associate $vm2_id $floating_ip2
nova floating-ip-associate $vm3_id $floating_ip3
nova floating-ip-associate $vm4_id $floating_ip4

#neutron floatingip-associate  --fixed-ip-address $floating_ip2 <PORT>