Merge lp:~gnuoy/charms/trusty/nova-cloud-controller/workload-status into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next

Proposed by Liam Young
Status: Merged
Merged at revision: 200
Proposed branch: lp:~gnuoy/charms/trusty/nova-cloud-controller/workload-status
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 388 lines (+108/-17)
10 files modified
hooks/charmhelpers/contrib/openstack/amulet/utils.py (+1/-1)
hooks/charmhelpers/contrib/openstack/context.py (+15/-4)
hooks/charmhelpers/contrib/openstack/neutron.py (+3/-3)
hooks/charmhelpers/contrib/openstack/templates/ceph.conf (+6/-0)
hooks/nova_cc_context.py (+15/-2)
hooks/nova_cc_hooks.py (+20/-3)
hooks/nova_cc_utils.py (+43/-3)
tests/charmhelpers/contrib/openstack/amulet/utils.py (+1/-1)
unit_tests/test_nova_cc_hooks.py (+1/-0)
unit_tests/test_utils.py (+3/-0)
To merge this branch: bzr merge lp:~gnuoy/charms/trusty/nova-cloud-controller/workload-status
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+273837@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #11534 nova-cloud-controller-next for gnuoy mp273837
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/11534/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #10726 nova-cloud-controller-next for gnuoy mp273837
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10726/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #7239 nova-cloud-controller-next for gnuoy mp273837
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/12718842/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7239/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/charmhelpers/contrib/openstack/amulet/utils.py'
2--- hooks/charmhelpers/contrib/openstack/amulet/utils.py 2015-09-22 02:07:16 +0000
3+++ hooks/charmhelpers/contrib/openstack/amulet/utils.py 2015-10-08 13:31:32 +0000
4@@ -752,7 +752,7 @@
5 self.log.debug('SSL is enabled @{}:{} '
6 '({})'.format(host, port, unit_name))
7 return True
8- elif not port and not conf_ssl:
9+ elif not conf_ssl:
10 self.log.debug('SSL not enabled @{}:{} '
11 '({})'.format(host, port, unit_name))
12 return False
13
14=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
15--- hooks/charmhelpers/contrib/openstack/context.py 2015-09-22 02:45:17 +0000
16+++ hooks/charmhelpers/contrib/openstack/context.py 2015-10-08 13:31:32 +0000
17@@ -14,6 +14,7 @@
18 # You should have received a copy of the GNU Lesser General Public License
19 # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
20
21+import glob
22 import json
23 import os
24 import re
25@@ -1363,7 +1364,7 @@
26 normalized.update({port: port for port in resolved
27 if port in ports})
28 if resolved:
29- return {bridge: normalized[port] for port, bridge in
30+ return {normalized[port]: bridge for port, bridge in
31 six.iteritems(portmap) if port in normalized.keys()}
32
33 return None
34@@ -1374,12 +1375,22 @@
35 def __call__(self):
36 ctxt = {}
37 mappings = super(PhyNICMTUContext, self).__call__()
38- if mappings and mappings.values():
39- ports = mappings.values()
40+ if mappings and mappings.keys():
41+ ports = sorted(mappings.keys())
42 napi_settings = NeutronAPIContext()()
43 mtu = napi_settings.get('network_device_mtu')
44+ all_ports = set()
45+ # If any of ports is a vlan device, its underlying device must have
46+ # mtu applied first.
47+ for port in ports:
48+ for lport in glob.glob("/sys/class/net/%s/lower_*" % port):
49+ lport = os.path.basename(lport)
50+ all_ports.add(lport.split('_')[1])
51+
52+ all_ports = list(all_ports)
53+ all_ports.extend(ports)
54 if mtu:
55- ctxt["devs"] = '\\n'.join(ports)
56+ ctxt["devs"] = '\\n'.join(all_ports)
57 ctxt['mtu'] = mtu
58
59 return ctxt
60
61=== modified file 'hooks/charmhelpers/contrib/openstack/neutron.py'
62--- hooks/charmhelpers/contrib/openstack/neutron.py 2015-09-22 02:45:17 +0000
63+++ hooks/charmhelpers/contrib/openstack/neutron.py 2015-10-08 13:31:32 +0000
64@@ -310,10 +310,10 @@
65 def parse_data_port_mappings(mappings, default_bridge='br-data'):
66 """Parse data port mappings.
67
68- Mappings must be a space-delimited list of port:bridge mappings.
69+ Mappings must be a space-delimited list of bridge:port.
70
71- Returns dict of the form {port:bridge} where port may be an mac address or
72- interface name.
73+ Returns dict of the form {port:bridge} where ports may be mac addresses or
74+ interface names.
75 """
76
77 # NOTE(dosaboy): we use rvalue for key to allow multiple values to be
78
79=== modified file 'hooks/charmhelpers/contrib/openstack/templates/ceph.conf'
80--- hooks/charmhelpers/contrib/openstack/templates/ceph.conf 2015-07-16 20:18:38 +0000
81+++ hooks/charmhelpers/contrib/openstack/templates/ceph.conf 2015-10-08 13:31:32 +0000
82@@ -13,3 +13,9 @@
83 err to syslog = {{ use_syslog }}
84 clog to syslog = {{ use_syslog }}
85
86+[client]
87+{% if rbd_client_cache_settings -%}
88+{% for key, value in rbd_client_cache_settings.iteritems() -%}
89+{{ key }} = {{ value }}
90+{% endfor -%}
91+{%- endif %}
92\ No newline at end of file
93
94=== modified file 'hooks/nova_cc_context.py'
95--- hooks/nova_cc_context.py 2015-10-02 14:15:57 +0000
96+++ hooks/nova_cc_context.py 2015-10-08 13:31:32 +0000
97@@ -81,7 +81,20 @@
98 return {}
99
100
101+class CloudComputeContext(context.OSContextGenerator):
102+ "Dummy context used by service status to check relation exists"
103+ interfaces = ['nova-compute']
104+
105+ def __call__(self):
106+ ctxt = {}
107+ rids = [rid for rid in relation_ids('cloud-compute')]
108+ if rids:
109+ ctxt['rids'] = rids
110+ return ctxt
111+
112+
113 class NeutronAPIContext(context.OSContextGenerator):
114+ interfaces = ['neutron-api']
115
116 def __call__(self):
117 log('Generating template context from neutron api relation')
118@@ -102,7 +115,7 @@
119
120
121 class VolumeServiceContext(context.OSContextGenerator):
122- interfaces = []
123+ interfaces = ['nova-volume-service', 'cinder-volume-service']
124
125 def __call__(self):
126 ctxt = {}
127@@ -228,7 +241,7 @@
128
129
130 class NeutronCCContext(context.NeutronContext):
131- interfaces = []
132+ interfaces = ['quantum-network-service', 'neutron-network-service']
133
134 @property
135 def plugin(self):
136
137=== modified file 'hooks/nova_cc_hooks.py'
138--- hooks/nova_cc_hooks.py 2015-09-24 16:29:26 +0000
139+++ hooks/nova_cc_hooks.py 2015-10-08 13:31:32 +0000
140@@ -26,6 +26,7 @@
141 related_units,
142 open_port,
143 unit_get,
144+ status_set,
145 )
146
147 from charmhelpers.core.host import (
148@@ -49,7 +50,8 @@
149 openstack_upgrade_available,
150 os_release,
151 os_requires_version,
152- sync_db_with_multi_ipv6_addresses
153+ sync_db_with_multi_ipv6_addresses,
154+ set_os_workload_status,
155 )
156
157 from charmhelpers.contrib.openstack.neutron import (
158@@ -101,6 +103,8 @@
159 guard_map,
160 get_topics,
161 setup_ipv6,
162+ REQUIRED_INTERFACES,
163+ check_optional_relations,
164 )
165
166 from charmhelpers.contrib.hahelpers.cluster import (
167@@ -146,9 +150,11 @@
168
169 @hooks.hook('install.real')
170 def install():
171+ status_set('maintenance', 'Executing pre-install')
172 execd_preinstall()
173 configure_installation_source(config('openstack-origin'))
174
175+ status_set('maintenance', 'Installing apt packages')
176 apt_update()
177 apt_install(determine_packages(), fatal=True)
178
179@@ -162,7 +168,9 @@
180 log('Installing %s to /usr/bin' % f)
181 shutil.copy2(f, '/usr/bin')
182 [open_port(port) for port in determine_ports()]
183- log('Disabling services into db relation joined')
184+ msg = 'Disabling services into db relation joined'
185+ log(msg)
186+ status_set('maintenance', msg)
187 disable_services()
188 cmd_all_services('stop')
189
190@@ -173,6 +181,7 @@
191 @restart_on_change(restart_map(), stopstart=True)
192 def config_changed():
193 if config('prefer-ipv6'):
194+ status_set('maintenance', 'configuring ipv6')
195 setup_ipv6()
196 sync_db_with_multi_ipv6_addresses(config('database'),
197 config('database-user'),
198@@ -180,10 +189,12 @@
199
200 global CONFIGS
201 if git_install_requested():
202+ status_set('maintenance', 'Running Git install')
203 if config_value_changed('openstack-origin-git'):
204 git_install(config('openstack-origin-git'))
205 elif not config('action-managed-upgrade'):
206 if openstack_upgrade_available('nova-common'):
207+ status_set('maintenance', 'Running openstack upgrade')
208 CONFIGS = do_openstack_upgrade(CONFIGS)
209 [neutron_api_relation_joined(rid=rid, remote_restart=True)
210 for rid in relation_ids('neutron-api')]
211@@ -192,6 +203,7 @@
212 CONFIGS.write_all()
213 if console_attributes('protocol'):
214 if not git_install_requested():
215+ status_set('maintenance', 'Configuring guest console access')
216 apt_update()
217 packages = console_attributes('packages') or []
218 filtered = filter_installed_packages(packages)
219@@ -244,6 +256,7 @@
220 log('Not running neutron database migration as migrations are by '
221 'the neutron-api charm.')
222 else:
223+ status_set('maintenance', 'Running neutron db migration')
224 migrate_neutron_database()
225 # neutron-api service may have appeared while the migration was
226 # running so prod it just in case
227@@ -330,6 +343,7 @@
228 # permitted units then check if we're in the list.
229 allowed_units = relation_get('nova_allowed_units')
230 if allowed_units and local_unit() in allowed_units.split():
231+ status_set('maintenance', 'Running nova db migration')
232 migrate_nova_database()
233 log('Triggering remote cloud-compute restarts.')
234 [compute_joined(rid=rid, remote_restart=True)
235@@ -354,6 +368,7 @@
236 CONFIGS.write_all()
237
238 if is_elected_leader(CLUSTER_RES):
239+ status_set('maintenance', 'Running nova db migration')
240 migrate_nova_database()
241 log('Triggering remote cloud-compute restarts.')
242 [compute_joined(rid=rid, remote_restart=True)
243@@ -578,6 +593,7 @@
244 if 'migration_auth_type' not in rel_settings:
245 return
246 if rel_settings['migration_auth_type'] == 'ssh':
247+ status_set('maintenance', 'configuring live migration')
248 key = rel_settings.get('ssh_public_key')
249 if not key:
250 log('SSH migration set but peer did not publish key.')
251@@ -1039,7 +1055,8 @@
252 hooks.execute(sys.argv)
253 except UnregisteredHookError as e:
254 log('Unknown hook {} - skipping.'.format(e))
255-
256+ set_os_workload_status(CONFIGS, REQUIRED_INTERFACES,
257+ charm_func=check_optional_relations)
258
259 if __name__ == '__main__':
260 main()
261
262=== modified file 'hooks/nova_cc_utils.py'
263--- hooks/nova_cc_utils.py 2015-10-06 15:47:35 +0000
264+++ hooks/nova_cc_utils.py 2015-10-08 13:31:32 +0000
265@@ -11,7 +11,10 @@
266 from charmhelpers.contrib.openstack.neutron import (
267 network_manager, neutron_plugin_attribute)
268
269-from charmhelpers.contrib.hahelpers.cluster import is_elected_leader
270+from charmhelpers.contrib.hahelpers.cluster import (
271+ is_elected_leader,
272+ get_hacluster_config,
273+)
274
275 from charmhelpers.contrib.peerstorage import peer_store
276
277@@ -31,7 +34,9 @@
278 git_yaml_value,
279 is_ip,
280 os_release,
281- save_script_rc as _save_script_rc)
282+ save_script_rc as _save_script_rc,
283+ set_os_workload_status,
284+)
285
286 from charmhelpers.fetch import (
287 apt_upgrade,
288@@ -50,6 +55,7 @@
289 is_relation_made,
290 INFO,
291 ERROR,
292+ status_get,
293 )
294
295 from charmhelpers.core.host import (
296@@ -80,6 +86,16 @@
297
298 CLUSTER_RES = 'grp_nova_vips'
299
300+# The interface is said to be satisfied if anyone of the interfaces in the
301+# list has a complete context.
302+REQUIRED_INTERFACES = {
303+ 'database': ['shared-db', 'pgsql-db'],
304+ 'messaging': ['amqp', 'zeromq-configuration'],
305+ 'identity': ['identity-service'],
306+ 'image': ['image-service'],
307+ 'compute': ['nova-compute'],
308+}
309+
310 # removed from original: charm-helper-sh
311 BASE_PACKAGES = [
312 'apache2',
313@@ -195,7 +211,8 @@
314 nova_cc_context.NeutronCCContext(),
315 nova_cc_context.NovaConfigContext(),
316 nova_cc_context.InstanceConsoleContext(),
317- nova_cc_context.ConsoleSSLContext()],
318+ nova_cc_context.ConsoleSSLContext(),
319+ nova_cc_context.CloudComputeContext()],
320 }),
321 (NOVA_API_PASTE, {
322 'services': [s for s in BASE_SERVICES if 'api' in s],
323@@ -1328,3 +1345,26 @@
324
325 apt_update()
326 apt_install(LATE_GIT_PACKAGES, fatal=True)
327+
328+
329+def check_optional_relations(configs):
330+ required_interfaces = {}
331+ if relation_ids('ha'):
332+ required_interfaces['ha'] = ['cluster']
333+ try:
334+ get_hacluster_config()
335+ except:
336+ return ('blocked',
337+ 'hacluster missing configuration: '
338+ 'vip, vip_iface, vip_cidr')
339+ if relation_ids('quantum-network-service'):
340+ required_interfaces['quantum'] = ['quantum-network-service']
341+ if relation_ids('cinder-volume-service'):
342+ required_interfaces['cinder'] = ['cinder-volume-service']
343+ if relation_ids('neutron-api'):
344+ required_interfaces['neutron-api'] = ['neutron-api']
345+ if required_interfaces:
346+ set_os_workload_status(configs, required_interfaces)
347+ return status_get()
348+ else:
349+ return 'unknown', 'No optional relations'
350
351=== modified file 'tests/charmhelpers/contrib/openstack/amulet/utils.py'
352--- tests/charmhelpers/contrib/openstack/amulet/utils.py 2015-09-22 02:07:16 +0000
353+++ tests/charmhelpers/contrib/openstack/amulet/utils.py 2015-10-08 13:31:32 +0000
354@@ -752,7 +752,7 @@
355 self.log.debug('SSL is enabled @{}:{} '
356 '({})'.format(host, port, unit_name))
357 return True
358- elif not port and not conf_ssl:
359+ elif not conf_ssl:
360 self.log.debug('SSL not enabled @{}:{} '
361 '({})'.format(host, port, unit_name))
362 return False
363
364=== modified file 'unit_tests/test_nova_cc_hooks.py'
365--- unit_tests/test_nova_cc_hooks.py 2015-09-24 16:29:26 +0000
366+++ unit_tests/test_nova_cc_hooks.py 2015-10-08 13:31:32 +0000
367@@ -73,6 +73,7 @@
368 'update_nrpe_config',
369 'git_install',
370 'git_install_requested',
371+ 'status_set',
372 ]
373
374
375
376=== modified file 'unit_tests/test_utils.py'
377--- unit_tests/test_utils.py 2015-05-22 15:31:25 +0000
378+++ unit_tests/test_utils.py 2015-10-08 13:31:32 +0000
379@@ -6,6 +6,9 @@
380 from contextlib import contextmanager
381 from mock import patch, MagicMock
382
383+patch('charmhelpers.contrib.openstack.utils.set_os_workload_status').start()
384+patch('charmhelpers.core.hookenv.status_set').start()
385+
386
387 def load_config():
388 '''

Subscribers

People subscribed via source and target branches