~bigdata-dev/charms/trusty/apache-hadoop-hdfs-master/smoke-test

« back to all changes in this revision

Viewing changes to hooks/callbacks.py

  • Committer: Cory Johns
  • Date: 2015-06-25 15:38:21 UTC
  • Revision ID: cory.johns@canonical.com-20150625153821-eq58qc25v1wt2uzf
Added extended status support

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
Add any additional tasks / setup here.  If a callback is used by mutliple
16
16
charms, consider refactoring it up to the jujubigdata library.
17
17
"""
 
18
 
 
19
from charmhelpers.core import hookenv
 
20
from charmhelpers.core import unitdata
 
21
from jujubigdata.relations import DataNode
 
22
 
 
23
 
 
24
def update_working_status():
 
25
    if unitdata.kv().get('charm.active', False):
 
26
        hookenv.status_set('maintenance', 'Updating configuration')
 
27
        return
 
28
    hookenv.status_set('maintenance', 'Setting up HDFS master')
 
29
 
 
30
 
 
31
def update_active_status():
 
32
    datanode = DataNode()
 
33
    if datanode.is_ready():
 
34
        hookenv.status_set('active', 'Ready (%s DataNodes)' % len(datanode.filtered_data()))
 
35
        unitdata.kv().set('charm.active', True)
 
36
    elif datanode.connected_units():
 
37
        hookenv.status_set('waiting', 'Waiting for compute slaves to provide DataNodes')
 
38
    else:
 
39
        hookenv.status_set('blocked', 'Waiting for relation to compute slaves')