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" "$opnfvlab" "$opnfvdistro" "$openstack" || true
17 if [ -f ./deployconfig.yaml ];then
18 EXTERNAL_NETWORK=`grep floating-ip-range deployconfig.yaml | cut -d ' ' -f 4 `
20 # split EXTERNAL_NETWORK=first ip;last ip; gateway;network
22 EXTNET=(${EXTERNAL_NETWORK//,/ })
24 EXTNET_FIP=${EXTNET[0]}
25 EXTNET_LIP=${EXTNET[1]}
26 EXTNET_GW=${EXTNET[2]}
27 EXTNET_NET=${EXTNET[3]}
28 EXTNET_PORT=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
29 ADMNET_GW=`grep "admNetgway" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
30 API_FQDN=`grep "os-domain-name" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
33 # launch eth on computer nodes and remove default gw route
35 computer_list=$(juju status --format short | grep -Eo 'nova-compute/[0-9]')
36 for node in $computer_list; do
37 echo "node name is ${node}"
38 juju ssh $node "sudo ifconfig $EXTNET_PORT up"
39 #juju ssh $node "sudo route del default gw $ADMNET_GW"
43 # Update gateway mac to onos for l3 function
46 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})'")
47 ## set external gateway mac in onos
48 juju set onos-controller gateway-mac=$EXTNET_GW_MAC
52 juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
56 juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
60 KEYSTONE=$(juju status keystone |grep public-address|sed -- 's/.*\: //')
61 if [ $(echo $KEYSTONE|wc -w) == 1 ];then
64 juju get keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']"
68 # create external network and subnet in openstack
70 mkdir -m 0700 -p cloud
71 keystoneIp=$(keystoneIp)
72 adminPasswd=$(juju get keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
73 configOpenrc admin $adminPasswd admin http://$keystoneIp:5000/v2.0 RegionOne > cloud/admin-openrc
74 chmod 0600 cloud/admin-openrc
78 if [ "$API_FQDN" != "None" ]; then
82 export OS_TENANT_NAME=$3
84 export OS_REGION_NAME=$5
85 export OS_ENDPOINT_TYPE='internalURL'
86 export CINDER_ENDPOINT_TYPE='internalURL'
87 export GLANCE_ENDPOINT_TYPE='internalURL'
88 export KEYSTONE_ENDPOINT_TYPE='internalURL'
89 export NEUTRON_ENDPOINT_TYPE='internalURL'
90 export NOVA_ENDPOINT_TYPE='internalURL'
96 export OS_TENANT_NAME=$3
98 export OS_REGION_NAME=$5
104 if [ "$API_FQDN" != "None" ]; then
105 # Push api fqdn local ip to all /etc/hosts
106 API_FQDN=$(juju get keystone | python -c "import yaml; import sys;\
107 print yaml.load(sys.stdin)['settings']['os-public-hostname']['value']")
109 KEYSTONEIP=$(keystoneIp)
110 juju run --all "if grep $API_FQDN /etc/hosts > /dev/null; then \
111 echo 'API FQDN already present'; \
113 sudo sh -c 'echo $KEYSTONEIP $API_FQDN >> /etc/hosts'; \
114 echo 'API FQDN injected'; \
117 #change in jumphost as well as below commands will run on jumphost
119 if grep $API_FQDN /etc/hosts; then
120 echo 'API FQDN already present'
122 sudo sh -c "echo $KEYSTONEIP $API_FQDN >> /etc/hosts"
123 echo 'API FQDN injected'
127 # Create an load openrc
130 . ./cloud/admin-openrc
132 echo "...... deploy public api proxy ......"
134 if [ "$opnfvlab" == "orangepod1" ] && [ "$opnfvsdn" == "nosdn" ]; then # only for first test phase
135 if [ -e ./labconfig.yaml ]; then
136 PUB_API_NET=$(grep floating-ip-range ./labconfig.yaml |cut -d/ -f2)
137 PUB_API_IP=$(grep public-api-ip ./labconfig.yaml |cut -d: -f2)
138 juju run --unit nodes/0 "sudo ip a a ${PUB_API_IP}/${PUB_API_NET} dev br-ex" || true
139 juju run --unit nodes/0 "sudo ip l set dev br-ex up" || true
140 python genPublicAPIProxyBundle.py -l labconfig.yaml >> bundles.yaml
141 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$opnfvos" || true
145 echo "...... deploy end public api proxy ......"
148 ## removing the swift API endpoint which is created by radosgw.
149 ## one option is not to used radosgw and other one is remove endpoint.
152 #echo "Removing swift endpoint and service"
153 #swift_service_id=$(openstack service list | grep swift | cut -d ' ' -f 2)
154 #swift_endpoint_id=$(openstack endpoint list | grep swift | cut -d ' ' -f 2)
155 #openstack endpoint delete $swift_endpoint_id
156 #openstack service delete $swift_service_id
159 ## Create external subnet Network
162 if [ "onos" == "$opnfvsdn" ]; then
164 neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net --router:external=True
165 neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
166 --name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
167 --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
168 #neutron subnet-create ext-net --name ext-subnet $EXTNET_NET
170 elif [ "nosdn" == "$opnfvsdn" ]; then
171 neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
172 --router:external=True \
173 --provider:network_type flat \
174 --provider:physical_network external
176 neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
177 --name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
178 --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
180 neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net --router:external=True
181 neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
182 --name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
183 --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
187 # Create Congress datasources
188 sudo apt-get install -y python-congressclient
190 openstack congress datasource create nova "nova" \
191 --config username=$OS_USERNAME \
192 --config tenant_name=$OS_TENANT_NAME \
193 --config password=$OS_PASSWORD \
194 --config auth_url=http://$keystoneIp:5000/v2.0
195 openstack congress datasource create neutronv2 "neutronv2" \
196 --config username=$OS_USERNAME \
197 --config tenant_name=$OS_TENANT_NAME \
198 --config password=$OS_PASSWORD \
199 --config auth_url=http://$keystoneIp:5000/v2.0
200 openstack congress datasource create ceilometer "ceilometer" \
201 --config username=$OS_USERNAME \
202 --config tenant_name=$OS_TENANT_NAME \
203 --config password=$OS_PASSWORD \
204 --config auth_url=http://$keystoneIp:5000/v2.0
205 openstack congress datasource create cinder "cinder" \
206 --config username=$OS_USERNAME \
207 --config tenant_name=$OS_TENANT_NAME \
208 --config password=$OS_PASSWORD \
209 --config auth_url=http://$keystoneIp:5000/v2.0
210 openstack congress datasource create glancev2 "glancev2" \
211 --config username=$OS_USERNAME \
212 --config tenant_name=$OS_TENANT_NAME \
213 --config password=$OS_PASSWORD \
214 --config auth_url=http://$keystoneIp:5000/v2.0
215 openstack congress datasource create keystone "keystone" \
216 --config username=$OS_USERNAME \
217 --config tenant_name=$OS_TENANT_NAME \
218 --config password=$OS_PASSWORD \
219 --config auth_url=http://$keystoneIp:5000/v2.0