206
206
# adding (or removing) nodes
207
for NEWNODE in ${NEWNODES} ; do
208
# remove is simpler: just remove the node name
209
if [ "$NODEMODE" = "REM" ]; then
210
- if ! echo "$NODES"|grep "${NEWNODE}" > /dev/null ; then
211
+ if ! xsearch "$NEWNODE" "$NODES"; then
212
echo "Node ${NEWNODE} is not known"
215
NODES="`echo $NODES|sed \"s/${NEWNODE}//\"|tr -s ' '`"
216
- change_var_value $FILE NODES "${NODES}"
217
- echo "SUCCESS: removed node '${NEWNODE}' from '$FILE'"
218
+ echo "$NODES" | tr ' ' '\n' | uniq > $EUCALYPTUS/var/lib/eucalyptus/nodes.list
219
+# change_var_value $FILE NODES "${NODES}"
220
+ echo "SUCCESS: removed node '${NEWNODE}'"
224
# let's sync keys with the nodes
225
if ! sync_keys ${SOURCEDIR} ${DESTDIR} ${NEWNODE} node-cert.pem cluster-cert.pem node-pk.pem cloud-cert.pem; then
228
echo "ERROR: could not synchronize keys with $NEWNODE!"
229
echo "The configuration will not have this node."
230
@@ -1394,10 +1449,11 @@
234
- if ! echo "${NODES}"|grep "${NEWNODE}" > /dev/null ; then
235
+ if ! xsearch "$NEWNODE" "$NODES"; then
236
# node is not present: we need to add it
237
NODES="${NODES} $NEWNODE"
238
- change_var_value $FILE NODES "${NODES}"
239
+ echo "$NODES" | tr ' ' '\n' | uniq > $EUCALYPTUS/var/lib/eucalyptus/nodes.list
240
+ # change_var_value $FILE NODES "${NODES}"
207
@@ -1388,13 +1441,14 @@
209
NEW_NODES="$x $NEW_NODES"
211
- change_var_value $FILE NODES "${NEW_NODES}"
212
+ echo "$NODES" | tr ' ' '\n' | uniq > $EUCALYPTUS/var/lib/eucalyptus/nodes.list
213
echo "SUCCESS: removed node '${NEWNODE}' from '$FILE'"
217
# let's sync keys with the nodes
218
if ! sync_keys ${SOURCEDIR} ${DESTDIR} ${NEWNODE} node-cert.pem cluster-cert.pem node-pk.pem cloud-cert.pem; then
221
echo "ERROR: could not synchronize keys with $NEWNODE!"
222
echo "The configuration will not have this node."
223
@@ -1420,7 +1474,7 @@
226
NODES="${NODES} $NEWNODE"
227
- change_var_value $FILE NODES "${NODES}"
228
+ echo "$NODES" | tr ' ' '\n' | uniq > $EUCALYPTUS/var/lib/eucalyptus/nodes.list
244
@@ -1474,3 +1530,5 @@
232
@@ -1497,3 +1551,5 @@
245
233
[ $to_start = "Y" ] && echo $x
246
234
done | sort | uniq > $EUCALYPTUS/var/lib/eucalyptus/services
284
272
echo "Database upgrade failed! Please check your database before using Eucalyptus."
275
--- a/util/eucalyptus.h
276
+++ b/util/eucalyptus.h
278
/* file paths relative to $EUCALYPTUS */
279
#define EUCALYPTUS_CONF_LOCATION "%s/etc/eucalyptus/eucalyptus.conf"
280
#define EUCALYPTUS_CONF_OVERRIDE_LOCATION "%s/etc/eucalyptus/eucalyptus.local.conf"
281
+#define NODES_LIST_LOCATION "%s/var/lib/eucalyptus/nodes.list"
282
#define EUCALYPTUS_ROOTWRAP "%s/usr/lib/eucalyptus/euca_rootwrap"
283
#define EUCALYPTUS_ADD_KEY "%s/usr/lib/eucalyptus/euca_rootwrap %s/usr/share/eucalyptus/add_key.pl %s/usr/lib/eucalyptus/euca_mountwrap"
284
#define EUCALYPTUS_GEN_LIBVIRT_XML "%s/usr/lib/eucalyptus/euca_rootwrap %s/usr/share/eucalyptus/gen_libvirt_xml"
285
--- a/cluster/handlers.c
286
+++ b/cluster/handlers.c
287
@@ -2383,7 +2383,7 @@
290
int update_config(void) {
291
- char home[MAX_PATH], *tmpstr=NULL;
292
+ char home[MAX_PATH], *tmpstr=NULL, nodesList[1024];
293
ccResource *res=NULL;
294
int rc, numHosts, ret;
296
@@ -2395,8 +2395,11 @@
301
+ snprintf(nodesList, 1024, NODES_LIST_LOCATION, config->eucahome);
303
+ // stat the config file(s), update modification time
304
for (i=0; i<2; i++) {
305
- // stat the config file, update modification time
306
rc = stat(config->configFiles[i], &statbuf);
308
if (statbuf.st_mtime > configMtime) {
309
@@ -2404,6 +2407,17 @@
314
+ // check the external nodes list file, if it exists
315
+ if (!check_file(nodesList)) {
316
+ rc = stat(nodesList, &statbuf);
318
+ if (statbuf.st_mtime > configMtime) {
319
+ configMtime = statbuf.st_mtime;
324
if (configMtime == 0) {
325
logprintfl(EUCAERROR, "update_config(): could not stat config files (%s,%s)\n", config->configFiles[0], config->configFiles[1]);
327
@@ -2952,10 +2966,13 @@
331
+ char nodesFile[1024];
336
+ snprintf(nodesFile, 1024, NODES_LIST_LOCATION, config->eucahome);
338
tmpstr = getConfString(config->configFiles, 2, CONFIG_NC_SERVICE);
341
@@ -2980,7 +2997,14 @@
343
if (tmpstr) free(tmpstr);
345
- tmpstr = getConfString(config->configFiles, 2, CONFIG_NODES);
346
+ if (!check_file(nodesFile)) {
347
+ // nodesFile exists, read list of nodes from nodesFile
348
+ tmpstr = file2str(nodesFile);
350
+ // otherwise, read NODES="..." from eucalyptus config file(s)
351
+ tmpstr = getConfString(config->configFiles, 2, CONFIG_NODES);
356
logprintfl(EUCAWARN,"refreshNodes(): NODES parameter is missing from config files(%s,%s)\n", config->configFiles[1], config->configFiles[0]);