-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdsconf.sh
More file actions
executable file
·364 lines (318 loc) · 8.95 KB
/
Copy pathdsconf.sh
File metadata and controls
executable file
·364 lines (318 loc) · 8.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#!/bin/bash
#
# Copyright (C) 2013 Cisco Systems, Inc.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v1.0 which accompanies this distribution,
# and is available at http://www.eclipse.org/legal/epl-v10.html
#
# Authors : Thomas Bachman
#
# Generate the local.conf, based on this machine's settings,
# and user input
#
odl_ip=""
odl_in_ds="y"
vm_personality="ODC"
active_ifs=""
service_host=""
service_host_name=""
odl_mgr_ip=""
host_ip=""
host_name=`hostname`
host_list=""
# Minimum memory requirements, in kB
od_mem=50000000
oc_mem=3000000
o_mem=2000000
odoc_mem=5000000
oco_mem=3000000
#
# personality-dependent services
#
ds_common_services="qpid neutron odl-compute n-cpu"
ds_compute_services="nova n-novnc"
ds_controller_services="n-cond q-svc q-dhcp q-l3 q-meta tempest"
#
# everyone gets these services
#
services=$ds_common_services
#
# services that are disabled
#
disabled_services="rabbit n-net"
header='''
LOGFILE=stack.sh.log\n
#SCREEN_LOGDIR=/opt/stack/data/log\n
#LOG_COLOR=False\n
#OFFLINE=True\n
RECLONE=yes\n
\n
'''
#
# single quoted to prevent variable substitutions
#
# add host info
footer='''
Q_HOST=$SERVICE_HOST\n
Q_PLUGIN=ml2\n
Q_ML2_PLUGIN_MECHANISM_DRIVERS=opendaylight,logger\n
ENABLE_TENANT_TUNNELS=True\n
ODL_BOOT_WAIT=70\n
\n
VNCSERVER_PROXYCLIENT_ADDRESS=${HOST_IP}\n
VNCSERVER_LISTEN=0.0.0.0\n
\n
#FLOATING_RANGE=192.168.210.0/24\n
#PUBLIC_NETWORK_GATEWAY=192.168.75.254\n
MYSQL_HOST=$SERVICE_HOST\n
RABBIT_HOST=$SERVICE_HOST\n
GLANCE_HOSTPORT=$SERVICE_HOST:9292\n
KEYSTONE_AUTH_HOST=$SERVICE_HOST\n
KEYSTONE_SERVICE_HOST=$SERVICE_HOST\n
\n
MYSQL_PASSWORD=mysql\n
RABBIT_PASSWORD=rabbit\n
QPID_PASSWORD=rabbit\n
SERVICE_TOKEN=service\n
SERVICE_PASSWORD=admin\n
ADMIN_PASSWORD=admin\n
\n
[[post-config|/etc/neutron/plugins/ml2/ml2_conf.ini]]\n
[agent]\n
minimize_polling=True\n
'''
#
# Create a list of active network interfaces
#
get_active_ifs()
{
all_ifs=`ls /sys/class/net`
for interface in $all_ifs
do
active=`cat /sys/class/net/$interface/operstate`
if [ "$active" == "up" ]; then
active_ifs=`echo "$active_ifs $interface"`
fi
done
}
#
# Have the user select the IP address to use
#
select_host_ip()
{
get_active_ifs
echo "Your system has the following IP addresses: "
count=0
if_index="0"
for interface in $active_ifs
do
if [ "$interface" == "lo" ]; then
continue;
fi
exists=`ifconfig | grep $interface`
if [ "$exists" == "" ]; then
continue;
fi
ip=`ifconfig $interface | grep 'inet ' | awk 'BEGIN {FS=":"} {print $2}' | awk 'BEGIN {FS=" "} {print $1}'`
echo " [$count] $interface: $ip"
let "count+=1";
done
entry=$if_index
if [ $count == 0 ]; then
echo "No active interfaces: please reconfigure /etc/sysconfig/network-scripts/ifcfg-<interface> and re-run"
exit
elif [ $count > 1 ]; then
echo -n "Select which interface to use [$entry]: "
read -a entry
if [ "$entry" == "" ]; then
entry=$if_index
else
if_index=$entry
fi
if [ "$entry" -gt "$count" ]; then
let "maxcnt=count-1"
echo "Invalid entry, must be less than $maxcnt"
exit
fi
fi
count=0
for interface in $active_ifs
do
if [ $count == $if_index ]; then
#echo "foo"
host_ip=`ifconfig $interface | grep 'inet ' | awk 'BEGIN {FS=":"} {print $2}' | awk 'BEGIN {FS=" "} {print $1}'`
break;
fi
let "count+=1"
done
}
#
# Verify the memory is sufficient for the configuration
#
check_mem()
{
memory=`cat /proc/meminfo | grep MemTotal | awk 'BEGIN {FS=" "} {print $2}'`
if [ "$vm_personality" == "O" ]; then
mem_needed=$od_mem
elif [ "$vm_personality" == "DC" ]; then
mem_needed=$oc_mem
elif [ "$vm_personality" == "D" ]; then
mem_needed=$o_mem
elif [ "$vm_personality" == "ODC" ]; then
mem_needed=$odoc_mem
elif [ "$vm_personality" == "DCD" ]; then
mem_needed=$oco_mem
fi
if [ "$memory" -lt "$mem_needed" ]; then
echo """
$vm_personality configurations require at least $mem_needed (have $memory).
Please shutdown the VM and reconfigure its memory
"""
exit
fi
}
echo """
This script configures the local.conf for the
VM, based on the desired configuration. The
VM can take on any of the following roles:
O: OpenDaylight Controller.
In this role, the VM is only responsible
for running the OpenDaylight Controller
DC: DevStack Controller.
In this role, the VM is only responsible
for running the DevStack controller.
D: DevStack Compute. In this role,
the VM is only responsible for
running the DevStack compute.
ODC: OpenDaylight Controller with DevStack Controller.
In this role, the VM runs both the OpenDaylight
controller and the DevStack controller. The
OpenDaylight controller is launched by DevStack.
DCD: DevStack Controller with DevStack Compute.
In this role, the VM acts as both an DevStack
controller and compute node.
"""
echo -n "Enter VM's personality [$vm_personality]: "
read -a entry
if [ "$entry" == "" ]; then
entry=$vm_personality
else
vm_personality=$entry
fi
if [ "$vm_personality" != "O" ] &&
[ "$vm_personality" != "DC" ] &&
[ "$vm_personality" != "D" ] &&
[ "$vm_personality" != "ODC" ] &&
[ "$vm_personality" != "DCD" ]; then
echo "$vm_personality is invalid"
exit;
fi
# For all nodes, run the memory check to make
# sure they've allocated enough memory to
# run the system.
check_mem
# Get the right IP
select_host_ip
service_host=$host_ip
service_host_name=$host_name
# For a combined ODL/DS coontroller, we still need
# to add in the services
if [ "$vm_personality" == "ODC" ]; then
services="$services $ds_controller_services odl-server"
fi
# For all pure DS nodes (no ODL -- DS controller, compute, or both),
# we need to point it to the ODL Controller
if [ "$vm_personality" == "D" ] ||
[ "$vm_personality" == "DC" ] ||
[ "$vm_personality" == "DCD" ]; then
services="$services $ds_controller_services"
service_host=$host_ip
service_host_name=$host_name
echo """
DevStack nodes need to point to the OpenDaylight Controller.
Please provide the IP address of the OpenDaylight Controller.
"""
echo -n "OpenDaylight Controller IP: "
read -a odl_ip
fi
#
# For DS Compute Only, we need to point it to
# the DS Controller and update the DS services
if [ "$vm_personality" == "D" ]; then
services="$services $ds_compute_services"
echo """
DevStack Compute nodes need to point to the DevStack
Controller. Please provide the IP address and hostname
of the DevStack Controller
"""
echo -n "DevStack Controller IP: "
read -a service_host
echo -n "DevStack Controller hostname: "
read -a service_host_name
if [ "$service_host_name" == "$host_name" ]; then
echo """
Note: You have configured the DevStack controller's
with the same name as this host. If this host
requires a name change, run the set_hostname.sh
script before running this one.
"""
fi
echo """
DevStack Compute nodes also need to point to the
OpenDaylight Controller. Please provide the IP address
of the OpenDaylight Controller
"""
# for DS compute, keep track of service host
host_list=$service_host_name
fi
######
# Generate local.conf, using parameters
######
echo "[[local|localrc]]" > local.conf
#
# Header
#
echo -e $header | while read -r line
do
echo -e $line >> local.conf
done
#
# Services
#
# disable all services for compute only nodes
if [ "$vm_personality" == "D" ]; then
echo "disable_all_services" >> local.conf
fi
for line in $disabled_services
do
echo "disable_service $line" >> local.conf
done
for line in $services
do
echo -e "enable_service $line" >> local.conf
done
echo -e "\n" >> local.conf
#
# Add in VM-specific parameters
#
echo "HOST_IP=$host_ip" >> local.conf
echo "HOST_NAME=$host_name" >> local.conf
echo "SERVICE_HOST=$service_host" >> local.conf
echo "SERVICE_HOST_NAME=$service_host_name" >> local.conf
if [ "$vm_personality" != "O" ] &&
[ "$vm_personality" != "ODC" ]; then
echo "ODL_MGR_IP=$odl_ip" >> local.conf
fi
#
# Footer
#
echo -e $footer | while read -r line
do
echo -e $line >> local.conf
done
if [ "$host_list" != "" ]; then
echo "*********************************************************"
echo "===========>>>> Be sure to add $host_list to /etc/hosts!"
echo "*********************************************************"
fi