~openstack-charm-sync/charms/trusty/keystone/next

« back to all changes in this revision

Viewing changes to hooks/keystone_utils.py

  • Committer: David Ames
  • Date: 2016-01-19 16:54:03 UTC
  • mfrom: (196.3.2 trunk)
  • Revision ID: david.ames@canonical.com-20160119165403-dr8gd3jr6qxbj86e
[tinwood,r=thedac] Fixes Bug#1526511  change pause/resume actions use (new) assess_status()

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
    INFO,
84
84
    WARNING,
85
85
    status_get,
 
86
    status_set,
86
87
)
87
88
 
88
89
from charmhelpers.fetch import (
116
117
import keystone_context
117
118
import keystone_ssl as ssl
118
119
 
 
120
from charmhelpers.core.unitdata import (
 
121
    HookData,
 
122
    kv,
 
123
)
 
124
 
 
125
 
119
126
TEMPLATES = 'templates/'
120
127
 
121
128
# removed from original: charm-helper-sh
1829
1836
        return status_get()
1830
1837
    else:
1831
1838
        return 'unknown', 'No optional relations'
 
1839
 
 
1840
 
 
1841
def is_paused(status_get=status_get):
 
1842
    """Is the unit paused?"""
 
1843
    with HookData()():
 
1844
        if kv().get('unit-paused'):
 
1845
            return True
 
1846
        else:
 
1847
            return False
 
1848
 
 
1849
 
 
1850
def assess_status(configs):
 
1851
    """Assess status of current unit
 
1852
 
 
1853
    Decides what the state of the unit should be based on the current
 
1854
    configuration.
 
1855
 
 
1856
    @param configs: a templating.OSConfigRenderer() object
 
1857
    """
 
1858
 
 
1859
    if is_paused():
 
1860
        status_set("maintenance",
 
1861
                   "Paused. Use 'resume' action to resume normal service.")
 
1862
        return
 
1863
 
 
1864
    # set the status according to the current state of the contexts
 
1865
    set_os_workload_status(
 
1866
        configs, REQUIRED_INTERFACES, charm_func=check_optional_relations)