~corey.bryant/charms/trusty/nova-cloud-controller/amulet-updates

« back to all changes in this revision

Viewing changes to hooks/nova_cc_utils.py

  • Committer: james.page at ubuntu
  • Date: 2014-06-24 11:43:28 UTC
  • mfrom: (78.2.7 nova-cloud-controller)
  • Revision ID: james.page@ubuntu.com-20140624114328-6wgs55qr9qn0oldq
[gnuoy,r=james-page] Refactoring to support split-out of Neutron functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    relation_get,
34
34
    relation_ids,
35
35
    remote_unit,
 
36
    is_relation_made,
36
37
    INFO,
37
38
    ERROR,
38
39
)
39
40
 
40
41
from charmhelpers.core.host import (
41
 
    service_start
 
42
    service_start,
42
43
)
43
44
 
44
45
 
106
107
                     context.SyslogContext(),
107
108
                     nova_cc_context.HAProxyContext(),
108
109
                     nova_cc_context.IdentityServiceContext(),
109
 
                     nova_cc_context.VolumeServiceContext(),
110
 
                     nova_cc_context.NeutronCCContext()],
 
110
                     nova_cc_context.VolumeServiceContext()],
111
111
    }),
112
112
    (NOVA_API_PASTE, {
113
113
        'services': [s for s in BASE_SERVICES if 'api' in s],
188
188
 
189
189
    net_manager = network_manager()
190
190
 
191
 
    # pop out irrelevant resources from the OrderedDict (easier than adding
192
 
    # them late)
193
 
    if net_manager != 'quantum':
194
 
        [resource_map.pop(k) for k in list(resource_map.iterkeys())
195
 
         if 'quantum' in k]
196
 
    if net_manager != 'neutron':
197
 
        [resource_map.pop(k) for k in list(resource_map.iterkeys())
198
 
         if 'neutron' in k]
199
 
 
200
191
    if os.path.exists('/etc/apache2/conf-available'):
201
192
        resource_map.pop(APACHE_CONF)
202
193
    else:
203
194
        resource_map.pop(APACHE_24_CONF)
204
195
 
205
 
    # add neutron plugin requirements. nova-c-c only needs the neutron-server
206
 
    # associated with configs, not the plugin agent.
207
 
    if net_manager in ['quantum', 'neutron']:
208
 
        plugin = neutron_plugin()
209
 
        if plugin:
210
 
            conf = neutron_plugin_attribute(plugin, 'config', net_manager)
211
 
            ctxts = (neutron_plugin_attribute(plugin, 'contexts', net_manager)
212
 
                     or [])
213
 
            services = neutron_plugin_attribute(plugin, 'server_services',
214
 
                                                net_manager)
215
 
            resource_map[conf] = {}
216
 
            resource_map[conf]['services'] = services
217
 
            resource_map[conf]['contexts'] = ctxts
218
 
            resource_map[conf]['contexts'].append(
219
 
                nova_cc_context.NeutronCCContext())
 
196
    if is_relation_made('neutron-api'):
 
197
        [resource_map.pop(k) for k in list(resource_map.iterkeys())
 
198
         if 'quantum' in k or 'neutron' in k]
 
199
        resource_map[NOVA_CONF]['contexts'].append(
 
200
            nova_cc_context.NeutronAPIContext())
 
201
    else:
 
202
        resource_map[NOVA_CONF]['contexts'].append(
 
203
            nova_cc_context.NeutronCCContext())
 
204
        # pop out irrelevant resources from the OrderedDict (easier than adding
 
205
        # them late)
 
206
        if net_manager != 'quantum':
 
207
            [resource_map.pop(k) for k in list(resource_map.iterkeys())
 
208
             if 'quantum' in k]
 
209
        if net_manager != 'neutron':
 
210
            [resource_map.pop(k) for k in list(resource_map.iterkeys())
 
211
             if 'neutron' in k]
 
212
        # add neutron plugin requirements. nova-c-c only needs the
 
213
        # neutron-server associated with configs, not the plugin agent.
 
214
        if net_manager in ['quantum', 'neutron']:
 
215
            plugin = neutron_plugin()
 
216
            if plugin:
 
217
                conf = neutron_plugin_attribute(plugin, 'config', net_manager)
 
218
                ctxts = (neutron_plugin_attribute(plugin, 'contexts',
 
219
                                                  net_manager)
 
220
                         or [])
 
221
                services = neutron_plugin_attribute(plugin, 'server_services',
 
222
                                                    net_manager)
 
223
                resource_map[conf] = {}
 
224
                resource_map[conf]['services'] = services
 
225
                resource_map[conf]['contexts'] = ctxts
 
226
                resource_map[conf]['contexts'].append(
 
227
                    nova_cc_context.NeutronCCContext())
220
228
 
221
 
            # update for postgres
222
 
            resource_map[conf]['contexts'].append(
223
 
                nova_cc_context.NeutronPostgresqlDBContext())
 
229
                # update for postgres
 
230
                resource_map[conf]['contexts'].append(
 
231
                    nova_cc_context.NeutronPostgresqlDBContext())
224
232
 
225
233
    # nova-conductor for releases >= G.
226
234
    if os_release('nova-common') not in ['essex', 'folsom']:
235
243
        for s in vmware_ctxt['services']:
236
244
            if s not in resource_map[NOVA_CONF]['services']:
237
245
                resource_map[NOVA_CONF]['services'].append(s)
 
246
 
238
247
    return resource_map
239
248
 
240
249
 
681
690
        })
682
691
 
683
692
    # XXX: Keep these relations named quantum_*??
684
 
    if network_manager() in ['quantum', 'neutron']:
 
693
    if is_relation_made('neutron-api'):
 
694
        endpoints.update({
 
695
            'quantum_service': None,
 
696
            'quantum_region': None,
 
697
            'quantum_public_url': None,
 
698
            'quantum_admin_url': None,
 
699
            'quantum_internal_url': None,
 
700
        })
 
701
    elif network_manager() in ['quantum', 'neutron']:
685
702
        endpoints.update({
686
703
            'quantum_service': 'quantum',
687
704
            'quantum_region': region,