~tribaal/charms/trusty/nova-cloud-controller/update-charm-helpers-stable

« back to all changes in this revision

Viewing changes to hooks/nova_cc_utils.py

Merged next in

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
)
40
40
 
41
41
from charmhelpers.core.host import (
42
 
    service_start
 
42
    service_start,
43
43
)
44
44
 
45
45
 
97
97
        'contexts': [context.AMQPContext(ssl_dir=NOVA_CONF_DIR),
98
98
                     context.SharedDBContext(
99
99
                         relation_prefix='nova', ssl_dir=NOVA_CONF_DIR),
 
100
                     nova_cc_context.NovaPostgresqlDBContext(),
100
101
                     context.ImageServiceContext(),
101
102
                     context.OSConfigFlagContext(),
102
103
                     context.SubordinateConfigContext(
103
104
                         interface='nova-vmware',
104
105
                         service='nova',
105
 
                         config_file=NOVA_CONF,
106
 
                     ),
 
106
                         config_file=NOVA_CONF),
107
107
                     context.SubordinateConfigContext(
108
108
                         interface='cell',
109
109
                         service='nova',
110
 
                         config_file=NOVA_CONF,
111
 
                     ),
 
110
                         config_file=NOVA_CONF),
112
111
                     context.SyslogContext(),
113
112
                     nova_cc_context.HAProxyContext(),
114
113
                     nova_cc_context.IdentityServiceContext(),
115
 
                     nova_cc_context.VolumeServiceContext(),
116
 
                     nova_cc_context.NovaCellContext()],
 
114
                     nova_cc_context.VolumeServiceContext()],
117
115
    }),
118
116
    (NOVA_API_PASTE, {
119
117
        'services': [s for s in BASE_SERVICES if 'api' in s],
200
198
        resource_map.pop(APACHE_24_CONF)
201
199
 
202
200
    if is_relation_made('neutron-api'):
203
 
        resource_map.pop(QUANTUM_CONF)
204
 
        resource_map.pop(QUANTUM_DEFAULT)
205
 
        resource_map.pop(NEUTRON_CONF)
206
 
        resource_map.pop(NEUTRON_DEFAULT)
 
201
        [resource_map.pop(k) for k in list(resource_map.iterkeys())
 
202
         if 'quantum' in k or 'neutron' in k]
207
203
        resource_map[NOVA_CONF]['contexts'].append(
208
204
            nova_cc_context.NeutronAPIContext())
209
205
    else:
210
206
        resource_map[NOVA_CONF]['contexts'].append(
211
207
            nova_cc_context.NeutronCCContext())
212
 
        resource_map[NOVA_CONF]['contexts'].append(
213
 
            nova_cc_context.NeutronPostgresqlDBContext())
214
208
        # pop out irrelevant resources from the OrderedDict (easier than adding
215
209
        # them late)
216
210
        if net_manager != 'quantum':
219
213
        if net_manager != 'neutron':
220
214
            [resource_map.pop(k) for k in list(resource_map.iterkeys())
221
215
             if 'neutron' in k]
222
 
    
223
 
    
224
 
        # add neutron plugin requirements. nova-c-c only needs the neutron-server
225
 
        # associated with configs, not the plugin agent.
 
216
        # add neutron plugin requirements. nova-c-c only needs the
 
217
        # neutron-server associated with configs, not the plugin agent.
226
218
        if net_manager in ['quantum', 'neutron']:
227
219
            plugin = neutron_plugin()
228
220
            if plugin:
229
221
                conf = neutron_plugin_attribute(plugin, 'config', net_manager)
230
 
                ctxts = (neutron_plugin_attribute(plugin, 'contexts', net_manager)
 
222
                ctxts = (neutron_plugin_attribute(plugin, 'contexts',
 
223
                                                  net_manager)
231
224
                         or [])
232
225
                services = neutron_plugin_attribute(plugin, 'server_services',
233
226
                                                    net_manager)
236
229
                resource_map[conf]['contexts'] = ctxts
237
230
                resource_map[conf]['contexts'].append(
238
231
                    nova_cc_context.NeutronCCContext())
239
 
    
 
232
 
240
233
                # update for postgres
241
234
                resource_map[conf]['contexts'].append(
242
235
                    nova_cc_context.NeutronPostgresqlDBContext())
243
 
       
 
236
 
244
237
    # nova-conductor for releases >= G.
245
238
    if os_release('nova-common') not in ['essex', 'folsom']:
246
239
        resource_map['/etc/nova/nova.conf']['services'] += ['nova-conductor']
254
247
        for s in vmware_ctxt['services']:
255
248
            if s not in resource_map[NOVA_CONF]['services']:
256
249
                resource_map[NOVA_CONF]['services'].append(s)
 
250
 
257
251
    novacell_ctxt = context.SubordinateConfigContext(interface='cell',
258
252
                                                     service='nova',
259
253
                                                     config_file=NOVA_CONF)
464
458
        # NOTE(jamespage) upgrade with existing config files as the
465
459
        # havana->icehouse migration enables new service_plugins which
466
460
        # create issues with db upgrades
 
461
        neutron_db_manage(['stamp', cur_os_rel])
467
462
        neutron_db_manage(['upgrade', 'head'])
468
463
        reset_os_release()
469
464
        configs = register_configs(release=new_os_rel)
606
601
    # known hosts entry for its IP, hostname and FQDN.
607
602
    private_address = relation_get('private-address')
608
603
    hosts = [private_address]
 
604
    if relation_get('hostname'):
 
605
        hosts.append(relation_get('hostname'))
609
606
 
610
607
    if not is_ip(private_address):
611
608
        hosts.append(get_host_ip(private_address))
649
646
    [keys.remove(key) for key in keys if key == public_key]
650
647
 
651
648
    with open(authorized_keys(user), 'w') as _keys:
652
 
        _keys.write('\n'.join(keys) + '\n')
 
649
        keys = '\n'.join(keys)
 
650
        if not keys.endswith('\n'):
 
651
            keys += '\n'
 
652
        _keys.write(keys)
653
653
 
654
654
 
655
655
def determine_endpoints(url):
699
699
        })
700
700
 
701
701
    # XXX: Keep these relations named quantum_*??
702
 
    if network_manager() in ['quantum', 'neutron']:
 
702
    if is_relation_made('neutron-api'):
 
703
        endpoints.update({
 
704
            'quantum_service': None,
 
705
            'quantum_region': None,
 
706
            'quantum_public_url': None,
 
707
            'quantum_admin_url': None,
 
708
            'quantum_internal_url': None,
 
709
        })
 
710
    elif network_manager() in ['quantum', 'neutron']:
703
711
        endpoints.update({
704
712
            'quantum_service': 'quantum',
705
713
            'quantum_region': region,