3 ##############################################################################
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 #./openstack.sh "$opnfvsdn" "$opnfvdistro" "$openstack"
16 if [ -f ./deployconfig.yaml ];then
17 EXTERNAL_NETWORK=`grep floating-ip-range deployconfig.yaml | cut -d ' ' -f 4 `
19 # split EXTERNAL_NETWORK=first ip;last ip; gateway;network
21 EXTNET=(${EXTERNAL_NETWORK//,/ })
23 EXTNET_FIP=${EXTNET[0]}
24 EXTNET_LIP=${EXTNET[1]}
25 EXTNET_GW=${EXTNET[2]}
26 EXTNET_NET=${EXTNET[3]}
27 EXTNET_PORT=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
28 ADMNET_GW=`grep "admNetgway" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
29 API_FQDN=`grep "os-domain-name" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
32 # launch eth on computer nodes and remove default gw route
34 computer_list=$(juju status --format short | grep -Eo 'nova-compute/[0-9]')
35 for node in $computer_list; do
36 echo "node name is ${node}"
37 juju ssh $node "sudo ifconfig $EXTNET_PORT up"
38 #juju ssh $node "sudo route del default gw $ADMNET_GW"
42 # Update gateway mac to onos for l3 function
45 EXTNET_GW_MAC=$(juju ssh nova-compute/0 "arp -a ${EXTNET_GW} | grep -Eo '([0-9a-fA-F]{2})(([/\s:-][0-9a-fA-F]{2}){5})'")
46 ## set external gateway mac in onos
47 juju set onos-controller gateway-mac=$EXTNET_GW_MAC
51 juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
55 juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
59 KEYSTONE=$(juju status keystone |grep public-address|sed -- 's/.*\: //')
60 if [ $(echo $KEYSTONE|wc -w) == 1 ];then
63 juju get keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']"
67 # create external network and subnet in openstack
69 mkdir -m 0700 -p cloud
70 keystoneIp=$(keystoneIp)
71 adminPasswd=$(juju get keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
72 configOpenrc admin $adminPasswd admin http://$keystoneIp:5000/v2.0 RegionOne > cloud/admin-openrc
73 chmod 0600 cloud/admin-openrc
77 if [ "$API_FQDN" != "None" ]; then
81 export OS_TENANT_NAME=$3
83 export OS_REGION_NAME=$5
84 export OS_ENDPOINT_TYPE='internalURL'
85 export CINDER_ENDPOINT_TYPE='internalURL'
86 export GLANCE_ENDPOINT_TYPE='internalURL'
87 export KEYSTONE_ENDPOINT_TYPE='internalURL'
88 export NEUTRON_ENDPOINT_TYPE='internalURL'
89 export NOVA_ENDPOINT_TYPE='internalURL'
95 export OS_TENANT_NAME=$3
97 export OS_REGION_NAME=$5
103 if [ "$API_FQDN" != "None" ]; then
104 # Push api fqdn local ip to all /etc/hosts
105 API_FQDN=$(juju get keystone | python -c "import yaml; import sys;\
106 print yaml.load(sys.stdin)['settings']['os-public-hostname']['value']")
108 KEYSTONEIP=$(keystoneIp)
109 juju run --all "if grep $API_FQDN /etc/hosts > /dev/null; then \
110 echo 'API FQDN already present'; \
112 sudo sh -c 'echo $KEYSTONEIP $API_FQDN >> /etc/hosts'; \
113 echo 'API FQDN injected'; \
116 #change in jumphost as well as below commands will run on jumphost
118 if grep $API_FQDN /etc/hosts; then
119 echo 'API FQDN already present'
121 sudo sh -c "echo $KEYSTONEIP $API_FQDN >> /etc/hosts"
122 echo 'API FQDN injected'
126 # Create an load openrc
129 . ./cloud/admin-openrc
131 echo "...... deploy public api proxy ......"
133 if [ "$opnfvlab" == "orangepod1" ] && [ "$opnfvsdn" == "nosdn" ]; then # only for first test phase
134 if [ -e ./labconfig.yaml ]; then
135 PUB_API_NET=$(grep floating-ip-range ./labconfig.yaml |cut -d/ -f2)
136 PUB_API_IP=$(grep public-api-ip ./labconfig.yaml |cut -d: -f2)
137 juju run --unit nodes/0 "sudo ip a a ${PUB_API_IP}/${PUB_API_NET} dev br-ex" || true
138 juju run --unit nodes/0 "sudo ip l set dev br-ex up" || true
139 python genPublicAPIProxyBundle.py -l labconfig.yaml >> bundles.yaml
140 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$opnfvos" || true
144 echo "...... deploy end public api proxy ......"
147 ## removing the swift API endpoint which is created by radosgw.
148 ## one option is not to used radosgw and other one is remove endpoint.
151 #echo "Removing swift endpoint and service"
152 #swift_service_id=$(openstack service list | grep swift | cut -d ' ' -f 2)
153 #swift_endpoint_id=$(openstack endpoint list | grep swift | cut -d ' ' -f 2)
154 #openstack endpoint delete $swift_endpoint_id
155 #openstack service delete $swift_service_id
158 ## Create external subnet Network
161 if [ "onos" == "$opnfvsdn" ]; then
163 neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net --router:external=True
164 neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
165 --name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
166 --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
167 #neutron subnet-create ext-net --name ext-subnet $EXTNET_NET
169 elif [ "nosdn" == "$opnfvsdn" ]; then
170 neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
171 --router:external=True \
172 --provider:network_type flat \
173 --provider:physical_network external
175 neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
176 --name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
177 --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
179 neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net --router:external=True
180 neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
181 --name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
182 --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
186 # Create Congress datasources
187 sudo apt-get install -y python-congressclient
189 openstack congress datasource create nova "nova" \
190 --config username=$OS_USERNAME \
191 --config tenant_name=$OS_TENANT_NAME \
192 --config password=$OS_PASSWORD \
193 --config auth_url=http://$keystoneIp:5000/v2.0
194 openstack congress datasource create neutronv2 "neutronv2" \
195 --config username=$OS_USERNAME \
196 --config tenant_name=$OS_TENANT_NAME \
197 --config password=$OS_PASSWORD \
198 --config auth_url=http://$keystoneIp:5000/v2.0
199 openstack congress datasource create ceilometer "ceilometer" \
200 --config username=$OS_USERNAME \
201 --config tenant_name=$OS_TENANT_NAME \
202 --config password=$OS_PASSWORD \
203 --config auth_url=http://$keystoneIp:5000/v2.0
204 openstack congress datasource create cinder "cinder" \
205 --config username=$OS_USERNAME \
206 --config tenant_name=$OS_TENANT_NAME \
207 --config password=$OS_PASSWORD \
208 --config auth_url=http://$keystoneIp:5000/v2.0
209 openstack congress datasource create glancev2 "glancev2" \
210 --config username=$OS_USERNAME \
211 --config tenant_name=$OS_TENANT_NAME \
212 --config password=$OS_PASSWORD \
213 --config auth_url=http://$keystoneIp:5000/v2.0
214 openstack congress datasource create keystone "keystone" \
215 --config username=$OS_USERNAME \
216 --config tenant_name=$OS_TENANT_NAME \
217 --config password=$OS_PASSWORD \
218 --config auth_url=http://$keystoneIp:5000/v2.0