Install python-apt before hooks run

Previously this charm had relied on python-apt being installed by
the principle. As charms migrate to py3 this is no longer a safe
assumption and actually never was. This change ensures that
python-apt is installed before immediatly. This follows the same
pattern as other charms by adding an install and install.real
files.

Change-Id: I9fe2a031df736b867d4f277448a4d8649fa8de64
This commit is contained in:
Liam Young 2017-11-24 09:21:44 +00:00
parent c744a97fb4
commit d73568eb13
3 changed files with 20 additions and 2 deletions

View File

@ -52,7 +52,7 @@ hooks = Hooks()
CONFIGS = register_configs() CONFIGS = register_configs()
@hooks.hook() @hooks.hook('install.real')
def install(): def install():
origin = config('openstack-origin') origin = config('openstack-origin')
configure_installation_source(origin) configure_installation_source(origin)

View File

@ -1 +0,0 @@
ceilometer_hooks.py

18
hooks/install Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
declare -a DEPS=('apt')
check_and_install() {
pkg="${1}-${2}"
if ! dpkg -s ${pkg} 2>&1 > /dev/null; then
apt-get -y install ${pkg}
fi
}
PYTHON="python"
for dep in ${DEPS[@]}; do
check_and_install ${PYTHON} ${dep}
done
exec ./hooks/install.real

1
hooks/install.real Symbolic link
View File

@ -0,0 +1 @@
ceilometer_hooks.py