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 jujuver=`juju --version`
19 if [ -f ./deployconfig.yaml ];then
20 EXTERNAL_NETWORK=`grep floating-ip-range deployconfig.yaml | cut -d ' ' -f 4 `
22 # split EXTERNAL_NETWORK=first ip;last ip; gateway;network
24 EXTNET=(${EXTERNAL_NETWORK//,/ })
26 EXTNET_FIP=${EXTNET[0]}
27 EXTNET_LIP=${EXTNET[1]}
28 EXTNET_GW=${EXTNET[2]}
29 EXTNET_NET=${EXTNET[3]}
30 EXTNET_PORT=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
31 ADMNET_GW=`grep "admNetgway" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
32 API_FQDN=`grep "os-domain-name" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
35 # launch eth on computer nodes and remove default gw route
37 computer_list=$(juju status --format short | grep -Eo 'nova-compute/[0-9]')
38 for node in $computer_list; do
39 echo "node name is ${node}"
40 juju ssh $node "sudo ifconfig $EXTNET_PORT up"
41 #juju ssh $node "sudo route del default gw $ADMNET_GW"
45 # Update gateway mac to onos for l3 function
48 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})'")
49 ## set external gateway mac in onos
50 if [[ "$jujuver" < "2" ]]; then
51 juju set onos-controller gateway-mac=$EXTNET_GW_MAC
53 juju config onos-controller gateway-mac=$EXTNET_GW_MAC
58 if [[ "$jujuver" < "2" ]]; then
59 juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
61 juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"applications\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
66 if [[ "$jujuver" < "2" ]]; then
67 juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
69 juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"applications\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
74 if [ $(juju status keystone --format=short | grep " keystone"|wc -l) == 1 ];then
75 unitAddress keystone 0
77 if [[ "$jujuver" < "2" ]]; then
78 juju get keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']" | cut -d " " -f 1
80 juju config keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']" | cut -d " " -f 1
85 # create external network and subnet in openstack
87 mkdir -m 0700 -p cloud
88 keystoneIp=$(keystoneIp)
89 if [[ "$jujuver" < "2" ]]; then
90 adminPasswd=$(juju get keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
92 adminPasswd=$(juju config keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
95 configOpenrc admin $adminPasswd admin http://$keystoneIp:5000/v2.0 RegionOne > ~/joid_config/admin-openrc
96 chmod 0600 ~/joid_config/admin-openrc
100 if [ "$API_FQDN" != "None" ]; then
102 export SERVICE_ENDPOINT=$4
104 unset SERVICE_ENDPOINT
105 export OS_USERNAME=$1
106 export OS_PASSWORD=$2
107 export OS_TENANT_NAME=$3
108 export OS_AUTH_URL=$4
109 export OS_REGION_NAME=$5
110 export OS_ENDPOINT_TYPE='internalURL'
111 export CINDER_ENDPOINT_TYPE='internalURL'
112 export GLANCE_ENDPOINT_TYPE='internalURL'
113 export KEYSTONE_ENDPOINT_TYPE='internalURL'
114 export NEUTRON_ENDPOINT_TYPE='internalURL'
115 export NOVA_ENDPOINT_TYPE='internalURL'
119 export SERVICE_ENDPOINT=$4
121 unset SERVICE_ENDPOINT
122 export OS_USERNAME=$1
123 export OS_PASSWORD=$2
124 export OS_TENANT_NAME=$3
125 export OS_AUTH_URL=$4
126 export OS_REGION_NAME=$5
132 if [ "$API_FQDN" != "None" ]; then
133 # Push api fqdn local ip to all /etc/hosts
134 if [[ "$jujuver" < "2" ]]; then
135 API_FQDN=$(juju get keystone | python -c "import yaml; import sys;\
136 print yaml.load(sys.stdin)['settings']['os-public-hostname']['value']")
138 API_FQDN=$(juju config keystone | python -c "import yaml; import sys;\
139 print yaml.load(sys.stdin)['settings']['os-public-hostname']['value']")
143 KEYSTONEIP=$(keystoneIp)
144 juju run --all "if grep $API_FQDN /etc/hosts > /dev/null; then \
145 echo 'API FQDN already present'; \
147 sudo sh -c 'echo $KEYSTONEIP $API_FQDN >> /etc/hosts'; \
148 echo 'API FQDN injected'; \
151 # remove this enhancement for heat that does not manage endpoints
152 juju run --service=heat "cp /etc/hosts /tmp/hosts ; \
153 grep -v $API_FQDN /tmp/hosts > /etc/hosts"
155 #change in jumphost as well as below commands will run on jumphost
156 if grep $API_FQDN /etc/hosts; then
157 echo 'API FQDN already present'
159 sudo sh -c "echo $KEYSTONEIP $API_FQDN >> /etc/hosts"
160 echo 'API FQDN injected'
164 # Create an load openrc
167 . ~/joid_config/admin-openrc
169 echo "...... deploy public api proxy ......"
171 if ([ "$opnfvlab" == "orangepod1" ] \
172 || [ "$opnfvlab" == "intelpod6" ]) \
173 && [ "$opnfvsdn" == "nosdn" ] \
174 && [ "$API_FQDN" != "None" ]; then # only for first test phase
175 if [ -e ./labconfig.yaml ]; then
176 PUB_API_MASK=$(grep floating-ip-range ./labconfig.yaml |cut -d/ -f2)
177 PUB_API_NET=$(grep floating-ip-range ./labconfig.yaml |cut -d, -f4)
178 PUB_API_IP=$(grep public-api-ip ./labconfig.yaml |cut -d: -f2)
179 if grep "- type: public" ./labconfig.yaml; then
180 # The public network exists on MAAS, so we push the dns record to it
182 # Recover maas ips and login to it
183 maas_ip=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //')
184 maas_pubip=$(grep floating-ip-range ./labconfig.yaml |cut -d, -f4 |perl -pe 's!^(.*)\.\d+/\d+$!$1.5!')
185 apikey=$(grep maas-oauth: environments.yaml | cut -d "'" -f 2)
186 maas login maas http://${maas_ip}/MAAS/api/1.0 ${apikey}
188 # Configure maas to add the record
189 CLUSTER_UUID=$(maas ubuntu node-groups list | grep uuid | cut -d\" -f4)
190 PUBLIC_MAAS_IF=$(maas ubuntu node-group-interfaces list $cluster_uuid |\
191 python -c "import yaml; import sys; cfg=yaml.load(sys.stdin); net_h={net['ip']:net['name'] for net in cfg}; print(net_h['$maas_pubip'])")
192 maas maas node-group-interface update ${CLUSTER_UUID} ${PUBLIC_MAAS_IF} static_ip_range_high=${PUB_API_IP} static_ip_range_low=${PUB_API_IP}
193 maas maas ipaddresses reserve network=${PUB_API_NET} requested_address=${PUB_API_IP} hostname=${API_FQDN}
194 dig ${PUB_API_IP} @${maas_ip} # just for log
196 juju run --unit nodes/0 "sudo ip a a ${PUB_API_IP}/${PUB_API_MASK} dev br-ex" || true
197 juju run --unit nodes/0 "sudo ip l set dev br-ex up" || true
198 python genPublicAPIProxyBundle.py -l labconfig.yaml >> bundles.yaml
199 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$opnfvos" || true
203 echo "...... deploy end public api proxy ......"
206 ## removing the swift API endpoint which is created by radosgw.
207 ## one option is not to used radosgw and other one is remove endpoint.
210 #echo "Removing swift endpoint and service"
211 #swift_service_id=$(openstack service list | grep swift | cut -d ' ' -f 2)
212 #swift_endpoint_id=$(openstack endpoint list | grep swift | cut -d ' ' -f 2)
213 #openstack endpoint delete $swift_endpoint_id
214 #openstack service delete $swift_service_id
217 ## Create external subnet Network
220 if [ "onos" == "$opnfvsdn" ]; then
222 neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
223 --router:external=True
225 neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
226 --router:external=True \
227 --provider:network_type flat \
228 --provider:physical_network physnet1
231 neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
232 --name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
233 --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
235 # Create Congress datasources
236 sudo apt-get install -y python-congressclient
238 openstack congress datasource create nova "nova" \
239 --config username=$OS_USERNAME \
240 --config tenant_name=$OS_TENANT_NAME \
241 --config password=$OS_PASSWORD \
242 --config auth_url=http://$keystoneIp:5000/v2.0
243 openstack congress datasource create neutronv2 "neutronv2" \
244 --config username=$OS_USERNAME \
245 --config tenant_name=$OS_TENANT_NAME \
246 --config password=$OS_PASSWORD \
247 --config auth_url=http://$keystoneIp:5000/v2.0
248 openstack congress datasource create ceilometer "ceilometer" \
249 --config username=$OS_USERNAME \
250 --config tenant_name=$OS_TENANT_NAME \
251 --config password=$OS_PASSWORD \
252 --config auth_url=http://$keystoneIp:5000/v2.0
253 openstack congress datasource create cinder "cinder" \
254 --config username=$OS_USERNAME \
255 --config tenant_name=$OS_TENANT_NAME \
256 --config password=$OS_PASSWORD \
257 --config auth_url=http://$keystoneIp:5000/v2.0
258 openstack congress datasource create glancev2 "glancev2" \
259 --config username=$OS_USERNAME \
260 --config tenant_name=$OS_TENANT_NAME \
261 --config password=$OS_PASSWORD \
262 --config auth_url=http://$keystoneIp:5000/v2.0
263 openstack congress datasource create keystone "keystone" \
264 --config username=$OS_USERNAME \
265 --config tenant_name=$OS_TENANT_NAME \
266 --config password=$OS_PASSWORD \
267 --config auth_url=http://$keystoneIp:5000/v2.0