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 ##############################################################################
13 if [ -f ./deployconfig.yaml ];then
14 EXTERNAL_NETWORK=`grep floating-ip-range deployconfig.yaml | cut -d ' ' -f 4 `
16 # split EXTERNAL_NETWORK=first ip;last ip; gateway;network
18 EXTNET=(${EXTERNAL_NETWORK//,/ })
20 EXTNET_FIP=${EXTNET[0]}
21 EXTNET_LIP=${EXTNET[1]}
22 EXTNET_GW=${EXTNET[2]}
23 EXTNET_NET=${EXTNET[3]}
24 EXTNET_PORT=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
25 ADMNET_GW=`grep "admNetgway" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
26 API_FQDN=`grep "os-domain-name" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
29 # launch eth on computer nodes and remove default gw route
31 computer_list=$(juju status --format short | grep -Eo 'nova-compute/[0-9]')
32 for node in $computer_list; do
33 echo "node name is ${node}"
34 juju ssh $node "sudo ifconfig $EXTNET_PORT up"
35 #juju ssh $node "sudo route del default gw $ADMNET_GW"
39 # Update gateway mac to onos for l3 function
42 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})'")
43 ## set external gateway mac in onos
44 juju set onos-controller gateway-mac=$EXTNET_GW_MAC
48 juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
52 juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
56 KEYSTONE=$(juju status keystone |grep public-address|sed -- 's/.*\: //')
57 if [ $(echo $KEYSTONE|wc -w) == 1 ];then
60 juju get keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']"
64 # create external network and subnet in openstack
66 mkdir -m 0700 -p cloud
67 keystoneIp=$(keystoneIp)
68 adminPasswd=$(juju get keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
69 configOpenrc admin $adminPasswd admin http://$keystoneIp:5000/v2.0 RegionOne > cloud/admin-openrc
70 chmod 0600 cloud/admin-openrc
74 if [ "$API_FQDN" != "None" ]; then
78 export OS_TENANT_NAME=$3
80 export OS_REGION_NAME=$5
81 export OS_ENDPOINT_TYPE='internalURL'
82 export CINDER_ENDPOINT_TYPE='internalURL'
83 export GLANCE_ENDPOINT_TYPE='internalURL'
84 export KEYSTONE_ENDPOINT_TYPE='internalURL'
85 export NEUTRON_ENDPOINT_TYPE='internalURL'
86 export NOVA_ENDPOINT_TYPE='internalURL'
92 export OS_TENANT_NAME=$3
94 export OS_REGION_NAME=$5
100 if [ "$API_FQDN" != "None" ]; then
101 # Push api fqdn local ip to all /etc/hosts
102 API_FQDN=$(juju get keystone | python -c "import yaml; import sys;\
103 print yaml.load(sys.stdin)['settings']['os-public-hostname']['value']")
105 KEYSTONEIP=$(keystoneIp)
106 juju run --all "if grep $API_FQDN /etc/hosts > /dev/null; then \
107 echo 'API FQDN already present'; \
109 sudo sh -c 'echo $KEYSTONEIP $API_FQDN >> /etc/hosts'; \
110 echo 'API FQDN injected'; \
113 #change in jumphost as well as below commands will run on jumphost
115 if grep $API_FQDN /etc/hosts; then
116 echo 'API FQDN already present'
118 sudo sh -c "echo $KEYSTONEIP $API_FQDN >> /etc/hosts"
119 echo 'API FQDN injected'
123 # Create an load openrc
126 . ./cloud/admin-openrc
128 echo "...... deploy public api proxy ......"
130 if [ "$opnfvlab" == "orangepod1" ] && [ "$opnfvsdn" == "nosdn" ]; then # only for first test phase
131 PUB_API_NET=$(grep floating-ip-range ./labconfig.yaml |cut -d/ -f2)
132 PUB_API_IP=$(grep public-api-ip ./labconfig.yaml |cut -d: -f2)
133 juju run --unit nodes/0 "sudo ip a a ${PUB_API_IP}/${PUB_API_NET} dev br-ex" || true
134 juju run --unit nodes/0 "sudo ip l set dev br-ex up" || true
135 python genPublicAPIProxyBundle.py -l labconfig.yaml >> bundles.yaml
136 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$openstack" || true
139 echo "...... deploy end public api proxy ......"
142 ## removing the swift API endpoint which is created by radosgw.
143 ## one option is not to used radosgw and other one is remove endpoint.
146 #echo "Removing swift endpoint and service"
147 #swift_service_id=$(openstack service list | grep swift | cut -d ' ' -f 2)
148 #swift_endpoint_id=$(openstack endpoint list | grep swift | cut -d ' ' -f 2)
149 #openstack endpoint delete $swift_endpoint_id
150 #openstack service delete $swift_service_id
153 ## Create external subnet Network
156 if [ "onos" == "$opnfvsdn" ]; then
158 neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net --router:external=True
159 neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
160 --name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
161 --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
162 #neutron subnet-create ext-net --name ext-subnet $EXTNET_NET
164 elif [ "nosdn" == "$opnfvsdn" ]; then
165 neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
166 --router:external=True \
167 --provider:network_type flat \
168 --provider:physical_network external
170 neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
171 --name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
172 --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
174 neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net --router:external=True
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
181 # Create Congress datasources
182 sudo apt-get install -y python-congressclient
184 openstack congress datasource create nova "nova" \
185 --config username=$OS_USERNAME \
186 --config tenant_name=$OS_TENANT_NAME \
187 --config password=$OS_PASSWORD \
188 --config auth_url=http://$keystoneIp:5000/v2.0
189 openstack congress datasource create neutronv2 "neutronv2" \
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 ceilometer "ceilometer" \
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 cinder "cinder" \
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 glancev2 "glancev2" \
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 keystone "keystone" \
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