Merge lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-secondary/status into lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-secondary/trunk

Proposed by Cory Johns
Status: Merged
Merged at revision: 67
Proposed branch: lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-secondary/status
Merge into: lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-secondary/trunk
Diff against target: 284 lines (+108/-26)
9 files modified
hooks/callbacks.py (+25/-0)
hooks/common.py (+19/-6)
hooks/config-changed (+11/-0)
hooks/install (+11/-0)
hooks/secondary-relation-changed (+11/-1)
hooks/setup.py (+8/-10)
hooks/start (+11/-0)
hooks/stop (+11/-0)
resources.yaml (+1/-9)
To merge this branch: bzr merge lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-secondary/status
Reviewer Review Type Date Requested Status
amir sanjar (community) Approve
Review via email: mp+262925@code.launchpad.net

Description of the change

Added extended status support.

Example status (tabular) outputs:

http://pastebin.ubuntu.com/11769979/ (in progress)
http://pastebin.ubuntu.com/11770196/ (complete)

Example status-history outputs:

http://pastebin.ubuntu.com/11770192/ (hdfs-master)
http://pastebin.ubuntu.com/11770195/ (compute-slave)

To post a comment you must log in.
Revision history for this message
Cory Johns (johnsca) wrote :

I also bundled charmhelpers and its dependencies, since there is almost no churn on it now and it made the status handling code cleaner as I could depend on hookenv.status_set() always being there.

67. By Cory Johns

Nested python resources to avoid attempting to pip install future non-python resources

Revision history for this message
amir sanjar (asanjar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/callbacks.py'
--- hooks/callbacks.py 2015-05-12 21:52:31 +0000
+++ hooks/callbacks.py 2015-06-25 13:44:16 +0000
@@ -15,3 +15,28 @@
15Add any additional tasks / setup here. If a callback is used by mutliple15Add any additional tasks / setup here. If a callback is used by mutliple
16charms, consider refactoring it up to the jujubigdata library.16charms, consider refactoring it up to the jujubigdata library.
17"""17"""
18
19from charmhelpers.core import hookenv
20from charmhelpers.core import unitdata
21from jujubigdata.relations import NameNodeMaster
22
23
24def 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
33def 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
40def update_active_status():
41 unitdata.kv().set('charm.active', True)
42 hookenv.status_set('active', 'Ready')
1843
=== modified file 'hooks/common.py'
--- hooks/common.py 2015-06-17 17:33:34 +0000
+++ hooks/common.py 2015-06-25 13:44:16 +0000
@@ -15,29 +15,39 @@
15"""15"""
1616
17import jujuresources17import jujuresources
18from charmhelpers.core import hookenv
19from charmhelpers.core import unitdata
20from charmhelpers.core import charmframework
1821
1922
20def bootstrap_resources():23def bootstrap_resources():
21 """24 """
22 Install required resources defined in resources.yaml25 Install required resources defined in resources.yaml
23 """26 """
27 if unitdata.kv().get('charm.bootstrapped', False):
28 return True
29 hookenv.status_set('maintenance', 'Installing base resources')
24 mirror_url = jujuresources.config_get('resources_mirror')30 mirror_url = jujuresources.config_get('resources_mirror')
25 if not jujuresources.fetch(mirror_url=mirror_url):31 if not jujuresources.fetch(mirror_url=mirror_url):
26 jujuresources.juju_log('Resources unavailable; manual intervention required', 'ERROR')32 missing = jujuresources.invalid()
33 hookenv.status_set('blocked', 'Unable to fetch required resource%s: %s' % (
34 's' if len(missing) > 1 else '',
35 ', '.join(missing),
36 ))
27 return False37 return False
28 jujuresources.install(['pathlib', 'pyaml', 'six', 'charmhelpers', 'jujubigdata'])38 jujuresources.install(['pathlib', 'jujubigdata'])
39 unitdata.kv().set('charm.bootstrapped', True)
29 return True40 return True
3041
3142
32def manage():43def manage():
33 if not bootstrap_resources():44 if not bootstrap_resources():
34 # defer until resources are available, since charmhelpers, and thus45 # defer until resources are available, since jujubigdata, and thus the
35 # the framework, (will be) managed by jujuresources46 # classes needed for the requires blocks, (will be) managed by jujuresources
36 return47 return
3748
38 from charmhelpers.core import charmframework
39 import jujubigdata49 import jujubigdata
40 import callbacks # noqa (ignore when linting)50 import callbacks
4151
42 # list of keys required to be in the dist.yaml52 # list of keys required to be in the dist.yaml
43 secondary_reqs = ['vendor', 'hadoop_version', 'packages', 'groups',53 secondary_reqs = ['vendor', 'hadoop_version', 'packages', 'groups',
@@ -55,6 +65,7 @@
55 ],65 ],
56 'callbacks': [66 'callbacks': [
57 hadoop.install,67 hadoop.install,
68 callbacks.update_blocked_status,
58 ],69 ],
59 },70 },
60 {71 {
@@ -67,12 +78,14 @@
67 namenode_master,78 namenode_master,
68 ],79 ],
69 'callbacks': [80 'callbacks': [
81 callbacks.update_working_status,
70 namenode_master.register_provided_hosts,82 namenode_master.register_provided_hosts,
71 jujubigdata.utils.manage_etc_hosts,83 jujubigdata.utils.manage_etc_hosts,
72 namenode_master.install_ssh_keys,84 namenode_master.install_ssh_keys,
73 hdfs.configure_secondarynamenode,85 hdfs.configure_secondarynamenode,
74 hdfs.start_secondarynamenode,86 hdfs.start_secondarynamenode,
75 charmframework.helpers.open_ports(dist_config.exposed_ports('secondary-namenode')),87 charmframework.helpers.open_ports(dist_config.exposed_ports('secondary-namenode')),
88 callbacks.update_active_status,
76 ],89 ],
77 'cleanup': [90 'cleanup': [
78 charmframework.helpers.close_ports(dist_config.exposed_ports('secondary-namenode')),91 charmframework.helpers.close_ports(dist_config.exposed_ports('secondary-namenode')),
7992
=== modified file 'hooks/config-changed'
--- hooks/config-changed 2015-02-09 18:22:41 +0000
+++ hooks/config-changed 2015-06-25 13:44:16 +0000
@@ -11,5 +11,16 @@
11# See the License for the specific language governing permissions and11# See the License for the specific language governing permissions and
12# limitations under the License.12# limitations under the License.
1313
14"""
15All hooks in this charm are managed by the Charm Framework.
16The framework helps manage dependencies and preconditions to ensure that
17steps are only executed when they can be successful. As such, no additional
18code should be added to this hook; instead, please integrate new functionality
19into the 'callbacks' list in hooks/common.py. New callbacks can be placed
20in hooks/callbacks.py, if necessary.
21
22See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
23for more information.
24"""
14import common25import common
15common.manage()26common.manage()
1627
=== modified file 'hooks/install'
--- hooks/install 2015-02-09 18:22:41 +0000
+++ hooks/install 2015-06-25 13:44:16 +0000
@@ -13,5 +13,16 @@
13import setup13import setup
14setup.pre_install()14setup.pre_install()
1515
16"""
17All hooks in this charm are managed by the Charm Framework.
18The framework helps manage dependencies and preconditions to ensure that
19steps are only executed when they can be successful. As such, no additional
20code should be added to this hook; instead, please integrate new functionality
21into the 'callbacks' list in hooks/common.py. New callbacks can be placed
22in hooks/callbacks.py, if necessary.
23
24See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
25for more information.
26"""
16import common27import common
17common.manage()28common.manage()
1829
=== modified file 'hooks/secondary-relation-changed'
--- hooks/secondary-relation-changed 2015-05-12 21:52:31 +0000
+++ hooks/secondary-relation-changed 2015-06-25 13:44:16 +0000
@@ -11,6 +11,16 @@
11# See the License for the specific language governing permissions and11# See the License for the specific language governing permissions and
12# limitations under the License.12# limitations under the License.
1313
14"""
15All hooks in this charm are managed by the Charm Framework.
16The framework helps manage dependencies and preconditions to ensure that
17steps are only executed when they can be successful. As such, no additional
18code should be added to this hook; instead, please integrate new functionality
19into the 'callbacks' list in hooks/common.py. New callbacks can be placed
20in hooks/callbacks.py, if necessary.
21
22See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
23for more information.
24"""
14import common25import common
15
16common.manage()26common.manage()
1727
=== modified file 'hooks/setup.py'
--- hooks/setup.py 2015-03-03 22:42:07 +0000
+++ hooks/setup.py 2015-06-25 13:44:16 +0000
@@ -12,24 +12,22 @@
12import subprocess12import subprocess
13from glob import glob13from glob import glob
1414
15
15def pre_install():16def pre_install():
16 """17 """
17 Do any setup required before the install hook.18 Do any setup required before the install hook.
18 """19 """
19 install_pip()20 install_pip()
20 install_jujuresources()21 install_bundled_resources()
2122
2223
23def install_pip():24def install_pip():
24 subprocess.check_call(['apt-get', 'install', '-yq', 'python-pip', 'bzr'])25 subprocess.check_call(['apt-get', 'install', '-yq', 'python-pip', 'bzr'])
2526
2627
27def install_jujuresources():28def install_bundled_resources():
28 """29 """
29 Install the bundled jujuresources library, if not present.30 Install the bundled resources libraries.
30 """31 """
31 try:32 archives = glob('resources/python/*')
32 import jujuresources # noqa33 subprocess.check_call(['pip', 'install'] + archives)
33 except ImportError:
34 jr_archive = glob('resources/jujuresources-*.tar.gz')[0]
35 subprocess.check_call(['pip', 'install', jr_archive])
3634
=== modified file 'hooks/start'
--- hooks/start 2015-02-09 18:22:41 +0000
+++ hooks/start 2015-06-25 13:44:16 +0000
@@ -11,5 +11,16 @@
11# See the License for the specific language governing permissions and11# See the License for the specific language governing permissions and
12# limitations under the License.12# limitations under the License.
1313
14"""
15All hooks in this charm are managed by the Charm Framework.
16The framework helps manage dependencies and preconditions to ensure that
17steps are only executed when they can be successful. As such, no additional
18code should be added to this hook; instead, please integrate new functionality
19into the 'callbacks' list in hooks/common.py. New callbacks can be placed
20in hooks/callbacks.py, if necessary.
21
22See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
23for more information.
24"""
14import common25import common
15common.manage()26common.manage()
1627
=== modified file 'hooks/stop'
--- hooks/stop 2015-02-09 18:22:41 +0000
+++ hooks/stop 2015-06-25 13:44:16 +0000
@@ -11,5 +11,16 @@
11# See the License for the specific language governing permissions and11# See the License for the specific language governing permissions and
12# limitations under the License.12# limitations under the License.
1313
14"""
15All hooks in this charm are managed by the Charm Framework.
16The framework helps manage dependencies and preconditions to ensure that
17steps are only executed when they can be successful. As such, no additional
18code should be added to this hook; instead, please integrate new functionality
19into the 'callbacks' list in hooks/common.py. New callbacks can be placed
20in hooks/callbacks.py, if necessary.
21
22See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html
23for more information.
24"""
14import common25import common
15common.manage()26common.manage()
1627
=== modified file 'resources.yaml'
--- resources.yaml 2015-06-19 16:58:47 +0000
+++ resources.yaml 2015-06-25 13:44:16 +0000
@@ -3,16 +3,8 @@
3resources:3resources:
4 pathlib:4 pathlib:
5 pypi: path.py>=7.05 pypi: path.py>=7.0
6 pyaml:
7 pypi: pyaml
8 six:
9 pypi: six
10 jujubigdata:6 jujubigdata:
11 pypi: jujubigdata>=2.0.0,<3.0.07 pypi: jujubigdata>=2.0.2,<3.0.0
12 charmhelpers:
13 pypi: http://bazaar.launchpad.net/~bigdata-dev/bigdata-data/trunk/download/kevin.monroe%40canonical.com-20150610215108-gq4ud2rriy1sp1h6/charmhelpers0.3.1.ta-20150610215050-vxrqhizdsrqwnmcm-1/charmhelpers-0.3.1.tar.gz
14 hash: 061fe7204289b96fab5d3ca02883040ea3026526ebf0ad38e21457527a18d139
15 hash_type: sha256
16 java-installer:8 java-installer:
17 # This points to a script which manages installing Java.9 # This points to a script which manages installing Java.
18 # If replaced with an alternate implementation, it must output *only* two10 # If replaced with an alternate implementation, it must output *only* two
1911
=== removed file 'resources/jujuresources-0.2.5.tar.gz'
20Binary files resources/jujuresources-0.2.5.tar.gz 2015-03-03 22:42:07 +0000 and resources/jujuresources-0.2.5.tar.gz 1970-01-01 00:00:00 +0000 differ12Binary files resources/jujuresources-0.2.5.tar.gz 2015-03-03 22:42:07 +0000 and resources/jujuresources-0.2.5.tar.gz 1970-01-01 00:00:00 +0000 differ
=== added directory 'resources/python'
=== added file 'resources/python/PyYAML-3.11.tar.gz'
21Binary files resources/python/PyYAML-3.11.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/PyYAML-3.11.tar.gz 2015-06-25 13:44:16 +0000 differ13Binary files resources/python/PyYAML-3.11.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/PyYAML-3.11.tar.gz 2015-06-25 13:44:16 +0000 differ
=== added file 'resources/python/charmhelpers-0.3.1.tar.gz'
22Binary files resources/python/charmhelpers-0.3.1.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/charmhelpers-0.3.1.tar.gz 2015-06-25 13:44:16 +0000 differ14Binary files resources/python/charmhelpers-0.3.1.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/charmhelpers-0.3.1.tar.gz 2015-06-25 13:44:16 +0000 differ
=== added file 'resources/python/jujuresources-0.2.8.tar.gz'
23Binary files resources/python/jujuresources-0.2.8.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/jujuresources-0.2.8.tar.gz 2015-06-25 13:44:16 +0000 differ15Binary files resources/python/jujuresources-0.2.8.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/jujuresources-0.2.8.tar.gz 2015-06-25 13:44:16 +0000 differ
=== added file 'resources/python/pyaml-15.5.7.tar.gz'
24Binary files resources/python/pyaml-15.5.7.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/pyaml-15.5.7.tar.gz 2015-06-25 13:44:16 +0000 differ16Binary files resources/python/pyaml-15.5.7.tar.gz 1970-01-01 00:00:00 +0000 and resources/python/pyaml-15.5.7.tar.gz 2015-06-25 13:44:16 +0000 differ
=== added file 'resources/python/six-1.9.0-py2.py3-none-any.whl'
25Binary files resources/python/six-1.9.0-py2.py3-none-any.whl 1970-01-01 00:00:00 +0000 and resources/python/six-1.9.0-py2.py3-none-any.whl 2015-06-25 13:44:16 +0000 differ17Binary files resources/python/six-1.9.0-py2.py3-none-any.whl 1970-01-01 00:00:00 +0000 and resources/python/six-1.9.0-py2.py3-none-any.whl 2015-06-25 13:44:16 +0000 differ

Subscribers

People subscribed via source and target branches

to all changes: