~1chb1n/charms/trusty/ceilometer/next-amulet-15.10

« back to all changes in this revision

Viewing changes to lib/ceilometer_utils.py

  • Committer: James Page
  • Date: 2015-10-19 16:24:11 UTC
  • mfrom: (102.1.3 ceilometer)
  • Revision ID: james.page@ubuntu.com-20151019162411-6kh2zirfixrkos35
Fixup problems with assessment of unit status when unit is paused via actions

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from charmhelpers.contrib.openstack.utils import (
18
18
    get_os_codename_package,
19
19
    get_os_codename_install_source,
20
 
    configure_installation_source
 
20
    configure_installation_source,
 
21
    set_os_workload_status,
21
22
)
22
 
from charmhelpers.core.hookenv import config, log
 
23
from charmhelpers.core.hookenv import config, log, status_set
 
24
from charmhelpers.core.unitdata import kv
23
25
from charmhelpers.fetch import apt_update, apt_install, apt_upgrade
24
26
from copy import deepcopy
25
27
 
229
231
    """
230
232
    with open(SHARED_SECRET, 'w') as secret_file:
231
233
        secret_file.write(secret)
 
234
 
 
235
 
 
236
def is_paused():
 
237
    '''Determine if current unit is in a paused state'''
 
238
    db = kv()
 
239
    if db.get('unit-paused'):
 
240
        return True
 
241
    else:
 
242
        return False
 
243
 
 
244
 
 
245
def assess_status(configs):
 
246
    if is_paused():
 
247
        status_set("maintenance",
 
248
                   "Unit paused - use 'resume' action "
 
249
                   "to resume normal service")
 
250
        return
 
251
 
 
252
    set_os_workload_status(configs, REQUIRED_INTERFACES)