3 # Copyright (C) 2013 Cisco Systems, Inc.
5 # This program and the accompanying materials are made available under the
6 # terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 # and is available at http://www.eclipse.org/legal/epl-v10.html
9 # Authors : Thomas Bachman
12 # Generate the local.conf, based on this machine's settings,
27 # Minimum memory requirements, in kB
37 # personality-dependent services
39 ds_common_services="qpid neutron odl-compute n-cpu"
40 ds_compute_services="nova n-novnc"
41 ds_controller_services="n-cond q-svc q-dhcp q-l3 q-meta tempest"
44 # everyone gets these services
46 services=$ds_common_services
49 # services that are disabled
51 disabled_services="rabbit n-net"
54 LOGFILE=stack.sh.log\n
55 #SCREEN_LOGDIR=/opt/stack/data/log\n
63 # single quoted to prevent variable substitutions
68 Q_HOST=$SERVICE_HOST\n
70 Q_ML2_PLUGIN_MECHANISM_DRIVERS=opendaylight,logger\n
71 ENABLE_TENANT_TUNNELS=True\n
74 VNCSERVER_PROXYCLIENT_ADDRESS=${HOST_IP}\n
75 VNCSERVER_LISTEN=0.0.0.0\n
77 #FLOATING_RANGE=192.168.210.0/24\n
78 #PUBLIC_NETWORK_GATEWAY=192.168.75.254\n
79 MYSQL_HOST=$SERVICE_HOST\n
80 RABBIT_HOST=$SERVICE_HOST\n
81 GLANCE_HOSTPORT=$SERVICE_HOST:9292\n
82 KEYSTONE_AUTH_HOST=$SERVICE_HOST\n
83 KEYSTONE_SERVICE_HOST=$SERVICE_HOST\n
85 MYSQL_PASSWORD=mysql\n
86 RABBIT_PASSWORD=rabbit\n
87 QPID_PASSWORD=rabbit\n
88 SERVICE_TOKEN=service\n
89 SERVICE_PASSWORD=admin\n
90 ADMIN_PASSWORD=admin\n
92 [[post-config|/etc/neutron/plugins/ml2/ml2_conf.ini]]\n
94 minimize_polling=True\n
98 # Create a list of active network interfaces
102 all_ifs=`egrep 'ONBOOT' /etc/sysconfig/network-scripts/ifcfg-*`
103 for interface in $all_ifs
105 active=`echo $interface | awk 'BEGIN {FS="="} {print $2}'`
106 if [ "$active" == "yes" ]; then
107 file=`echo $interface | awk 'BEGIN {FS=":"} {print $1}'`
108 intf=`basename $file | awk 'BEGIN {FS="-"} {print $2}'`
109 active_ifs=`echo "$active_ifs $intf"`
115 # Have the user select the IP address to use
120 echo "Your system has the following IP addresses: "
123 for interface in $active_ifs
125 if [ "$interface" == "lo" ]; then
128 exists=`ifconfig | grep $interface`
129 if [ "$exists" == "" ]; then
132 ip=`ifconfig $interface | grep 'inet ' | awk 'BEGIN {FS=" "} {print $2}'`
133 echo " [$count] $interface: $ip"
138 if [ $count == 0 ]; then
139 echo "No active interfaces: please reconfigure /etc/sysconfig/network-scripts/ifcfg-<interface> and re-run"
141 elif [ $count > 1 ]; then
142 echo -n "Select which interface to use [$entry]: "
144 if [ "$entry" > "$count" ]; then
146 echo "Invalid entry, must be less than $maxcnt"
148 elif [ "$entry" == "" ]; then
156 for interface in $active_ifs
158 if [ $count == $if_index ]; then
160 host_ip=`ifconfig $interface | grep 'inet ' | awk 'BEGIN {FS=" "} {print $2}'`
168 # Verify the memory is sufficient for the configuration
172 memory=`cat /proc/meminfo | grep MemTotal | awk 'BEGIN {FS=" "} {print $2}'`
173 if [ "$vm_personality" == "O" ]; then
175 elif [ "$vm_personality" == "DC" ]; then
177 elif [ "$vm_personality" == "D" ]; then
179 elif [ "$vm_personality" == "ODC" ]; then
181 elif [ "$vm_personality" == "DCD" ]; then
184 if [ "$memory" -lt "$mem_needed" ]; then
186 $vm_personality configurations require at least $mem_needed (have $memory).
187 Please shutdown the VM and reconfigure its memory
194 This script configures the local.conf for the
195 VM, based on the desired configuration. The
196 VM can take on any of the following roles:
198 O: OpenDaylight Controller.
199 In this role, the VM is only responsible
200 for running the OpenDaylight Controller
202 DC: DevStack Controller.
203 In this role, the VM is only responsible
204 for running the DevStack controller.
206 D: DevStack Compute. In this role,
207 the VM is only responsible for
208 running the DevStack compute.
210 ODC: OpenDaylight Controller with DevStack Controller.
211 In this role, the VM runs both the OpenDaylight
212 controller and the DevStack controller. The
213 OpenDaylight controller is launched by DevStack.
215 DCD: DevStack Controller with DevStack Compute.
216 In this role, the VM acts as both an DevStack
217 controller and compute node.
220 echo -n "Enter VM's personality [$vm_personality]: "
222 if [ "$entry" == "" ]; then
223 entry=$vm_personality
225 vm_personality=$entry
227 if [ "$vm_personality" != "O" ] &&
228 [ "$vm_personality" != "DC" ] &&
229 [ "$vm_personality" != "D" ] &&
230 [ "$vm_personality" != "ODC" ] &&
231 [ "$vm_personality" != "DCD" ]; then
232 echo "$vm_personality is invalid"
236 # For all nodes, run the memory check to make
237 # sure they've allocated enough memory to
244 service_host=$host_ip
245 service_host_name=$host_name
247 # For a combined ODL/DS coontroller, we still need
248 # to add in the services
249 if [ "$vm_personality" == "ODC" ]; then
250 services="$services $ds_controller_services odl-server"
253 # For all pure DS nodes (no ODL -- DS controller, compute, or both),
254 # we need to point it to the ODL Controller
255 if [ "$vm_personality" == "D" ] ||
256 [ "$vm_personality" == "DC" ] ||
257 [ "$vm_personality" == "DCD" ]; then
258 if [ "$vm_personality" == "D" ]; then
259 services="$services $ds_compute_services"
261 services="$services $ds_controller_services"
263 service_host=$host_ip
264 service_host_name=$host_name
266 DevStack nodes need to point to the OpenDaylight Controller.
267 Please provide the IP address of the OpenDaylight Controller.
269 echo -n "OpenDaylight Controller IP: "
275 # For DS Compute Only, we need to point it to
276 # the DS Controller and update the DS services
277 if [ "$vm_personality" == "D" ]; then
278 services="$services $ds_compute_services"
280 DevStack Compute nodes need to point to the DevStack
281 Controller. Please provide the IP address and hostname
282 of the DevStack Controller
284 echo -n "DevStack Controller IP: "
286 echo -n "DevStack Controller hostname: "
287 read -a service_host_name
288 if [ "$service_host_name" == "$host_name" ]; then
290 Note: You have configured the DevStack controller's
291 with the same name as this host. If this host
292 requires a name change, run the set_hostname.sh
293 script before running this one.
297 DevStack Compute nodes also need to point to the
298 OpenDaylight Controller. Please provide the IP address
299 of the OpenDaylight Controller
302 # for DS compute, keep track of service host
303 host_list=$service_host_name
307 # Generate local.conf, using parameters
309 echo "[[local|localrc]]" > local.conf
314 echo -e $header | while read -r line
316 echo -e $line >> local.conf
322 # disable all services for compute only nodes
323 if [ "$vm_personality" == "D" ]; then
324 echo "disable_all_services" >> local.conf
327 for line in $disabled_services
329 echo "disable_service $line" >> local.conf
332 for line in $services
334 echo -e "enable_service $line" >> local.conf
336 echo -e "\n" >> local.conf
341 # Add in VM-specific parameters
343 echo "HOST_IP=$host_ip" >> local.conf
344 echo "HOST_NAME=$host_name" >> local.conf
345 echo "SERVICE_HOST=$service_host" >> local.conf
346 echo "SERVICE_HOST_NAME=$service_host_name" >> local.conf
347 if [ "$vm_personality" != "O" ] &&
348 [ "$vm_personality" != "ODC" ]; then
349 echo "ODL_MGR_IP=$odl_ip" >> local.conf
356 echo -e $footer | while read -r line
358 echo -e $line >> local.conf
362 if [ "$host_list" != "" ]; then
363 echo "*********************************************************"
364 echo "===========>>>> Be sure to add $host_list to /etc/hosts!"
365 echo "*********************************************************"