~admcleod/charms/trusty/apache-hadoop-hdfs-secondary/hadoop-upgrade

« back to all changes in this revision

Viewing changes to hooks/callbacks.py

bundle resources into charm for ease of install; add extended status messages; use updated java-installer.sh that ensures java is on the path

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 NameNodeMaster
 
22
 
 
23
 
 
24
def update_blocked_status():
 
25
    if unitdata.kv().get('charm.active', False):
 
26
        return
 
27
    if NameNodeMaster(relation_name='secondary').connected_units():
 
28
        hookenv.status_set('waiting', 'Waiting for HDFS master to provide primary NameNode'),
 
29
    else:
 
30
        hookenv.status_set('blocked', 'Waiting for relation to HDFS master'),
 
31
 
 
32
 
 
33
def update_working_status():
 
34
    if unitdata.kv().get('charm.active', False):
 
35
        hookenv.status_set('maintenance', 'Updating configuration')
 
36
        return
 
37
    hookenv.status_set('maintenance', 'Setting up Secondary NameNode')
 
38
 
 
39
 
 
40
def update_active_status():
 
41
    unitdata.kv().set('charm.active', True)
 
42
    hookenv.status_set('active', 'Ready')