~narindergupta/opnfv/stable-R2

« back to all changes in this revision

Viewing changes to ci/onos/cloud-sh-onos/openstack.sh

  • Committer: zhangyuanyou
  • Date: 2016-01-02 08:55:55 UTC
  • Revision ID: git-v1:9d5ca8b6a6c9e33a5f8318483ad940eb9918819d
JOID-18 Juju integration with ONOSFW.

Change-Id: Iaffdb78ceb5a4c1a57fce3459289c65d6b6a4f42

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 60
 
39
                done
 
40
        done
 
41
}
 
42
 
 
43
waitForService()
 
44
{
 
45
        for service; do
 
46
                while [ "$(agentStateUnit "$service" 0)" != started ]; do
 
47
                        sleep 60
 
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:-neutron-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
# onos
 
85
juju deploy --to lxc:1 $CHARM_ONOS_CONTROLLER_DEPLOY_OPTS "${CHARM_ONOS_CONTROLLER:-onos-controller}"
 
86
 
 
87
# relation must be set first
 
88
# no official way of knowing when this relation hook will fire
 
89
waitForService mysql keystone
 
90
juju add-relation keystone mysql
 
91
sleep 60
 
92
 
 
93
waitForService rabbitmq-server nova-cloud-controller glance
 
94
juju add-relation nova-cloud-controller mysql
 
95
juju add-relation nova-cloud-controller rabbitmq-server
 
96
juju add-relation nova-cloud-controller glance
 
97
juju add-relation nova-cloud-controller keystone
 
98
sleep 60
 
99
 
 
100
waitForService neutron-api
 
101
juju add-relation neutron-api mysql
 
102
juju add-relation neutron-api rabbitmq-server
 
103
juju add-relation neutron-api keystone
 
104
juju add-relation neutron-api nova-cloud-controller
 
105
sleep 60
 
106
 
 
107
waitForService openstack-dashboard neutron-gateway nova-compute
 
108
juju add-relation neutron-gateway mysql
 
109
juju add-relation neutron-gateway:amqp rabbitmq-server:amqp
 
110
juju add-relation neutron-gateway nova-cloud-controller
 
111
juju add-relation neutron-gateway neutron-api
 
112
juju add-relation nova-compute:shared-db mysql:shared-db
 
113
juju add-relation nova-compute:amqp rabbitmq-server:amqp
 
114
juju add-relation nova-compute glance
 
115
juju add-relation nova-compute nova-cloud-controller
 
116
juju add-relation glance mysql
 
117
juju add-relation glance keystone
 
118
juju add-relation openstack-dashboard keystone
 
119
sleep 60
 
120
 
 
121
# onos
 
122
waitForService onos-controller
 
123
juju add-relation neutron-api onos-controller
 
124
juju add-relation neutron-gateway onos-controller
 
125
juju add-relation nova-compute onos-controller
 
126
sleep 60
 
127
 
 
128
# enable kvm on compute
 
129
machine=$(unitMachine nova-compute 0)
 
130
juju scp compute.sh $machine:
 
131
juju run --machine $machine "sudo ./compute.sh"
 
132
 
 
133
mkdir -m 0700 -p cloud
 
134
controller_address=$(unitAddress keystone 0)
 
135
configOpenrc admin admin Admin http://$controller_address:5000/v2.0 RegionOne > cloud/admin-openrc
 
136
chmod 0600 cloud/admin-openrc
 
137
 
 
138
# keystone need some extra time before it become availble for cloud operations.
 
139
 
 
140
sleep 300
 
141
machine=$(unitMachine nova-cloud-controller 0)
 
142
juju scp cloud-setup.sh cloud/admin-openrc ~/.ssh/id_rsa.pub $machine:
 
143
juju run --machine $machine ./cloud-setup.sh
 
144
 
 
145
machine=$(unitMachine glance 0)
 
146
juju scp glance.sh cloud/admin-openrc $machine:
 
147
juju run --machine $machine ./glance.sh