~narindergupta/opnfv/stable-R2

« back to all changes in this revision

Viewing changes to ci/nosdn/cloud-sh-odl/openstack.sh

  • Committer: Narinder Gupta
  • Date: 2015-12-05 01:38:59 UTC
  • Revision ID: git-v1:6c7fc201c56648de9622dffc48a3f47e81de9465
modified to comment the use of juju-br0 as external network.
Added option to install neutron-openswitch without ODL.
consolidated source files to common as all sdn share the s
same source for openstack and it can be modified during deployment.

Change-Id: I1df7f5cd5d928d170bc6be6b32c3404dbcb5fda3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -ex
 
2
 
 
3
agentState()
 
4
{
 
5
        juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"machines\"][\"$1\"][\"agent-state\"]" 2> /dev/null
 
6
}
 
7
 
 
8
agentStateUnit()
 
9
{
 
10
        juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"agent-state\"]" 2> /dev/null
 
11
}
 
12
 
 
13
configOpenrc()
 
14
{
 
15
        cat <<-EOF
 
16
                export OS_USERNAME=$1
 
17
                export OS_PASSWORD=$2
 
18
                export OS_TENANT_NAME=$3
 
19
                export OS_AUTH_URL=$4
 
20
                export OS_REGION_NAME=$5
 
21
                EOF
 
22
}
 
23
 
 
24
unitAddress()
 
25
{
 
26
        juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
 
27
}
 
28
 
 
29
unitMachine()
 
30
{
 
31
        juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
 
32
}
 
33
 
 
34
waitForMachine()
 
35
{
 
36
        for machine; do
 
37
                while [ "$(agentState $machine)" != started ]; do
 
38
                        sleep 5
 
39
                done
 
40
        done
 
41
}
 
42
 
 
43
waitForService()
 
44
{
 
45
        for service; do
 
46
                while [ "$(agentStateUnit "$service" 0)" != started ]; do
 
47
                        sleep 5
 
48
                done
 
49
        done
 
50
}
 
51
 
 
52
if [ $# -ne 0 ]; then
 
53
        . "$1"
 
54
fi
 
55
 
 
56
juju bootstrap
 
57
waitForMachine 0
 
58
 
 
59
spare_cpus=$(($(grep processor /proc/cpuinfo | wc -l) - 5))
 
60
if [ $spare_cpus -gt 0 ]; then
 
61
        spare_cpus=$(((spare_cpus * 3) / 4))
 
62
else
 
63
        spare_cpus=0
 
64
fi
 
65
 
 
66
extra_cpus=0
 
67
[ $spare_cpus -ne 0 ] && extra_cpus=$((1 + (((spare_cpus - 1) * 3) / 4))) && spare_cpus=$((spare_cpus - extra_cpus))
 
68
juju add-machine --constraints "cpu-cores=$((1 + extra_cpus)) mem=8G root-disk=20G" --series $DEFAULT_SERIES
 
69
 
 
70
juju deploy --constraints mem=1G $CHARM_NEUTRON_GATEWAY_DEPLOY_OPTS "${CHARM_NEUTRON_GATEWAY:-quantum-gateway}" neutron-gateway
 
71
 
 
72
juju deploy --constraints "cpu-cores=$((1 + spare_cpus)) mem=4G root-disk=20G" $CHARM_NOVA_COMPUTE_DEPLOY_OPTS "${CHARM_NOVA_COMPUTE:-nova-compute}"
 
73
 
 
74
waitForMachine 1
 
75
juju scp lxc-network.sh 1:
 
76
juju run --machine 1 "sudo ./lxc-network.sh"
 
77
juju deploy --to lxc:1 $CHARM_MYSQL_DEPLOY_OPTS "${CHARM_MYSQL:-mysql}"
 
78
juju deploy --to lxc:1 $CHARM_RABBITMQ_SERVER_DEPLOY_OPTS "${CHARM_RABBITMQ_SERVER:-rabbitmq-server}"
 
79
juju deploy --to lxc:1 $CHARM_KEYSTONE_DEPLOY_OPTS "${CHARM_KEYSTONE:-keystone}"
 
80
juju deploy --to lxc:1 $CHARM_NOVA_CLOUD_CONTROLLER_DEPLOY_OPTS "${CHARM_NOVA_CLOUD_CONTROLLER:-nova-cloud-controller}"
 
81
juju deploy --to lxc:1 $CHARM_NEUTRON_API_DEPLOY_OPTS "${CHARM_NEUTRON_API:-neutron-api}"
 
82
juju deploy --to lxc:1 $CHARM_GLANCE_DEPLOY_OPTS "${CHARM_GLANCE:-glance}"
 
83
juju deploy --to lxc:1 $CHARM_OPENSTACK_DASHBOARD_DEPLOY_OPTS "${CHARM_OPENSTACK_DASHBOARD:-openstack-dashboard}"
 
84
# opendaylight
 
85
juju deploy --to lxc:1 $CHARM_ODL_CONTROLLER_DEPLOY_OPTS "${CHARM_ODL_CONTROLLER:-odl-controller}"
 
86
juju deploy $CHARM_NEUTRON_ODL_DEPLOY_OPTS "${CHARM_NEUTRON_ODL:-neutron-odl}"
 
87
 
 
88
# relation must be set first
 
89
# no official way of knowing when this relation hook will fire
 
90
waitForService mysql keystone
 
91
juju add-relation keystone mysql
 
92
sleep 60
 
93
 
 
94
waitForService rabbitmq-server nova-cloud-controller glance
 
95
juju add-relation nova-cloud-controller mysql
 
96
juju add-relation nova-cloud-controller rabbitmq-server
 
97
juju add-relation nova-cloud-controller glance
 
98
juju add-relation nova-cloud-controller keystone
 
99
sleep 60
 
100
 
 
101
waitForService neutron-api
 
102
juju add-relation neutron-api mysql
 
103
juju add-relation neutron-api rabbitmq-server
 
104
juju add-relation neutron-api keystone
 
105
juju add-relation neutron-api nova-cloud-controller
 
106
sleep 60
 
107
 
 
108
waitForService openstack-dashboard neutron-gateway nova-compute
 
109
juju add-relation neutron-gateway mysql
 
110
juju add-relation neutron-gateway:amqp rabbitmq-server:amqp
 
111
juju add-relation neutron-gateway nova-cloud-controller
 
112
juju add-relation neutron-gateway neutron-api
 
113
juju add-relation nova-compute:shared-db mysql:shared-db
 
114
juju add-relation nova-compute:amqp rabbitmq-server:amqp
 
115
juju add-relation nova-compute glance
 
116
juju add-relation nova-compute nova-cloud-controller
 
117
juju add-relation glance mysql
 
118
juju add-relation glance keystone
 
119
juju add-relation openstack-dashboard keystone
 
120
sleep 60
 
121
 
 
122
# opendaylight
 
123
waitForService odl-controller
 
124
juju add-relation neutron-api odl-controller
 
125
juju add-relation neutron-gateway odl-controller
 
126
juju add-relation nova-compute neutron-odl
 
127
juju add-relation neutron-odl odl-controller
 
128
sleep 60
 
129
 
 
130
# enable kvm on compute
 
131
machine=$(unitMachine nova-compute 0)
 
132
juju scp compute.sh $machine:
 
133
juju run --machine $machine "sudo ./compute.sh"
 
134
 
 
135
mkdir -m 0700 -p cloud
 
136
controller_address=$(unitAddress keystone 0)
 
137
configOpenrc admin password Admin http://$controller_address:5000/v2.0 RegionOne > cloud/admin-openrc
 
138
chmod 0600 cloud/admin-openrc
 
139
 
 
140
machine=$(unitMachine nova-cloud-controller 0)
 
141
juju scp cloud-setup.sh cloud/admin-openrc ~/.ssh/id_rsa.pub $machine:
 
142
juju run --machine $machine ./cloud-setup.sh
 
143
 
 
144
machine=$(unitMachine glance 0)
 
145
juju scp glance.sh cloud/admin-openrc $machine:
 
146
juju run --machine $machine ./glance.sh