2 ##############################################################################
3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 # http://www.apache.org/licenses/LICENSE-2.0
7 ##############################################################################
11 source common/tools.sh
13 #./openstack.sh "$opnfvsdn" "$opnfvlab" "$opnfvdistro" "$openstack" || true
20 if [ -f ./deployconfig.yaml ];then
21 EXTERNAL_NETWORK=`grep floating-ip-range deployconfig.yaml | cut -d ' ' -f 4 `
23 # split EXTERNAL_NETWORK=first ip;last ip; gateway;network
25 EXTNET=(${EXTERNAL_NETWORK//,/ })
27 EXTNET_FIP=${EXTNET[0]}
28 EXTNET_LIP=${EXTNET[1]}
29 EXTNET_GW=${EXTNET[2]}
30 EXTNET_NET=${EXTNET[3]}
31 EXTNET_PORT=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
32 ADMNET_GW=`grep "admNetgway" 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 juju config onos-controller gateway-mac=$EXTNET_GW_MAC
54 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
58 juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"applications\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
62 if [ $(juju status keystone --format=short | grep " keystone"|wc -l) == 1 ];then
63 unitAddress keystone 0
65 juju config keystone vip | cut -d " " -f 1
69 # create external network and subnet in openstack
71 echo_info "Creating the openrc (OpenStack client environment scripts)"
73 mkdir -m 0700 -p cloud
74 usessl=$(juju config keystone ssl_ca)
75 if [[ "$usessl" == "" ]]; then
80 keystoneIp=$(juju config keystone os-public-hostname | cut -d " " -f 1)
81 if [[ "$keystoneIp" == "" ]]; then
82 keystoneIp=$(keystoneIp)
84 adminPasswd=$(juju config keystone admin-password | cut -d " " -f 1)
86 v3api=$(juju config keystone preferred-api-version)
88 if [[ "$v3api" == "3" ]]; then
89 if [ "$usessl" == "yes" ]; then
90 configOpenrc admin $adminPasswd admin https://$keystoneIp:5000/v3 RegionOne publicURL > ~/joid_config/admin-openrc
92 configOpenrc admin $adminPasswd admin http://$keystoneIp:5000/v3 RegionOne publicURL > ~/joid_config/admin-openrc
94 chmod 0600 ~/joid_config/admin-openrc
95 source ~/joid_config/admin-openrc
96 projectid=`openstack project show admin -c id -f value`
97 projectdomainid=`openstack domain show admin_domain -c id -f value`
98 userdomainid=`openstack user show admin -c domain_id -f value`
99 urlapi=`openstack catalog show keystone --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)['endpoints']" | grep public | cut -d " " -f 4`
100 configOpenrc admin $adminPasswd admin $urlapi RegionOne > ~/joid_config/admin-openrc
102 configOpenrc2 admin $adminPasswd admin http://$keystoneIp:5000/v2.0 RegionOne > ~/joid_config/admin-openrc
103 chmod 0600 ~/joid_config/admin-openrc
109 export SERVICE_ENDPOINT=$4
111 unset SERVICE_ENDPOINT
112 export OS_USERNAME=$1
113 export OS_PASSWORD=$2
114 export OS_TENANT_NAME=$3
115 export OS_AUTH_URL=$4
116 export OS_REGION_NAME=$5
121 if [ "$usessl" == "yes" ]; then
123 #export OS_NO_CACHE='true'
124 export OS_AUTH_URL=$4
125 export OS_USER_DOMAIN_NAME=admin_domain
126 export OS_PROJECT_DOMAIN_NAME=admin_domain
127 export OS_USERNAME=$1
128 export OS_TENANT_NAME=$3
129 export OS_PROJECT_NAME=$3
130 export OS_PASSWORD=$2
131 export OS_IDENTITY_API_VERSION=3
132 export OS_REGION_NAME=$5
133 export OS_INTERFACE=public
134 export OS_CACERT=~/joid_config/keystone_juju_ca_cert.crt
138 #export OS_NO_CACHE='true'
139 export OS_AUTH_URL=$4
140 export OS_USER_DOMAIN_NAME=admin_domain
141 export OS_PROJECT_DOMAIN_NAME=admin_domain
142 export OS_USERNAME=$1
143 export OS_TENANT_NAME=$3
144 export OS_PROJECT_NAME=$3
145 export OS_PASSWORD=$2
146 export OS_IDENTITY_API_VERSION=3
147 export OS_REGION_NAME=$5
148 export OS_INTERFACE=public
149 #export OS_CACERT=~/joid_config/bradm.etsi-ubuntu-jh.maas.pem
155 if [ "$usessl" == "yes" ]; then
156 juju scp keystone/0:/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt ~/joid_config/
159 # Create an load openrc
162 . ~/joid_config/admin-openrc
165 ## removing the swift API endpoint which is created by radosgw.
166 ## one option is not to used radosgw and other one is remove endpoint.
169 #echo "Removing swift endpoint and service"
170 #swift_service_id=$(openstack service list | grep swift | cut -d ' ' -f 2)
171 #swift_endpoint_id=$(openstack endpoint list | grep swift | cut -d ' ' -f 2)
172 #openstack endpoint delete $swift_endpoint_id
173 #openstack service delete $swift_service_id
176 ## Create external subnet Network
179 echo_info "Creating external network with neutron"
181 if [ "onos" == "$opnfvsdn" ]; then
183 openstack network show ext-net > /dev/null 2>&1 || openstack network create \
184 --external --share --enable ext-net
185 elif [ "ocl" == "$opnfvsdn" ]; then
186 openstack network show ext-net > /dev/null 2>&1 || openstack network create \
187 --external --share --enable ext-net
190 openstack network show ext-net > /dev/null 2>&1 || openstack network create \
191 --provider-network-type flat \
192 --provider-physical-network physnet1 \
193 --external --share --enable ext-net
196 openstack subnet show ext-subnet > /dev/null 2>&1 || openstack subnet create \
197 --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
198 --no-dhcp --gateway $EXTNET_GW --network ext-net --subnet-range $EXTNET_NET ext-subnet
200 # Ocl can push packets to the fabric network in order to reach a gateway if BGP/L3VPN hasn't been configured.
201 if [ "ocl" == "$opnfvsdn" ]; then
202 echo "Creating simple gateway functions on ocl vRouters"
203 juju run --application nova-compute "sudo \
204 python /opt/contrail/utils/provision_vgw_interface.py \
205 --oper create --interface vgw1 --subnets $EXTNET_NET --routes 0.0.0.0/24 --vrf default-domain:admin:ext-net:ext-net"
208 #congress team is not updating and supporting charm anymore so defer it.
210 # Create Congress datasources
211 #sudo apt-get install -y python-congressclient
213 #openstack congress datasource create nova "nova" \
214 # --config username=$OS_USERNAME \
215 # --config tenant_name=$OS_TENANT_NAME \
216 # --config password=$OS_PASSWORD \
217 # --config auth_url=http://$keystoneIp:5000/v2.0
218 #openstack congress datasource create neutronv2 "neutronv2" \
219 # --config username=$OS_USERNAME \
220 # --config tenant_name=$OS_TENANT_NAME \
221 # --config password=$OS_PASSWORD \
222 # --config auth_url=http://$keystoneIp:5000/v2.0
223 #openstack congress datasource create ceilometer "ceilometer" \
224 # --config username=$OS_USERNAME \
225 # --config tenant_name=$OS_TENANT_NAME \
226 # --config password=$OS_PASSWORD \
227 # --config auth_url=http://$keystoneIp:5000/v2.0
228 #openstack congress datasource create cinder "cinder" \
229 # --config username=$OS_USERNAME \
230 # --config tenant_name=$OS_TENANT_NAME \
231 # --config password=$OS_PASSWORD \
232 # --config auth_url=http://$keystoneIp:5000/v2.0
233 #openstack congress datasource create glancev2 "glancev2" \
234 # --config username=$OS_USERNAME \
235 # --config tenant_name=$OS_TENANT_NAME \
236 # --config password=$OS_PASSWORD \
237 # --config auth_url=http://$keystoneIp:5000/v2.0
238 #openstack congress datasource create keystone "keystone" \
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