Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
#8: Add support for Xenial and status
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoceppi committed Jan 9, 2017
1 parent bd7565c commit 650082b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hooks/config-changed
Expand Up @@ -16,11 +16,13 @@ from charmhelpers.fetch import (
apt_update,
apt_install
)
from charmhelpers.core.hookenv import relations_of_type
from charmhelpers.core.hookenv import relations_of_type, status_set
from charmhelpers.core.host import mkdir, rsync
from charmhelpers.core.templating import render


status_set('maintenance', 'Configuring MySQL')

# Add archive source if provided
add_source(utils.config_get('source'), utils.config_get('key'))
apt_update()
Expand Down Expand Up @@ -118,7 +120,7 @@ if os.path.isfile(ROOT_PASSFILE):
PASSFILE = ROOT_PASSFILE
else:
PASSFILE = VAR_PASSFILE

with open(PASSFILE,'r') as rpw:
root_pass = rpw.read()

Expand Down Expand Up @@ -426,3 +428,5 @@ else:
for path in ["/etc/cron.d/mysql_backup", "/usr/local/bin/mysql_backup.sh"]:
if os.path.exists(path):
os.unlink(path)

status_set('active', 'Ready')
4 changes: 4 additions & 0 deletions hooks/install.real
Expand Up @@ -11,7 +11,10 @@ from charmhelpers.fetch import (
add_source
)

from charmhelpers.core import hookenv


hookenv.status_set('maintenance', 'Setting up additional sources')
# Add archive source of provided
add_source(utils.config_get('source'), utils.config_get('key'))
apt_update()
Expand All @@ -31,6 +34,7 @@ if os.path.isdir('exec.d'):
# Update again in case any pre-exec script(s) modified sources.
apt_update()

hookenv.status_set('maintenance', 'Installing support packages')
apt_install(['debconf-utils', 'python-mysqldb', 'uuid', 'pwgen', 'dnsutils'])

ROOT_PASSFILE = os.path.join('/root', 'mysql.passwd')
Expand Down
6 changes: 6 additions & 0 deletions hooks/start
Expand Up @@ -4,3 +4,9 @@ set -e

service mysql restart
open-port 3306

version=$(mysql --version|awk '{ print $5 }'|awk -F\, '{ print $1 }')

application-version-set $version || true

status-set active Ready
3 changes: 3 additions & 0 deletions hooks/upgrade-charm
Expand Up @@ -27,3 +27,6 @@ $home/install
exec $home/config-changed

open-port 3306

version=$(mysql --version|awk '{ print $5 }'|awk -F\, '{ print $1 }')
application-version-set $version || true
1 change: 1 addition & 0 deletions metadata.yaml
Expand Up @@ -10,6 +10,7 @@ tags:
- databases
- openstack
series:
- xenial
- trusty
- precise
provides:
Expand Down

0 comments on commit 650082b

Please sign in to comment.