Merge CONFIG_CHANGED.
This commit is contained in:
@@ -11,6 +11,8 @@ GLANCE_API_CONF="/etc/glance/glance-api.conf"
|
|||||||
GLANCE_API_PASTE_INI="/etc/glance/glance-api-paste.ini"
|
GLANCE_API_PASTE_INI="/etc/glance/glance-api-paste.ini"
|
||||||
CONF_DIR="/etc/glance"
|
CONF_DIR="/etc/glance"
|
||||||
|
|
||||||
|
# Flag used to track config changes.
|
||||||
|
CONFIG_CHANGED="False"
|
||||||
if [[ -e "$CHARM_DIR/lib/openstack-common" ]] ; then
|
if [[ -e "$CHARM_DIR/lib/openstack-common" ]] ; then
|
||||||
. $CHARM_DIR/lib/openstack-common
|
. $CHARM_DIR/lib/openstack-common
|
||||||
else
|
else
|
||||||
@@ -18,6 +20,8 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
function set_paste_deploy_flavor {
|
function set_paste_deploy_flavor {
|
||||||
|
# NOTE(adam_g): If we want to benefit from CONFIG_CHANGED here,
|
||||||
|
# needs to be updated to detect already config'd settings.
|
||||||
local flavor="$1"
|
local flavor="$1"
|
||||||
local config="$2"
|
local config="$2"
|
||||||
case $config in
|
case $config in
|
||||||
@@ -27,12 +31,14 @@ function set_paste_deploy_flavor {
|
|||||||
esac
|
esac
|
||||||
if ! grep -q "\[paste_deploy\]" "$conf" ; then
|
if ! grep -q "\[paste_deploy\]" "$conf" ; then
|
||||||
juju-log "Updating $conf: Setting new paste_deploy flavor = $flavor"
|
juju-log "Updating $conf: Setting new paste_deploy flavor = $flavor"
|
||||||
echo -e "\n[paste_deploy]\nflavor = keystone\n" >>$conf && return 0
|
echo -e "\n[paste_deploy]\nflavor = keystone\n" >>$conf &&
|
||||||
|
CONFIG_CHANGED="True" && return 0
|
||||||
juju-log "ERROR: Could not update paste_deploy flavor in $conf" && return 1
|
juju-log "ERROR: Could not update paste_deploy flavor in $conf" && return 1
|
||||||
fi
|
fi
|
||||||
juju-log "Updating $conf: Setting paste_deploy flavor = $flavor"
|
juju-log "Updating $conf: Setting paste_deploy flavor = $flavor"
|
||||||
local tag="[paste_deploy]"
|
local tag="[paste_deploy]"
|
||||||
sed -i "/$tag/, +1 s/\(flavor = \).*/\1$flavor/g" $conf && return 0
|
sed -i "/$tag/, +1 s/\(flavor = \).*/\1$flavor/g" $conf &&
|
||||||
|
CONFIG_CHANGED="True" && return 0
|
||||||
juju-log "ERROR: Could not update paste_deploy flavor in $conf" && return 1
|
juju-log "ERROR: Could not update paste_deploy flavor in $conf" && return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,12 +83,13 @@ function set_or_update {
|
|||||||
[[ -z $VALUE ]] && juju-log "ERROR: set_or_update(): key $KEY missing value" \
|
[[ -z $VALUE ]] && juju-log "ERROR: set_or_update(): key $KEY missing value" \
|
||||||
&& exit 1
|
&& exit 1
|
||||||
cat $CONF | grep "$KEY = $VALUE" >/dev/null \
|
cat $CONF | grep "$KEY = $VALUE" >/dev/null \
|
||||||
&& juju-log "glance: $KEY = $VALUE already set" exit 0
|
&& juju-log "glance: $KEY = $VALUE already set" && return 0
|
||||||
if cat $CONF | grep "$KEY =" >/dev/null ; then
|
if cat $CONF | grep "$KEY =" >/dev/null ; then
|
||||||
sed -i "s|\($KEY = \).*|\1$VALUE|" $CONF
|
sed -i "s|\($KEY = \).*|\1$VALUE|" $CONF
|
||||||
else
|
else
|
||||||
echo "$KEY = $VALUE" >>$CONF
|
echo "$KEY = $VALUE" >>$CONF
|
||||||
fi
|
fi
|
||||||
|
CONFIG_CHANGED="True"
|
||||||
}
|
}
|
||||||
|
|
||||||
do_openstack_upgrade() {
|
do_openstack_upgrade() {
|
||||||
|
@@ -71,8 +71,6 @@ function db_changed {
|
|||||||
|
|
||||||
juju-log "$CHARM - db_changed: Configuring glance.conf for access to $glance_db"
|
juju-log "$CHARM - db_changed: Configuring glance.conf for access to $glance_db"
|
||||||
|
|
||||||
service_ctl all stop
|
|
||||||
|
|
||||||
set_or_update sql_connection "mysql://$db_user:$db_password@$db_host/$glance_db" registry
|
set_or_update sql_connection "mysql://$db_user:$db_password@$db_host/$glance_db" registry
|
||||||
|
|
||||||
# since folsom, a db connection setting in glance-api.conf is required.
|
# since folsom, a db connection setting in glance-api.conf is required.
|
||||||
|
@@ -20,6 +20,9 @@ function service_ctl_status {
|
|||||||
|
|
||||||
function service_ctl {
|
function service_ctl {
|
||||||
# control a specific service, or all (as defined by $SERVICES)
|
# control a specific service, or all (as defined by $SERVICES)
|
||||||
|
# service restarts will only occur depending on global $CONFIG_CHANGED,
|
||||||
|
# which should be updated in charm's set_or_update().
|
||||||
|
local config_changed=${CONFIG_CHANGED:-True}
|
||||||
if [[ $1 == "all" ]] ; then
|
if [[ $1 == "all" ]] ; then
|
||||||
ctl="$SERVICES"
|
ctl="$SERVICES"
|
||||||
else
|
else
|
||||||
@@ -37,12 +40,21 @@ function service_ctl {
|
|||||||
"stop")
|
"stop")
|
||||||
service_ctl_status $i && service $i stop || return 0 ;;
|
service_ctl_status $i && service $i stop || return 0 ;;
|
||||||
"restart")
|
"restart")
|
||||||
service_ctl_status $i && service $i restart || service $i start ;;
|
if [[ "$config_changed" == "True" ]] ; then
|
||||||
|
service_ctl_status $i && service $i restart || service $i start
|
||||||
|
fi
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
if [[ $? != 0 ]] ; then
|
if [[ $? != 0 ]] ; then
|
||||||
juju-log "$CHARM: service_ctl ERROR - Service $i failed to $action"
|
juju-log "$CHARM: service_ctl ERROR - Service $i failed to $action"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
# all configs should have been reloaded on restart of all services, reset
|
||||||
|
# flag if its being used.
|
||||||
|
if [[ "$action" == "restart" ]] && [[ -n "$CONFIG_CHANGED" ]] &&
|
||||||
|
[[ "$ctl" == "all" ]]; then
|
||||||
|
CONFIG_CHANGED="False"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_install_source {
|
function configure_install_source {
|
||||||
|
Reference in New Issue
Block a user