~hopem/charms/trusty/swift-proxy/self-healing-cluster-sync

« back to all changes in this revision

Viewing changes to actions/actions.py

  • Committer: Edward Hope-Morley
  • Date: 2016-01-12 12:12:12 UTC
  • mfrom: (95.1.38 swift-proxy)
  • Revision ID: edward.hope-morley@canonical.com-20160112121212-ws31fznkuo9t4dpw
synced /next

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import sys
6
6
import yaml
7
7
 
 
8
sys.path.append('hooks/')
 
9
 
8
10
from charmhelpers.core.host import service_pause, service_resume
9
 
from charmhelpers.core.hookenv import action_fail, status_set
10
 
 
11
 
from lib.swift_utils import services
 
11
from charmhelpers.core.hookenv import action_fail
 
12
from charmhelpers.core.unitdata import HookData, kv
 
13
from lib.swift_utils import assess_status, services
 
14
from swift_hooks import CONFIGS
12
15
 
13
16
 
14
17
def get_action_parser(actions_yaml_path, action_name,
31
34
        stopped = service_pause(service)
32
35
        if not stopped:
33
36
            raise Exception("{} didn't stop cleanly.".format(service))
34
 
    status_set(
35
 
        "maintenance", "Paused. Use 'resume' action to resume normal service.")
 
37
    with HookData()():
 
38
        kv().set('unit-paused', True)
 
39
    assess_status(CONFIGS)
36
40
 
37
41
 
38
42
def resume(args):
44
48
        started = service_resume(service)
45
49
        if not started:
46
50
            raise Exception("{} didn't start cleanly.".format(service))
47
 
    status_set("active", "")
 
51
    with HookData()():
 
52
        kv().set('unit-paused', False)
 
53
    assess_status(CONFIGS)
48
54
 
49
55
 
50
56
# A dictionary of all the defined actions to callables (which take