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 if [ -f ./deployconfig.yaml ];then
11 EXTERNAL_NETWORK=`grep floating-ip-range deployconfig.yaml | cut -d ' ' -f 4 `
13 # split EXTERNAL_NETWORK=first ip;last ip; gateway;network
15 EXTNET=(${EXTERNAL_NETWORK//,/ })
17 EXTNET_FIP=${EXTNET[0]}
18 EXTNET_LIP=${EXTNET[1]}
19 EXTNET_GW=${EXTNET[2]}
20 EXTNET_NET=${EXTNET[3]}
21 EXTNET_PORT=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
22 ADMNET_GW=`grep "admNetgway" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
23 API_FQDN=`grep "os-domain-name" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
26 # launch eth on computer nodes and remove default gw route
28 computer_list=$(juju status --format short | grep -Eo 'nova-compute/[0-9]')
29 for node in $computer_list; do
30 echo "node name is ${node}"
31 juju ssh $node "sudo ifconfig $EXTNET_PORT up"
32 #juju ssh $node "sudo route del default gw $ADMNET_GW"
36 # Update gateway mac to onos for l3 function
39 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})'")
40 ## set external gateway mac in onos
41 juju set onos-controller gateway-mac=$EXTNET_GW_MAC
45 juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
49 juju status | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
53 KEYSTONE=$(juju status keystone |grep public-address|sed -- 's/.*\: //')
54 if [ $(echo $KEYSTONE|wc -w) == 1 ];then
57 juju get keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']"
61 # create external network and subnet in openstack
63 mkdir -m 0700 -p cloud
64 keystoneIp=$(keystoneIp)
65 adminPasswd=$(juju get keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
66 configOpenrc admin $adminPasswd admin http://$keystoneIp:5000/v2.0 RegionOne > cloud/admin-openrc
67 chmod 0600 cloud/admin-openrc
71 if [ "$API_FQDN" != "''" ]; then
75 export OS_TENANT_NAME=$3
77 export OS_REGION_NAME=$5
78 export OS_ENDPOINT_TYPE='internalURL'
79 export CINDER_ENDPOINT_TYPE='internalURL'
80 export GLANCE_ENDPOINT_TYPE='internalURL'
81 export KEYSTONE_ENDPOINT_TYPE='internalURL'
82 export NEUTRON_ENDPOINT_TYPE='internalURL'
83 export NOVA_ENDPOINT_TYPE='internalURL'
89 export OS_TENANT_NAME=$3
91 export OS_REGION_NAME=$5
97 if [ "$API_FQDN" != "''" ]; then
98 # Push api fqdn local ip to all /etc/hosts
99 API_FQDN=$(juju get keystone | python -c "import yaml; import sys;\
100 print yaml.load(sys.stdin)['settings']['os-public-hostname']['value']")
102 KEYSTONEIP=$(keystoneIp)
103 juju run --all "if grep $API_FQDN /etc/hosts > /dev/null; then \
104 echo 'API FQDN already present'; \
106 sudo sh -c 'echo $KEYSTONEIP $API_FQDN >> /etc/hosts'; \
107 echo 'API FQDN injected'; \
110 #change in jumphost as well as below commands will run on jumphost
112 if grep $API_FQDN /etc/hosts; then
113 echo 'API FQDN already present'
115 sudo sh -c "echo $KEYSTONEIP $API_FQDN >> /etc/hosts"
116 echo 'API FQDN injected'
120 # Create an load openrc
123 . ./cloud/admin-openrc
126 ## removing the swift API endpoint which is created by radosgw.
127 ## one option is not to used radosgw and other one is remove endpoint.
130 echo "Removing swift endpoint and service"
131 swift_service_id=$(openstack service list | grep swift | cut -d ' ' -f 2)
132 swift_endpoint_id=$(openstack endpoint list | grep swift | cut -d ' ' -f 2)
133 openstack endpoint delete $swift_endpoint_id
134 openstack service delete $swift_service_id
137 ## Create external subnet Network
140 #neutron net-create ext-net --shared --router:external=True
141 neutron net-create ext-net --router:external=True
143 if [ "onos" == "$1" ]; then
145 neutron subnet-create ext-net --name ext-subnet \
146 --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
147 --disable-dhcp --gateway $EXTNET_GW --dns-nameserver 8.8.8.8 $EXTNET_NET
148 #neutron subnet-create ext-net --name ext-subnet $EXTNET_NET
150 elif [ "nosdn" == "$1" ]; then
151 neutron subnet-create ext-net --name ext-subnet \
152 --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
153 --disable-dhcp --gateway $EXTNET_GW --dns-nameserver 8.8.8.8 $EXTNET_NET
154 # configure security groups
155 #neutron security-group-rule-create --direction ingress --ethertype IPv4 --protocol icmp --remote-ip-prefix 0.0.0.0/0 default
156 #neutron security-group-rule-create --direction ingress --ethertype IPv4 --protocol tcp --port-range-min 22 --port-range-max 22 --remote-ip-prefix 0.0.0.0/0 default
158 neutron subnet-create ext-net --name ext-subnet \
159 --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
160 --disable-dhcp --gateway $EXTNET_GW --dns-nameserver 8.8.8.8 $EXTNET_NET
164 # Create Congress datasources
165 sudo apt-get install -y python-congressclient
167 openstack congress datasource create nova "nova" \
168 --config username=$OS_USERNAME \
169 --config tenant_name=$OS_TENANT_NAME \
170 --config password=$OS_PASSWORD \
171 --config auth_url=http://$keystoneIp:5000/v2.0
172 openstack congress datasource create neutronv2 "neutronv2" \
173 --config username=$OS_USERNAME \
174 --config tenant_name=$OS_TENANT_NAME \
175 --config password=$OS_PASSWORD \
176 --config auth_url=http://$keystoneIp:5000/v2.0
177 openstack congress datasource create ceilometer "ceilometer" \
178 --config username=$OS_USERNAME \
179 --config tenant_name=$OS_TENANT_NAME \
180 --config password=$OS_PASSWORD \
181 --config auth_url=http://$keystoneIp:5000/v2.0
182 openstack congress datasource create cinder "cinder" \
183 --config username=$OS_USERNAME \
184 --config tenant_name=$OS_TENANT_NAME \
185 --config password=$OS_PASSWORD \
186 --config auth_url=http://$keystoneIp:5000/v2.0
187 openstack congress datasource create glancev2 "glancev2" \
188 --config username=$OS_USERNAME \
189 --config tenant_name=$OS_TENANT_NAME \
190 --config password=$OS_PASSWORD \
191 --config auth_url=http://$keystoneIp:5000/v2.0
192 openstack congress datasource create keystone "keystone" \
193 --config username=$OS_USERNAME \
194 --config tenant_name=$OS_TENANT_NAME \
195 --config password=$OS_PASSWORD \
196 --config auth_url=http://$keystoneIp:5000/v2.0