From 3e0e41f403734ca1db7c9404da5239b0301704a1 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Tue, 14 Apr 2020 08:59:31 +0000 Subject: [PATCH] Add support for custom status checks --- ops_openstack.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ops_openstack.py b/ops_openstack.py index eac3ea2..e8f1ddf 100644 --- a/ops_openstack.py +++ b/ops_openstack.py @@ -71,6 +71,9 @@ class OSBaseCharm(CharmBase): apt_install(self.PACKAGES, fatal=True) self.update_status() + def custom_status_check(self): + raise NotImplementedError + def update_status(self): logging.info("Updating status") if self.state.series_upgrade: @@ -90,6 +93,13 @@ class OSBaseCharm(CharmBase): self.unit.status = BlockedStatus( 'Missing relations: {}'.format(', '.join(missing_relations))) return + try: + # Custom checks return True if the checked passed else False. + # If the check failed the custom check will have set the status. + if not self.custom_status_check(): + return + except NotImplementedError: + pass if self.state.is_started: self.unit.status = ActiveStatus('Unit is ready') else: