4
CHARM="openstack-dashboard"
6
PACKAGES="openstack-dashboard python-keystoneclient python-memcache memcached haproxy python-novaclient"
7
LOCAL_SETTINGS="/etc/openstack-dashboard/local_settings.py"
8
HOOKS_DIR="$CHARM_DIR/hooks"
10
if [[ -e "$HOOKS_DIR/lib/openstack-common" ]] ; then
11
. $HOOKS_DIR/lib/openstack-common
13
juju-log "ERROR: Couldn't load $HOOKS_DIR/lib/openstack-common." && exit 1
17
# set a key = value option in $LOCAL_SETTINGS
19
[[ -z "$key" ]] || [[ -z "$value" ]] &&
20
juju-log "$CHARM set_or_update: ERROR - missing parameters" && return 1
21
if [ "$value" == "True" ] || [ "$value" == "False" ]; then
22
grep -q "^$key = $value" "$LOCAL_SETTINGS" &&
23
juju-log "$CHARM set_or_update: $key = $value already set" && return 0
25
grep -q "^$key = \"$value\"" "$LOCAL_SETTINGS" &&
26
juju-log "$CHARM set_or_update: $key = $value already set" && return 0
28
if grep -q "^$key = " "$LOCAL_SETTINGS" ; then
29
juju-log "$CHARM set_or_update: Setting $key = $value"
30
cp "$LOCAL_SETTINGS" /etc/openstack-dashboard/local_settings.last
31
if [ "$value" == "True" ] || [ "$value" == "False" ]; then
32
sed -i "s|\(^$key = \).*|\1$value|g" "$LOCAL_SETTINGS" || return 1
34
sed -i "s|\(^$key = \).*|\1\"$value\"|g" "$LOCAL_SETTINGS" || return 1
37
juju-log "$CHARM set_or_update: Adding $key = $value"
38
if [ "$value" == "True" ] || [ "$value" == "False" ]; then
39
echo "$key = $value" >>$LOCAL_SETTINGS || return 1
41
echo "$key = \"$value\"" >>$LOCAL_SETTINGS || return 1
47
do_openstack_upgrade() {
52
# Setup apt repository access and kick off the actual package upgrade.
53
configure_install_source "$rel"
55
DEBIAN_FRONTEND=noninteractive apt-get --option Dpkg::Options::=--force-confnew -y \
58
# Configure new config files for access to keystone, if a relation exists.
59
r_id=$(relation-ids identity-service | head -n1)
60
if [[ -n "$r_id" ]] ; then
61
export JUJU_REMOTE_UNIT=$(relation-list -r $r_id | head -n1)
62
export JUJU_RELATION="identity-service"
63
export JUJU_RELATION_ID="$r_id"
64
local service_host=$(relation-get -r $r_id service_host)
65
local service_port=$(relation-get -r $r_id service_port)
66
if [[ -n "$service_host" ]] && [[ -n "$service_port" ]] ; then
67
service_url="http://$service_host:$service_port/v2.0"
68
set_or_update OPENSTACK_KEYSTONE_URL "$service_url"
74
# Reconfigure to listen on provided port
75
a2ensite default-ssl || :
78
from_port=$(echo $ports | cut -d : -f 1)
79
to_port=$(echo $ports | cut -d : -f 2)
80
sed -i -e "s/$from_port/$to_port/g" /etc/apache2/ports.conf
81
for site in $(ls -1 /etc/apache2/sites-available); do
82
sed -i -e "s/$from_port/$to_port/g" \
83
/etc/apache2/sites-available/$site
88
configure_apache_cert() {
91
echo $cert | base64 -di > /etc/ssl/certs/dashboard.cert
92
echo $key | base64 -di > /etc/ssl/private/dashboard.key
93
chmod 0600 /etc/ssl/private/dashboard.key
94
sed -i -e "s|\(.*SSLCertificateFile\).*|\1 /etc/ssl/certs/dashboard.cert|g" \
95
-e "s|\(.*SSLCertificateKeyFile\).*|\1 /etc/ssl/private/dashboard.key|g" \
96
/etc/apache2/sites-available/default-ssl