~ionutbalutoiu/charms/trusty/neutron-api/next

« back to all changes in this revision

Viewing changes to hooks/neutron_api_hooks.py

  • Committer: Robert Ayres
  • Date: 2015-10-08 11:48:15 UTC
  • mto: This revision was merged to the branch mainline in revision 151.
  • Revision ID: robert.ayres@canonical.com-20151008114815-3rpz17g6e90ef9tz
Fix quota driver unit tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
from charmhelpers.contrib.openstack.utils import (
38
38
    config_value_changed,
39
39
    configure_installation_source,
40
 
    set_os_workload_status,
 
40
    os_workload_status,
41
41
    git_install_requested,
42
42
    openstack_upgrade_available,
43
43
    os_requires_version,
148
148
 
149
149
@hooks.hook('install.real')
150
150
@hooks.hook()
 
151
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
152
                    charm_func=check_optional_relations)
151
153
def install():
152
154
    status_set('maintenance', 'Executing pre-install')
153
155
    execd_preinstall()
169
171
 
170
172
@hooks.hook('upgrade-charm')
171
173
@hooks.hook('config-changed')
 
174
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
175
                    charm_func=check_optional_relations)
172
176
@restart_on_change(restart_map(), stopstart=True)
173
177
def config_changed():
174
178
    # If neutron is ready to be queried then check for incompatability between
226
230
 
227
231
 
228
232
@hooks.hook('amqp-relation-joined')
 
233
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
234
                    charm_func=check_optional_relations)
229
235
def amqp_joined(relation_id=None):
230
236
    relation_set(relation_id=relation_id,
231
237
                 username=config('rabbit-user'), vhost=config('rabbit-vhost'))
233
239
 
234
240
@hooks.hook('amqp-relation-changed')
235
241
@hooks.hook('amqp-relation-departed')
 
242
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
243
                    charm_func=check_optional_relations)
236
244
@restart_on_change(restart_map())
237
245
def amqp_changed():
238
246
    if 'amqp' not in CONFIGS.complete_contexts():
242
250
 
243
251
 
244
252
@hooks.hook('shared-db-relation-joined')
 
253
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
254
                    charm_func=check_optional_relations)
245
255
def db_joined():
246
256
    if is_relation_made('pgsql-db'):
247
257
        # error, postgresql is used
261
271
 
262
272
 
263
273
@hooks.hook('pgsql-db-relation-joined')
 
274
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
275
                    charm_func=check_optional_relations)
264
276
def pgsql_neutron_db_joined():
265
277
    if is_relation_made('shared-db'):
266
278
        # raise error
273
285
 
274
286
 
275
287
@hooks.hook('shared-db-relation-changed')
 
288
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
289
                    charm_func=check_optional_relations)
276
290
@restart_on_change(restart_map())
277
291
def db_changed():
278
292
    if 'shared-db' not in CONFIGS.complete_contexts():
283
297
 
284
298
 
285
299
@hooks.hook('pgsql-db-relation-changed')
 
300
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
301
                    charm_func=check_optional_relations)
286
302
@restart_on_change(restart_map())
287
303
def postgresql_neutron_db_changed():
288
304
    CONFIGS.write(NEUTRON_CONF)
293
309
            'identity-service-relation-broken',
294
310
            'shared-db-relation-broken',
295
311
            'pgsql-db-relation-broken')
 
312
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
313
                    charm_func=check_optional_relations)
296
314
def relation_broken():
297
315
    CONFIGS.write_all()
298
316
 
299
317
 
300
318
@hooks.hook('identity-service-relation-joined')
 
319
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
320
                    charm_func=check_optional_relations)
301
321
def identity_joined(rid=None, relation_trigger=False):
302
322
    public_url = '{}:{}'.format(canonical_url(CONFIGS, PUBLIC),
303
323
                                api_port('neutron-server'))
319
339
 
320
340
 
321
341
@hooks.hook('identity-service-relation-changed')
 
342
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
343
                    charm_func=check_optional_relations)
322
344
@restart_on_change(restart_map())
323
345
def identity_changed():
324
346
    if 'identity-service' not in CONFIGS.complete_contexts():
358
380
 
359
381
 
360
382
@hooks.hook('neutron-plugin-api-relation-joined')
 
383
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
384
                    charm_func=check_optional_relations)
361
385
def neutron_plugin_api_relation_joined(rid=None):
362
386
    if config('neutron-plugin') == 'nsx':
363
387
        relation_data = {
429
453
 
430
454
 
431
455
@hooks.hook('ha-relation-joined')
 
456
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
457
                    charm_func=check_optional_relations)
432
458
def ha_joined():
433
459
    cluster_config = get_hacluster_config()
434
460
    resources = {
481
507
 
482
508
 
483
509
@hooks.hook('ha-relation-changed')
 
510
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
511
                    charm_func=check_optional_relations)
484
512
def ha_changed():
485
513
    clustered = relation_get('clustered')
486
514
    if not clustered or clustered in [None, 'None', '']:
496
524
 
497
525
 
498
526
@hooks.hook('zeromq-configuration-relation-joined')
 
527
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
528
                    charm_func=check_optional_relations)
499
529
@os_requires_version('kilo', 'neutron-server')
500
530
def zeromq_configuration_relation_joined(relid=None):
501
531
    relation_set(relation_id=relid,
505
535
 
506
536
@hooks.hook('zeromq-configuration-relation-changed',
507
537
            'neutron-plugin-api-subordinate-relation-changed')
 
538
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
539
                    charm_func=check_optional_relations)
508
540
@restart_on_change(restart_map(), stopstart=True)
509
541
def zeromq_configuration_relation_changed():
510
542
    CONFIGS.write_all()
543
575
        hooks.execute(sys.argv)
544
576
    except UnregisteredHookError as e:
545
577
        log('Unknown hook {} - skipping.'.format(e))
546
 
    set_os_workload_status(CONFIGS, REQUIRED_INTERFACES,
547
 
                           charm_func=check_optional_relations)
548
578
 
549
579
 
550
580
if __name__ == '__main__':