Add support for custom status checks
This commit is contained in:
parent
bef6f2161b
commit
3e0e41f403
|
@ -71,6 +71,9 @@ class OSBaseCharm(CharmBase):
|
||||||
apt_install(self.PACKAGES, fatal=True)
|
apt_install(self.PACKAGES, fatal=True)
|
||||||
self.update_status()
|
self.update_status()
|
||||||
|
|
||||||
|
def custom_status_check(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def update_status(self):
|
def update_status(self):
|
||||||
logging.info("Updating status")
|
logging.info("Updating status")
|
||||||
if self.state.series_upgrade:
|
if self.state.series_upgrade:
|
||||||
|
@ -90,6 +93,13 @@ class OSBaseCharm(CharmBase):
|
||||||
self.unit.status = BlockedStatus(
|
self.unit.status = BlockedStatus(
|
||||||
'Missing relations: {}'.format(', '.join(missing_relations)))
|
'Missing relations: {}'.format(', '.join(missing_relations)))
|
||||||
return
|
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:
|
if self.state.is_started:
|
||||||
self.unit.status = ActiveStatus('Unit is ready')
|
self.unit.status = ActiveStatus('Unit is ready')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue