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 ',' ' '`
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 Canonical > cloud/admin-openrc
67 chmod 0600 cloud/admin-openrc
74 export OS_TENANT_NAME=$3
76 export OS_REGION_NAME=$5
77 export OS_ENDPOINT_TYPE='internalURL'
78 export CINDER_ENDPOINT_TYPE='internalURL'
79 export GLANCE_ENDPOINT_TYPE='internalURL'
80 export KEYSTONE_ENDPOINT_TYPE='internalURL'
81 export NEUTRON_ENDPOINT_TYPE='internalURL'
82 export NOVA_ENDPOINT_TYPE='internalURL'
86 # Push api fqdn local ip to all /etc/hosts
87 API_FQDN=$(juju get keystone | python -c "import yaml; import sys;\
88 print yaml.load(sys.stdin)['settings']['os-public-hostname']['value']")
92 KEYSTONEIP=$(keystoneIp)
93 juju run --all "if grep $API_FQDN /etc/hosts > /dev/null; then \
94 echo 'API FQDN already present'; \
96 sudo sh -c 'echo $KEYSTONEIP $API_FQDN >> /etc/hosts'; \
97 echo 'API FQDN injected'; \
100 #change in jumphost as well as below commands will run on jumphost
102 if grep $API_FQDN /etc/hosts; then
103 echo 'API FQDN already present'
105 sudo sh -c "echo $KEYSTONEIP $API_FQDN >> /etc/hosts"
106 echo 'API FQDN injected'
109 # Create an load openrc
111 . ./cloud/admin-openrc
113 wget -P /tmp/images http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img
114 openstack image create --file /tmp/images/cirros-0.3.3-x86_64-disk.img --disk-format qcow2 --container-format bare "cirros-0.3.3-x86_64"
116 #wget -P /tmp/images http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
117 #openstack image create --file /tmp/images/trusty-server-cloudimg-amd64-disk1.img --disk-format qcow2 --container-format bare "ubuntu-trusty-daily"
118 #wget -P /tmp/images http://cloud-images.ubuntu.com/trusty/current/xenial-server-cloudimg-amd64.tar.gz
119 #openstack image create --file /tmp/images/xenial-server-cloudimg-amd64.tar.gz --container-format bare --disk-format raw "xenial-server-cloudimg-amd64"
124 #nova flavor-delete m1.tiny
125 #nova flavor-create m1.tiny 1 512 8 1
129 openstack project create --description "Demo Tenant" demo
130 openstack user create --project demo --password demo --email demo@demo.demo demo
132 openstack keypair create --public-key ~/.ssh/id_rsa.pub ubuntu-keypair
134 # configure external network
137 ## Create external subnet Network
139 if [ "onos" == "$1" ]; then
141 neutron net-create ext-net --shared --router:external=True
142 neutron subnet-create ext-net --name ext-subnet $EXTNET_NET
144 elif [ "nosdn" == "$1" ]; then
145 neutron net-create ext-net --shared --router:external --provider:physical_network external --provider:network_type flat
146 neutron subnet-create ext-net --name ext-subnet \
147 --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
148 --disable-dhcp --gateway $EXTNET_GW --dns-nameserver 8.8.8.8 $EXTNET_NET
149 # configure security groups
150 neutron security-group-rule-create --direction ingress --ethertype IPv4 --protocol icmp --remote-ip-prefix 0.0.0.0/0 default
151 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
153 neutron net-create ext-net --shared --router:external --provider:physical_network external --provider:network_type flat
154 neutron subnet-create ext-net --name ext-subnet \
155 --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
156 --disable-dhcp --gateway $EXTNET_GW --dns-nameserver 8.8.8.8 $EXTNET_NET
161 neutron net-create demo-net
162 neutron subnet-create --name demo-subnet --gateway 10.20.5.1 demo-net 10.20.5.0/24
164 neutron router-create demo-router
166 neutron router-interface-add demo-router demo-subnet
168 neutron router-gateway-set demo-router ext-net
170 # create pool of floating ips
172 while [ $i -ne 3 ]; do
173 neutron floatingip-create ext-net
177 #http://docs.openstack.org/juno/install-guide/install/apt/content/launch-instance-neutron.html
178 # nova boot --flavor m1.small --image cirros-0.3.3-x86_64 --nic net-id=b65479a4-3638-4595-9245-6e41ccd8bfd8 --security-group default --key-name ubuntu-keypair demo-instance1
179 # nova floating-ip-associate demo-instance1 10.5.8.35
181 # Create Congress datasources
182 sudo apt-get install -y python-congressclient
183 openstack congress datasource create nova "nova" \
184 --config username=$OS_USERNAME \
185 --config tenant_name=$OS_TENANT_NAME \
186 --config password=$OS_PASSWORD \
187 --config auth_url=http://$keystoneIp:5000/v2.0
188 openstack congress datasource create neutronv2 "neutronv2" \
189 --config username=$OS_USERNAME \
190 --config tenant_name=$OS_TENANT_NAME \
191 --config password=$OS_PASSWORD \
192 --config auth_url=http://$keystoneIp:5000/v2.0
193 openstack congress datasource create ceilometer "ceilometer" \
194 --config username=$OS_USERNAME \
195 --config tenant_name=$OS_TENANT_NAME \
196 --config password=$OS_PASSWORD \
197 --config auth_url=http://$keystoneIp:5000/v2.0
198 openstack congress datasource create cinder "cinder" \
199 --config username=$OS_USERNAME \
200 --config tenant_name=$OS_TENANT_NAME \
201 --config password=$OS_PASSWORD \
202 --config auth_url=http://$keystoneIp:5000/v2.0
203 openstack congress datasource create glancev2 "glancev2" \
204 --config username=$OS_USERNAME \
205 --config tenant_name=$OS_TENANT_NAME \
206 --config password=$OS_PASSWORD \
207 --config auth_url=http://$keystoneIp:5000/v2.0
208 openstack congress datasource create keystone "keystone" \
209 --config username=$OS_USERNAME \
210 --config tenant_name=$OS_TENANT_NAME \
211 --config password=$OS_PASSWORD \
212 --config auth_url=http://$keystoneIp:5000/v2.0