Trigger upgrades on source change

Ensure that a change to the triliovault-pkg-source option forces
an upgrade of any previously installed packages.

Refactor to use new TrilioVault bases classes from charms.openstack.

Change-Id: I5aff6b787f663addc72e584cb64cead3f47b7d69
Closes-Bug: 1879904
This commit is contained in:
James Page 2020-06-02 16:41:26 +01:00
parent 600a086afe
commit 27d418aa29
2 changed files with 5 additions and 17 deletions

View File

@ -14,11 +14,10 @@
import os
import charmhelpers.core.hookenv as hookenv
import charmhelpers.contrib.openstack.utils as os_utils
import charmhelpers.fetch as fetch
import charms_openstack.charm
import charms_openstack.plugins
# select the default release function
charms_openstack.charm.use_defaults('charm.default-select-release')
@ -27,7 +26,9 @@ HORIZON_PATH = "/usr/share/openstack-dashboard"
MANAGE_PY = os.path.join(HORIZON_PATH, "manage.py")
class TrilioHorizonPluginQueensCharm(charms_openstack.charm.OpenStackCharm):
class TrilioHorizonPluginQueensCharm(
charms_openstack.plugins.TrilioVaultSubordinateCharm
):
service_name = name = "trilio-horizon-plugin"
@ -45,24 +46,10 @@ class TrilioHorizonPluginQueensCharm(charms_openstack.charm.OpenStackCharm):
release_pkg = "openstack-dashboard"
package_codenames = os_utils.PACKAGE_CODENAMES
def configure_source(self):
with open(
"/etc/apt/sources.list.d/" "trilio-gemfury-sources.list", "w"
) as tsources:
tsources.write(hookenv.config("triliovault-pkg-source"))
fetch.apt_update(fatal=True)
@property
def version_package(self):
return self.packages[-1]
def install(self):
self.configure_source()
super().install()
def upgrade_charm(self):
super().upgrade_charm()
class TrilioHorizonPluginCharm(TrilioHorizonPluginQueensCharm):

View File

@ -28,3 +28,4 @@ charm.use_defaults(
def install_source_changed():
"""Trigger re-install of charm if source configuration options change"""
reactive.clear_flag("charm.installed")
reactive.set_flag("upgrade.triliovault")