Pause/Resume methods can be called by actions.
Add pause and resume methods which can be called by charm actions. Change-Id: I91a1bfe1cb58abbb401356a14cb3725eaefc1138
This commit is contained in:
parent
fd9f94789d
commit
7e026dd1df
|
@ -170,6 +170,24 @@ class OpenStackCharm(BaseOpenStackCharm,
|
||||||
version = os_utils.os_release(self.version_package)
|
version = os_utils.os_release(self.version_package)
|
||||||
return version
|
return version
|
||||||
|
|
||||||
|
def run_pause_or_resume(self, action):
|
||||||
|
"""Helper to enable pause/resume action to be processed."""
|
||||||
|
actions = {
|
||||||
|
'pause': os_utils.pause_unit,
|
||||||
|
'resume': os_utils.resume_unit}
|
||||||
|
pause_services = self.services
|
||||||
|
if self.haproxy_enabled():
|
||||||
|
pause_services.append('haproxy')
|
||||||
|
actions[action](self.assess_status, services=pause_services)
|
||||||
|
|
||||||
|
def pause(self):
|
||||||
|
"""Pause the charms services."""
|
||||||
|
self.run_pause_or_resume('pause')
|
||||||
|
|
||||||
|
def resume(self):
|
||||||
|
"""Resume the charms services."""
|
||||||
|
self.run_pause_or_resume('resume')
|
||||||
|
|
||||||
|
|
||||||
class OpenStackAPICharm(OpenStackCharm):
|
class OpenStackAPICharm(OpenStackCharm):
|
||||||
"""The base class for API OS charms -- this just bakes in the default
|
"""The base class for API OS charms -- this just bakes in the default
|
||||||
|
|
Loading…
Reference in New Issue