Merge lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-secondary/status into lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-secondary/trunk
- Trusty Tahr (14.04)
- status
- Merge into 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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
amir sanjar (community) | Approve | ||
Review via email: mp+262925@code.launchpad.net |
Commit message
Description of the change
Added extended status support.
Example status (tabular) outputs:
http://
http://
Example status-history outputs:
http://
http://
To post a comment you must log in.
Revision history for this message
Cory Johns (johnsca) wrote : | # |
- 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
1 | === modified file 'hooks/callbacks.py' | |||
2 | --- hooks/callbacks.py 2015-05-12 21:52:31 +0000 | |||
3 | +++ hooks/callbacks.py 2015-06-25 13:44:16 +0000 | |||
4 | @@ -15,3 +15,28 @@ | |||
5 | 15 | Add any additional tasks / setup here. If a callback is used by mutliple | 15 | Add any additional tasks / setup here. If a callback is used by mutliple |
6 | 16 | charms, consider refactoring it up to the jujubigdata library. | 16 | charms, consider refactoring it up to the jujubigdata library. |
7 | 17 | """ | 17 | """ |
8 | 18 | |||
9 | 19 | from charmhelpers.core import hookenv | ||
10 | 20 | from charmhelpers.core import unitdata | ||
11 | 21 | from jujubigdata.relations import NameNodeMaster | ||
12 | 22 | |||
13 | 23 | |||
14 | 24 | def update_blocked_status(): | ||
15 | 25 | if unitdata.kv().get('charm.active', False): | ||
16 | 26 | return | ||
17 | 27 | if NameNodeMaster(relation_name='secondary').connected_units(): | ||
18 | 28 | hookenv.status_set('waiting', 'Waiting for HDFS master to provide primary NameNode'), | ||
19 | 29 | else: | ||
20 | 30 | hookenv.status_set('blocked', 'Waiting for relation to HDFS master'), | ||
21 | 31 | |||
22 | 32 | |||
23 | 33 | def update_working_status(): | ||
24 | 34 | if unitdata.kv().get('charm.active', False): | ||
25 | 35 | hookenv.status_set('maintenance', 'Updating configuration') | ||
26 | 36 | return | ||
27 | 37 | hookenv.status_set('maintenance', 'Setting up Secondary NameNode') | ||
28 | 38 | |||
29 | 39 | |||
30 | 40 | def update_active_status(): | ||
31 | 41 | unitdata.kv().set('charm.active', True) | ||
32 | 42 | hookenv.status_set('active', 'Ready') | ||
33 | 18 | 43 | ||
34 | === modified file 'hooks/common.py' | |||
35 | --- hooks/common.py 2015-06-17 17:33:34 +0000 | |||
36 | +++ hooks/common.py 2015-06-25 13:44:16 +0000 | |||
37 | @@ -15,29 +15,39 @@ | |||
38 | 15 | """ | 15 | """ |
39 | 16 | 16 | ||
40 | 17 | import jujuresources | 17 | import jujuresources |
41 | 18 | from charmhelpers.core import hookenv | ||
42 | 19 | from charmhelpers.core import unitdata | ||
43 | 20 | from charmhelpers.core import charmframework | ||
44 | 18 | 21 | ||
45 | 19 | 22 | ||
46 | 20 | def bootstrap_resources(): | 23 | def bootstrap_resources(): |
47 | 21 | """ | 24 | """ |
48 | 22 | Install required resources defined in resources.yaml | 25 | Install required resources defined in resources.yaml |
49 | 23 | """ | 26 | """ |
50 | 27 | if unitdata.kv().get('charm.bootstrapped', False): | ||
51 | 28 | return True | ||
52 | 29 | hookenv.status_set('maintenance', 'Installing base resources') | ||
53 | 24 | mirror_url = jujuresources.config_get('resources_mirror') | 30 | mirror_url = jujuresources.config_get('resources_mirror') |
54 | 25 | if not jujuresources.fetch(mirror_url=mirror_url): | 31 | if not jujuresources.fetch(mirror_url=mirror_url): |
56 | 26 | jujuresources.juju_log('Resources unavailable; manual intervention required', 'ERROR') | 32 | missing = jujuresources.invalid() |
57 | 33 | hookenv.status_set('blocked', 'Unable to fetch required resource%s: %s' % ( | ||
58 | 34 | 's' if len(missing) > 1 else '', | ||
59 | 35 | ', '.join(missing), | ||
60 | 36 | )) | ||
61 | 27 | return False | 37 | return False |
63 | 28 | jujuresources.install(['pathlib', 'pyaml', 'six', 'charmhelpers', 'jujubigdata']) | 38 | jujuresources.install(['pathlib', 'jujubigdata']) |
64 | 39 | unitdata.kv().set('charm.bootstrapped', True) | ||
65 | 29 | return True | 40 | return True |
66 | 30 | 41 | ||
67 | 31 | 42 | ||
68 | 32 | def manage(): | 43 | def manage(): |
69 | 33 | if not bootstrap_resources(): | 44 | if not bootstrap_resources(): |
72 | 34 | # defer until resources are available, since charmhelpers, and thus | 45 | # defer until resources are available, since jujubigdata, and thus the |
73 | 35 | # the framework, (will be) managed by jujuresources | 46 | # classes needed for the requires blocks, (will be) managed by jujuresources |
74 | 36 | return | 47 | return |
75 | 37 | 48 | ||
76 | 38 | from charmhelpers.core import charmframework | ||
77 | 39 | import jujubigdata | 49 | import jujubigdata |
79 | 40 | import callbacks # noqa (ignore when linting) | 50 | import callbacks |
80 | 41 | 51 | ||
81 | 42 | # list of keys required to be in the dist.yaml | 52 | # list of keys required to be in the dist.yaml |
82 | 43 | secondary_reqs = ['vendor', 'hadoop_version', 'packages', 'groups', | 53 | secondary_reqs = ['vendor', 'hadoop_version', 'packages', 'groups', |
83 | @@ -55,6 +65,7 @@ | |||
84 | 55 | ], | 65 | ], |
85 | 56 | 'callbacks': [ | 66 | 'callbacks': [ |
86 | 57 | hadoop.install, | 67 | hadoop.install, |
87 | 68 | callbacks.update_blocked_status, | ||
88 | 58 | ], | 69 | ], |
89 | 59 | }, | 70 | }, |
90 | 60 | { | 71 | { |
91 | @@ -67,12 +78,14 @@ | |||
92 | 67 | namenode_master, | 78 | namenode_master, |
93 | 68 | ], | 79 | ], |
94 | 69 | 'callbacks': [ | 80 | 'callbacks': [ |
95 | 81 | callbacks.update_working_status, | ||
96 | 70 | namenode_master.register_provided_hosts, | 82 | namenode_master.register_provided_hosts, |
97 | 71 | jujubigdata.utils.manage_etc_hosts, | 83 | jujubigdata.utils.manage_etc_hosts, |
98 | 72 | namenode_master.install_ssh_keys, | 84 | namenode_master.install_ssh_keys, |
99 | 73 | hdfs.configure_secondarynamenode, | 85 | hdfs.configure_secondarynamenode, |
100 | 74 | hdfs.start_secondarynamenode, | 86 | hdfs.start_secondarynamenode, |
101 | 75 | charmframework.helpers.open_ports(dist_config.exposed_ports('secondary-namenode')), | 87 | charmframework.helpers.open_ports(dist_config.exposed_ports('secondary-namenode')), |
102 | 88 | callbacks.update_active_status, | ||
103 | 76 | ], | 89 | ], |
104 | 77 | 'cleanup': [ | 90 | 'cleanup': [ |
105 | 78 | charmframework.helpers.close_ports(dist_config.exposed_ports('secondary-namenode')), | 91 | charmframework.helpers.close_ports(dist_config.exposed_ports('secondary-namenode')), |
106 | 79 | 92 | ||
107 | === modified file 'hooks/config-changed' | |||
108 | --- hooks/config-changed 2015-02-09 18:22:41 +0000 | |||
109 | +++ hooks/config-changed 2015-06-25 13:44:16 +0000 | |||
110 | @@ -11,5 +11,16 @@ | |||
111 | 11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
112 | 12 | # limitations under the License. | 12 | # limitations under the License. |
113 | 13 | 13 | ||
114 | 14 | """ | ||
115 | 15 | All hooks in this charm are managed by the Charm Framework. | ||
116 | 16 | The framework helps manage dependencies and preconditions to ensure that | ||
117 | 17 | steps are only executed when they can be successful. As such, no additional | ||
118 | 18 | code should be added to this hook; instead, please integrate new functionality | ||
119 | 19 | into the 'callbacks' list in hooks/common.py. New callbacks can be placed | ||
120 | 20 | in hooks/callbacks.py, if necessary. | ||
121 | 21 | |||
122 | 22 | See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html | ||
123 | 23 | for more information. | ||
124 | 24 | """ | ||
125 | 14 | import common | 25 | import common |
126 | 15 | common.manage() | 26 | common.manage() |
127 | 16 | 27 | ||
128 | === modified file 'hooks/install' | |||
129 | --- hooks/install 2015-02-09 18:22:41 +0000 | |||
130 | +++ hooks/install 2015-06-25 13:44:16 +0000 | |||
131 | @@ -13,5 +13,16 @@ | |||
132 | 13 | import setup | 13 | import setup |
133 | 14 | setup.pre_install() | 14 | setup.pre_install() |
134 | 15 | 15 | ||
135 | 16 | """ | ||
136 | 17 | All hooks in this charm are managed by the Charm Framework. | ||
137 | 18 | The framework helps manage dependencies and preconditions to ensure that | ||
138 | 19 | steps are only executed when they can be successful. As such, no additional | ||
139 | 20 | code should be added to this hook; instead, please integrate new functionality | ||
140 | 21 | into the 'callbacks' list in hooks/common.py. New callbacks can be placed | ||
141 | 22 | in hooks/callbacks.py, if necessary. | ||
142 | 23 | |||
143 | 24 | See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html | ||
144 | 25 | for more information. | ||
145 | 26 | """ | ||
146 | 16 | import common | 27 | import common |
147 | 17 | common.manage() | 28 | common.manage() |
148 | 18 | 29 | ||
149 | === modified file 'hooks/secondary-relation-changed' | |||
150 | --- hooks/secondary-relation-changed 2015-05-12 21:52:31 +0000 | |||
151 | +++ hooks/secondary-relation-changed 2015-06-25 13:44:16 +0000 | |||
152 | @@ -11,6 +11,16 @@ | |||
153 | 11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
154 | 12 | # limitations under the License. | 12 | # limitations under the License. |
155 | 13 | 13 | ||
156 | 14 | """ | ||
157 | 15 | All hooks in this charm are managed by the Charm Framework. | ||
158 | 16 | The framework helps manage dependencies and preconditions to ensure that | ||
159 | 17 | steps are only executed when they can be successful. As such, no additional | ||
160 | 18 | code should be added to this hook; instead, please integrate new functionality | ||
161 | 19 | into the 'callbacks' list in hooks/common.py. New callbacks can be placed | ||
162 | 20 | in hooks/callbacks.py, if necessary. | ||
163 | 21 | |||
164 | 22 | See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html | ||
165 | 23 | for more information. | ||
166 | 24 | """ | ||
167 | 14 | import common | 25 | import common |
168 | 15 | |||
169 | 16 | common.manage() | 26 | common.manage() |
170 | 17 | 27 | ||
171 | === modified file 'hooks/setup.py' | |||
172 | --- hooks/setup.py 2015-03-03 22:42:07 +0000 | |||
173 | +++ hooks/setup.py 2015-06-25 13:44:16 +0000 | |||
174 | @@ -12,24 +12,22 @@ | |||
175 | 12 | import subprocess | 12 | import subprocess |
176 | 13 | from glob import glob | 13 | from glob import glob |
177 | 14 | 14 | ||
178 | 15 | |||
179 | 15 | def pre_install(): | 16 | def pre_install(): |
180 | 16 | """ | 17 | """ |
181 | 17 | Do any setup required before the install hook. | 18 | Do any setup required before the install hook. |
182 | 18 | """ | 19 | """ |
183 | 19 | install_pip() | 20 | install_pip() |
185 | 20 | install_jujuresources() | 21 | install_bundled_resources() |
186 | 21 | 22 | ||
187 | 22 | 23 | ||
188 | 23 | def install_pip(): | 24 | def install_pip(): |
189 | 24 | subprocess.check_call(['apt-get', 'install', '-yq', 'python-pip', 'bzr']) | 25 | subprocess.check_call(['apt-get', 'install', '-yq', 'python-pip', 'bzr']) |
190 | 25 | 26 | ||
191 | 26 | 27 | ||
201 | 27 | def install_jujuresources(): | 28 | def install_bundled_resources(): |
202 | 28 | """ | 29 | """ |
203 | 29 | Install the bundled jujuresources library, if not present. | 30 | Install the bundled resources libraries. |
204 | 30 | """ | 31 | """ |
205 | 31 | try: | 32 | archives = glob('resources/python/*') |
206 | 32 | import jujuresources # noqa | 33 | subprocess.check_call(['pip', 'install'] + archives) |
198 | 33 | except ImportError: | ||
199 | 34 | jr_archive = glob('resources/jujuresources-*.tar.gz')[0] | ||
200 | 35 | subprocess.check_call(['pip', 'install', jr_archive]) | ||
207 | 36 | 34 | ||
208 | === modified file 'hooks/start' | |||
209 | --- hooks/start 2015-02-09 18:22:41 +0000 | |||
210 | +++ hooks/start 2015-06-25 13:44:16 +0000 | |||
211 | @@ -11,5 +11,16 @@ | |||
212 | 11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
213 | 12 | # limitations under the License. | 12 | # limitations under the License. |
214 | 13 | 13 | ||
215 | 14 | """ | ||
216 | 15 | All hooks in this charm are managed by the Charm Framework. | ||
217 | 16 | The framework helps manage dependencies and preconditions to ensure that | ||
218 | 17 | steps are only executed when they can be successful. As such, no additional | ||
219 | 18 | code should be added to this hook; instead, please integrate new functionality | ||
220 | 19 | into the 'callbacks' list in hooks/common.py. New callbacks can be placed | ||
221 | 20 | in hooks/callbacks.py, if necessary. | ||
222 | 21 | |||
223 | 22 | See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html | ||
224 | 23 | for more information. | ||
225 | 24 | """ | ||
226 | 14 | import common | 25 | import common |
227 | 15 | common.manage() | 26 | common.manage() |
228 | 16 | 27 | ||
229 | === modified file 'hooks/stop' | |||
230 | --- hooks/stop 2015-02-09 18:22:41 +0000 | |||
231 | +++ hooks/stop 2015-06-25 13:44:16 +0000 | |||
232 | @@ -11,5 +11,16 @@ | |||
233 | 11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
234 | 12 | # limitations under the License. | 12 | # limitations under the License. |
235 | 13 | 13 | ||
236 | 14 | """ | ||
237 | 15 | All hooks in this charm are managed by the Charm Framework. | ||
238 | 16 | The framework helps manage dependencies and preconditions to ensure that | ||
239 | 17 | steps are only executed when they can be successful. As such, no additional | ||
240 | 18 | code should be added to this hook; instead, please integrate new functionality | ||
241 | 19 | into the 'callbacks' list in hooks/common.py. New callbacks can be placed | ||
242 | 20 | in hooks/callbacks.py, if necessary. | ||
243 | 21 | |||
244 | 22 | See http://big-data-charm-helpers.readthedocs.org/en/latest/examples/framework.html | ||
245 | 23 | for more information. | ||
246 | 24 | """ | ||
247 | 14 | import common | 25 | import common |
248 | 15 | common.manage() | 26 | common.manage() |
249 | 16 | 27 | ||
250 | === modified file 'resources.yaml' | |||
251 | --- resources.yaml 2015-06-19 16:58:47 +0000 | |||
252 | +++ resources.yaml 2015-06-25 13:44:16 +0000 | |||
253 | @@ -3,16 +3,8 @@ | |||
254 | 3 | resources: | 3 | resources: |
255 | 4 | pathlib: | 4 | pathlib: |
256 | 5 | pypi: path.py>=7.0 | 5 | pypi: path.py>=7.0 |
257 | 6 | pyaml: | ||
258 | 7 | pypi: pyaml | ||
259 | 8 | six: | ||
260 | 9 | pypi: six | ||
261 | 10 | jujubigdata: | 6 | jujubigdata: |
267 | 11 | pypi: jujubigdata>=2.0.0,<3.0.0 | 7 | pypi: jujubigdata>=2.0.2,<3.0.0 |
263 | 12 | charmhelpers: | ||
264 | 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 | ||
265 | 14 | hash: 061fe7204289b96fab5d3ca02883040ea3026526ebf0ad38e21457527a18d139 | ||
266 | 15 | hash_type: sha256 | ||
268 | 16 | java-installer: | 8 | java-installer: |
269 | 17 | # This points to a script which manages installing Java. | 9 | # This points to a script which manages installing Java. |
270 | 18 | # If replaced with an alternate implementation, it must output *only* two | 10 | # If replaced with an alternate implementation, it must output *only* two |
271 | 19 | 11 | ||
272 | === removed file 'resources/jujuresources-0.2.5.tar.gz' | |||
273 | 20 | Binary 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 | 12 | Binary 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 |
274 | === added directory 'resources/python' | |||
275 | === added file 'resources/python/PyYAML-3.11.tar.gz' | |||
276 | 21 | Binary 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 | 13 | Binary 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 |
277 | === added file 'resources/python/charmhelpers-0.3.1.tar.gz' | |||
278 | 22 | Binary 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 | 14 | Binary 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 |
279 | === added file 'resources/python/jujuresources-0.2.8.tar.gz' | |||
280 | 23 | Binary 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 | 15 | Binary 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 |
281 | === added file 'resources/python/pyaml-15.5.7.tar.gz' | |||
282 | 24 | Binary 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 | 16 | Binary 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 |
283 | === added file 'resources/python/six-1.9.0-py2.py3-none-any.whl' | |||
284 | 25 | Binary 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 | 17 | Binary 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 |
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.