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

« back to all changes in this revision

Viewing changes to hooks/neutron_api_hooks.py

  • Committer: Liam Young
  • Date: 2014-06-18 10:36:43 UTC
  • Revision ID: liam.young@canonical.com-20140618103643-j0vgz5vz300fz1ag
Added hooks unit tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
    [open_port(port) for port in determine_ports()]
67
67
 
68
68
 
 
69
@hooks.hook('upgrade-charm')
69
70
@hooks.hook('config-changed')
70
71
@restart_on_change(restart_map(), stopstart=True)
71
72
def config_changed():
75
76
        neutron_api_relation_joined(rid=r_id)
76
77
    for r_id in relation_ids('neutron-plugin-api'):
77
78
        neutron_plugin_api_relation_joined(rid=r_id)
 
79
    for r_id in relation_ids('amqp'):
 
80
        amqp_joined(relation_id=r_id)
 
81
    for r_id in relation_ids('identity-service'):
 
82
        identity_joined(rid=r_id)
78
83
 
79
84
 
80
85
@hooks.hook('amqp-relation-joined')
95
100
 
96
101
@hooks.hook('shared-db-relation-joined')
97
102
def db_joined():
98
 
    if is_relation_made('pgsql-nova-db') or \
99
 
            is_relation_made('pgsql-db'):
 
103
    if is_relation_made('pgsql-db'):
100
104
        # error, postgresql is used
101
105
        e = ('Attempting to associate a mysql database when there is already '
102
106
             'associated a postgresql one')
146
150
    CONFIGS.write_all()
147
151
 
148
152
 
149
 
@hooks.hook('upgrade-charm')
150
 
def upgrade_charm():
151
 
    for r_id in relation_ids('amqp'):
152
 
        amqp_joined(relation_id=r_id)
153
 
    for r_id in relation_ids('identity-service'):
154
 
        identity_joined(rid=r_id)
155
 
 
156
 
 
157
153
@hooks.hook('identity-service-relation-joined')
158
154
def identity_joined(rid=None):
159
155
    base_url = canonical_url(CONFIGS)
272
268
def ha_changed():
273
269
    clustered = relation_get('clustered')
274
270
    if not clustered or clustered in [None, 'None', '']:
275
 
        log('ha_changed: hacluster subordinate not fully clustered.')
 
271
        log('ha_changed: hacluster subordinate not fully clustered.:' + str(clustered))
276
272
        return
277
273
    if not is_leader(CLUSTER_RES):
278
274
        log('ha_changed: hacluster complete but we are not leader.')