48
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
49
## set external gateway mac in onos
50
juju config onos-controller gateway-mac=$EXTNET_GW_MAC
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
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
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
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
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
62
74
if [ $(juju status keystone --format=short | grep " keystone"|wc -l) == 1 ];then
63
75
unitAddress keystone 0
65
juju config keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']" | cut -d " " -f 1
77
if [[ "$jujuver" < "2" ]]; then
78
juju get keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']"
80
juju config keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']"
69
85
# create external network and subnet in openstack
71
echo_info "Creating the openrc (OpenStack client environment scripts)"
73
87
mkdir -m 0700 -p cloud
74
88
keystoneIp=$(keystoneIp)
75
adminPasswd=$(juju config keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
77
v3api=`juju config keystone preferred-api-version`
79
if [[ "$v3api" == "3" ]]; then
80
configOpenrc admin $adminPasswd admin http://$keystoneIp:5000/v3 RegionOne publicURL > ~/joid_config/admin-openrc
81
chmod 0600 ~/joid_config/admin-openrc
82
source ~/joid_config/admin-openrc
83
projectid=`openstack project show admin -c id -f value`
84
projectdomainid=`openstack domain show admin_domain -c id -f value`
85
userdomainid=`openstack user show admin -c domain_id -f value`
86
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`
87
configOpenrc admin $adminPasswd admin $urlapi RegionOne > ~/joid_config/admin-openrc
89
if [[ "$jujuver" < "2" ]]; then
90
adminPasswd=$(juju get keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
89
configOpenrc2 admin $adminPasswd admin http://$keystoneIp:5000/v2.0 RegionOne > ~/joid_config/admin-openrc
90
chmod 0600 ~/joid_config/admin-openrc
92
adminPasswd=$(juju config keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
96
export SERVICE_ENDPOINT=$4
98
unset SERVICE_ENDPOINT
100
export OS_PASSWORD=$2
101
export OS_TENANT_NAME=$3
102
export OS_AUTH_URL=$4
103
export OS_REGION_NAME=$5
95
configOpenrc admin $adminPasswd admin http://$keystoneIp:35357/v2.0 RegionOne > ~/joid_config/admin-openrc
96
chmod 0600 ~/joid_config/admin-openrc
109
#export OS_NO_CACHE='true'
110
export OS_AUTH_URL=$4
111
export OS_USER_DOMAIN_NAME=admin_domain
112
export OS_PROJECT_DOMAIN_NAME=admin_domain
113
export OS_USERNAME=$1
114
export OS_TENANT_NAME=$3
115
export OS_PROJECT_NAME=$3
116
export OS_PASSWORD=$2
117
export OS_IDENTITY_API_VERSION=3
118
export OS_REGION_NAME=$5
119
export OS_INTERFACE=public
120
#export OS_INSECURE=true
121
#export OS_CASSL=~/joid_config/ca.pem
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'
125
164
# Create an load openrc
128
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" deployment.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 ......"
131
206
## removing the swift API endpoint which is created by radosgw.
132
207
## one option is not to used radosgw and other one is remove endpoint.
142
217
## Create external subnet Network
145
echo_info "Creating external network with neutron"
147
220
if [ "onos" == "$opnfvsdn" ]; then
149
openstack network show ext-net > /dev/null 2>&1 || openstack network create \
150
--external --share --enable ext-net
151
elif [ "ocl" == "$opnfvsdn" ]; then
152
openstack network show ext-net > /dev/null 2>&1 || openstack network create \
153
--external --share --enable ext-net
156
openstack network show ext-net > /dev/null 2>&1 || openstack network create \
157
--provider-network-type flat \
158
--provider-physical-network physnet1 \
159
--external --share --enable ext-net
162
openstack subnet show ext-subnet > /dev/null 2>&1 || openstack subnet create \
163
--allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
164
--no-dhcp --gateway $EXTNET_GW --network ext-net --subnet-range $EXTNET_NET ext-subnet
166
# Ocl can push packets to the fabric network in order to reach a gateway if BGP/L3VPN hasn't been configured.
167
if [ "ocl" == "$opnfvsdn" ]; then
168
echo "Creating simple gateway functions on ocl vRouters"
169
juju run --application nova-compute "sudo \
170
python /opt/contrail/utils/provision_vgw_interface.py \
171
--oper create --interface vgw1 --subnets $EXTNET_NET --routes 0.0.0.0/24 --vrf default-domain:admin:ext-net:ext-net"
174
#congress team is not updating and supporting charm anymore so defer it.
222
neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net --router:external=True
223
neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
224
--name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
225
--disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
226
#neutron subnet-create ext-net --name ext-subnet $EXTNET_NET
228
elif [ "nosdn" == "$opnfvsdn" ]; then
229
neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
230
--router:external=True \
231
--provider:network_type flat \
232
--provider:physical_network physnet1
234
neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
235
--name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
236
--disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
238
elif [ "odl" == "$opnfvsdn" ]; then
239
neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
240
--router:external=True \
241
--provider:network_type vxlan
243
neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
244
--name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
245
--disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
247
neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
248
--router:external=True \
249
--provider:network_type flat \
250
--provider:physical_network physnet1
252
neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
253
--name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
254
--disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
176
258
# Create Congress datasources
177
#sudo apt-get install -y python-congressclient
259
sudo apt-get install -y python-congressclient
179
#openstack congress datasource create nova "nova" \
180
# --config username=$OS_USERNAME \
181
# --config tenant_name=$OS_TENANT_NAME \
182
# --config password=$OS_PASSWORD \
183
# --config auth_url=http://$keystoneIp:5000/v2.0
184
#openstack congress datasource create neutronv2 "neutronv2" \
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 ceilometer "ceilometer" \
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 cinder "cinder" \
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 glancev2 "glancev2" \
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 keystone "keystone" \
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
261
openstack congress datasource create nova "nova" \
262
--config username=$OS_USERNAME \
263
--config tenant_name=$OS_TENANT_NAME \
264
--config password=$OS_PASSWORD \
265
--config auth_url=http://$keystoneIp:5000/v2.0
266
openstack congress datasource create neutronv2 "neutronv2" \
267
--config username=$OS_USERNAME \
268
--config tenant_name=$OS_TENANT_NAME \
269
--config password=$OS_PASSWORD \
270
--config auth_url=http://$keystoneIp:5000/v2.0
271
openstack congress datasource create ceilometer "ceilometer" \
272
--config username=$OS_USERNAME \
273
--config tenant_name=$OS_TENANT_NAME \
274
--config password=$OS_PASSWORD \
275
--config auth_url=http://$keystoneIp:5000/v2.0
276
openstack congress datasource create cinder "cinder" \
277
--config username=$OS_USERNAME \
278
--config tenant_name=$OS_TENANT_NAME \
279
--config password=$OS_PASSWORD \
280
--config auth_url=http://$keystoneIp:5000/v2.0
281
openstack congress datasource create glancev2 "glancev2" \
282
--config username=$OS_USERNAME \
283
--config tenant_name=$OS_TENANT_NAME \
284
--config password=$OS_PASSWORD \
285
--config auth_url=http://$keystoneIp:5000/v2.0
286
openstack congress datasource create keystone "keystone" \
287
--config username=$OS_USERNAME \
288
--config tenant_name=$OS_TENANT_NAME \
289
--config password=$OS_PASSWORD \
290
--config auth_url=http://$keystoneIp:5000/v2.0