Browse Source

Add support for custom status checks

changes/13/749213/1
Liam Young 2 years ago
parent
commit
3e0e41f403
  1. 10
      ops_openstack.py

10
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:

Loading…
Cancel
Save