Set status to Paused, with informational message on how to undo.

This commit is contained in:
Adam Collard 2015-08-11 09:28:36 +01:00
parent b46fd66f00
commit 71afac4c78
2 changed files with 25 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import sys
import yaml
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
@ -29,6 +29,8 @@ def pause(args):
stopped = service_pause(service)
if not stopped:
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

View File

@ -13,7 +13,8 @@ import actions.actions
class PauseTestCase(CharmTestCase):
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):
"""Pause action pauses all of the Swift services."""
@ -59,6 +60,26 @@ class PauseTestCase(CharmTestCase):
'swift-account-replicator',
'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):