Set status to Paused, with informational message on how to undo.
This commit is contained in:
parent
b46fd66f00
commit
71afac4c78
|
@ -6,7 +6,7 @@ import sys
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from charmhelpers.core.host import service_pause
|
from charmhelpers.core.host import service_pause
|
||||||
from charmhelpers.core.hookenv import action_fail
|
from charmhelpers.core.hookenv import action_fail, status_set
|
||||||
|
|
||||||
from lib.swift_storage_utils import SWIFT_SVCS
|
from lib.swift_storage_utils import SWIFT_SVCS
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ def pause(args):
|
||||||
stopped = service_pause(service)
|
stopped = service_pause(service)
|
||||||
if not stopped:
|
if not stopped:
|
||||||
raise Exception("{} didn't stop cleanly.".format(service))
|
raise Exception("{} didn't stop cleanly.".format(service))
|
||||||
|
status_set(
|
||||||
|
"maintenance", "Paused. Use 'resume' action to resume normal service.")
|
||||||
|
|
||||||
|
|
||||||
# A dictionary of all the defined actions to callables (which take
|
# A dictionary of all the defined actions to callables (which take
|
||||||
|
|
|
@ -13,7 +13,8 @@ import actions.actions
|
||||||
class PauseTestCase(CharmTestCase):
|
class PauseTestCase(CharmTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(PauseTestCase, self).setUp(actions.actions, ["service_pause"])
|
super(PauseTestCase, self).setUp(
|
||||||
|
actions.actions, ["service_pause", "status_set"])
|
||||||
|
|
||||||
def test_pauses_services(self):
|
def test_pauses_services(self):
|
||||||
"""Pause action pauses all of the Swift services."""
|
"""Pause action pauses all of the Swift services."""
|
||||||
|
@ -59,6 +60,26 @@ class PauseTestCase(CharmTestCase):
|
||||||
'swift-account-replicator',
|
'swift-account-replicator',
|
||||||
'swift-account-server'])
|
'swift-account-server'])
|
||||||
|
|
||||||
|
def test_status_mode(self):
|
||||||
|
"""Pause action sets the status to maintenance."""
|
||||||
|
status_calls = []
|
||||||
|
self.status_set.side_effect = lambda state, msg: status_calls.append(
|
||||||
|
state)
|
||||||
|
|
||||||
|
actions.actions.pause([])
|
||||||
|
self.assertEqual(status_calls, ["maintenance"])
|
||||||
|
|
||||||
|
def test_status_message(self):
|
||||||
|
"""Pause action sets a status message reflecting that it's paused."""
|
||||||
|
status_calls = []
|
||||||
|
self.status_set.side_effect = lambda state, msg: status_calls.append(
|
||||||
|
msg)
|
||||||
|
|
||||||
|
actions.actions.pause([])
|
||||||
|
self.assertEqual(
|
||||||
|
status_calls, ["Paused. "
|
||||||
|
"Use 'resume' action to resume normal service."])
|
||||||
|
|
||||||
|
|
||||||
class GetActionParserTestCase(unittest.TestCase):
|
class GetActionParserTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue