Merge "Minor comment corrections"
diff --git a/functions b/functions
index 2aab3cd..f5032d5 100644
--- a/functions
+++ b/functions
@@ -271,6 +271,8 @@
if [[ $? -eq 0 ]]; then
os_VENDOR="openSUSE"
fi
+ elif [[ $os_VENDOR == "openSUSE project" ]]; then
+ os_VENDOR="openSUSE"
elif [[ $os_VENDOR =~ Red.*Hat ]]; then
os_VENDOR="Red Hat"
fi
@@ -553,6 +555,56 @@
fi
}
+# Get a multiple line option from an INI file
+# iniget_multiline config-file section option
+function iniget_multiline() {
+ local file=$1
+ local section=$2
+ local option=$3
+ local values
+ values=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { s/^$option[ \t]*=[ \t]*//gp; }" "$file")
+ echo ${values}
+}
+
+# Set a multiple line option in an INI file
+# iniset_multiline config-file section option value1 value2 valu3 ...
+function iniset_multiline() {
+ local file=$1
+ local section=$2
+ local option=$3
+ shift 3
+ local values
+ for v in $@; do
+ # The later sed command inserts each new value in the line next to
+ # the section identifier, which causes the values to be inserted in
+ # the reverse order. Do a reverse here to keep the original order.
+ values="$v ${values}"
+ done
+ if ! grep -q "^\[$section\]" "$file"; then
+ # Add section at the end
+ echo -e "\n[$section]" >>"$file"
+ else
+ # Remove old values
+ sed -i -e "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ d; }" "$file"
+ fi
+ # Add new ones
+ for v in $values; do
+ sed -i -e "/^\[$section\]/ a\\
+$option = $v
+" "$file"
+ done
+}
+
+# Append a new option in an ini file without replacing the old value
+# iniadd config-file section option value1 value2 value3 ...
+function iniadd() {
+ local file=$1
+ local section=$2
+ local option=$3
+ shift 3
+ local values="$(iniget_multiline $file $section $option) $@"
+ iniset_multiline $file $section $option $values
+}
# is_service_enabled() checks if the service(s) specified as arguments are
# enabled by the user in ``ENABLED_SERVICES``.
diff --git a/lib/horizon b/lib/horizon
index 9180370..9c96b58 100644
--- a/lib/horizon
+++ b/lib/horizon
@@ -34,6 +34,24 @@
APACHE_USER=${APACHE_USER:-$USER}
APACHE_GROUP=${APACHE_GROUP:-$(id -gn $APACHE_USER)}
+# utility method of setting python option
+function _horizon_config_set() {
+ local file=$1
+ local section=$2
+ local option=$3
+ local value=$4
+
+ if grep -q "^$section" $file; then
+ line=$(sed -ne "/^$section/,/^}/ { /^ *'$option':/ p; }" $file)
+ if [ -n "$line" ]; then
+ sed -i -e "/^$section/,/^}/ s/^\( *'$option'\) *:.*$/\1: $value,/" $file
+ else
+ sed -i -e "/^$section/ a\n '$option': $value,\n" $file
+ fi
+ else
+ echo -e "\n\n$section = {\n '$option': $value,\n}" >> $file
+ fi
+}
# Entry Points
# ------------
@@ -61,6 +79,11 @@
local_settings=$HORIZON_DIR/openstack_dashboard/local/local_settings.py
cp $FILES/horizon_settings.py $local_settings
+ # enable loadbalancer dashboard in case service is enabled
+ if is_service_enabled q-lbaas; then
+ _horizon_config_set $local_settings OPENSTACK_QUANTUM_NETWORK enable_lb True
+ fi
+
# Initialize the horizon database (it stores sessions and notices shown to
# users). The user system is external (keystone).
cd $HORIZON_DIR
diff --git a/lib/nova b/lib/nova
index 42b6139..13e20f8 100644
--- a/lib/nova
+++ b/lib/nova
@@ -425,8 +425,7 @@
if is_service_enabled ceilometer; then
iniset $NOVA_CONF DEFAULT instance_usage_audit "True"
iniset $NOVA_CONF DEFAULT instance_usage_audit_period "hour"
- iniset $NOVA_CONF DEFAULT notification_driver "nova.openstack.common.notifier.rpc_notifier"
- iniset $NOVA_CONF DEFAULT notification_driver "ceilometer.compute.nova_notifier"
+ iniset_multiline $NOVA_CONF DEFAULT notification_driver "nova.openstack.common.notifier.rpc_notifier" "ceilometer.compute.nova_notifier"
fi
diff --git a/stack.sh b/stack.sh
index 0f5401a..c39d855 100755
--- a/stack.sh
+++ b/stack.sh
@@ -524,9 +524,9 @@
# as the template to search for, appending '.*' to match the date
# we added on earlier runs.
LOGDIR=$(dirname "$LOGFILE")
- LOGNAME=$(basename "$LOGFILE")
+ LOGFILENAME=$(basename "$LOGFILE")
mkdir -p $LOGDIR
- find $LOGDIR -maxdepth 1 -name $LOGNAME.\* -mtime +$LOGDAYS -exec rm {} \;
+ find $LOGDIR -maxdepth 1 -name $LOGFILENAME.\* -mtime +$LOGDAYS -exec rm {} \;
LOGFILE=$LOGFILE.${CURRENT_LOG_TIME}
SUMFILE=$LOGFILE.${CURRENT_LOG_TIME}.summary
@@ -556,8 +556,8 @@
echo_summary "stack.sh log $LOGFILE"
# Specified logfile name always links to the most recent log
- ln -sf $LOGFILE $LOGDIR/$LOGNAME
- ln -sf $SUMFILE $LOGDIR/$LOGNAME.summary
+ ln -sf $LOGFILE $LOGDIR/$LOGFILENAME
+ ln -sf $SUMFILE $LOGDIR/$LOGFILENAME.summary
else
# Set up output redirection without log files
# Copy stdout to fd 3
diff --git a/tests/functions.sh b/tests/functions.sh
index 4fe6443..27a6cfe 100755
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -60,6 +60,10 @@
[ddd]
empty =
+
+[eee]
+multi = foo1
+multi = foo2
EOF
# Test with spaces
@@ -193,6 +197,34 @@
echo "inicomment failed: $VAL"
fi
+# Test multiple line iniset/iniget
+iniset_multiline test.ini eee multi bar1 bar2
+
+VAL=$(iniget_multiline test.ini eee multi)
+if [[ "$VAL" == "bar1 bar2" ]]; then
+ echo "OK: iniset_multiline"
+else
+ echo "iniset_multiline failed: $VAL"
+fi
+
+# Test iniadd with exiting values
+iniadd test.ini eee multi bar3
+VAL=$(iniget_multiline test.ini eee multi)
+if [[ "$VAL" == "bar1 bar2 bar3" ]]; then
+ echo "OK: iniadd"
+else
+ echo "iniadd failed: $VAL"
+fi
+
+# Test iniadd with non-exiting values
+iniadd test.ini eee non-multi foobar1 foobar2
+VAL=$(iniget_multiline test.ini eee non-multi)
+if [[ "$VAL" == "foobar1 foobar2" ]]; then
+ echo "OK: iniadd with non-exiting value"
+else
+ echo "iniadd with non-exsting failed: $VAL"
+fi
+
rm test.ini
# Enabling/disabling services