コード例 #1
0
def resource_map(release=None):
    """
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    """
    resource_map = deepcopy(BASE_RESOURCE_MAP)
    if relation_ids('backup-backend'):
        resource_map[CINDER_CONF]['services'].append('cinder-backup')
        resource_map[ceph_config_file()]['services'].append('cinder-backup')

    if relation_ids('ceph'):
        # need to create this early, new peers will have a relation during
        # registration # before they've run the ceph hooks to create the
        # directory.
        # !!! FIX: These side effects seem inappropriate for this method
        mkdir(os.path.dirname(CEPH_CONF))
        mkdir(os.path.dirname(ceph_config_file()))

        # Install ceph config as an alternative for co-location with
        # ceph and ceph-osd charm - cinder ceph.conf will be
        # lower priority than both of these but thats OK
        if not os.path.exists(ceph_config_file()):
            # touch file for pre-templated generation
            open(ceph_config_file(), 'w').close()
        install_alternative(os.path.basename(CEPH_CONF),
                            CEPH_CONF, ceph_config_file())
    else:
        resource_map.pop(ceph_config_file())

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_SITE_CONF)
    else:
        resource_map.pop(APACHE_SITE_24_CONF)

    # Remove services from map which are not enabled by user config
    for cfg in resource_map.keys():
        resource_map[cfg]['services'] = \
            filter_services(resource_map[cfg]['services'])

    if enable_memcache(source=config()['openstack-origin']):
        resource_map[MEMCACHED_CONF] = {
            'contexts': [context.MemcacheContext()],
            'services': ['memcached']}

    if run_in_apache():
        for cfile in resource_map:
            svcs = resource_map[cfile]['services']
            if 'cinder-api' in svcs:
                svcs.remove('cinder-api')
                if 'apache2' not in svcs:
                    svcs.append('apache2')
        wsgi_script = "/usr/bin/cinder-wsgi"
        resource_map[WSGI_CINDER_API_CONF] = {
            'contexts': [context.WSGIWorkerConfigContext(name="cinder",
                                                         script=wsgi_script),
                         cinder_contexts.HAProxyContext()],
            'services': ['apache2']
        }

    return resource_map
コード例 #2
0
    return _interfaces


# Map config files to hook contexts and services that will be associated
# with file in restart_on_changes()'s service map.
BASE_RESOURCE_MAP = OrderedDict([
    (CINDER_CONF, {
        'contexts': [
            context.SharedDBContext(ssl_dir=CINDER_CONF_DIR),
            context.AMQPContext(ssl_dir=CINDER_CONF_DIR),
            context.ImageServiceContext(),
            context.OSConfigFlagContext(),
            context.SyslogContext(),
            cinder_contexts.CephContext(),
            cinder_contexts.HAProxyContext(),
            cinder_contexts.ImageServiceContext(),
            cinder_contexts.CinderSubordinateConfigContext(
                interface=['storage-backend', 'backup-backend'],
                service='cinder',
                config_file=CINDER_CONF),
            cinder_contexts.StorageBackendContext(),
            cinder_contexts.LoggingConfigContext(),
            context.IdentityServiceContext(service='cinder',
                                           service_user='******'),
            context.BindHostContext(),
            context.WorkerConfigContext(),
            cinder_contexts.RegionContext(),
            context.InternalEndpointContext(),
            cinder_contexts.VolumeUsageAuditContext(),
            context.MemcacheContext(),