def resource_map():
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    resource_map = deepcopy(BASE_RESOURCE_MAP)

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

    resource_map[NOVA_CONF]['contexts'].append(
        nova_cc_context.NeutronCCContext())

    if os_release('nova-common') >= 'mitaka':
        resource_map[NOVA_CONF]['contexts'].append(
            nova_cc_context.NovaAPISharedDBContext(relation_prefix='novaapi',
                                                   database='nova_api',
                                                   ssl_dir=NOVA_CONF_DIR))

    if console_attributes('services'):
        resource_map[NOVA_CONF]['services'] += \
            console_attributes('services')

    if (config('enable-serial-console')
            and os_release('nova-common') >= 'juno'):
        resource_map[NOVA_CONF]['services'] += \
            SERIAL_CONSOLE['services']

    # also manage any configs that are being updated by subordinates.
    vmware_ctxt = context.SubordinateConfigContext(interface='nova-vmware',
                                                   service='nova',
                                                   config_file=NOVA_CONF)
    vmware_ctxt = vmware_ctxt()
    if vmware_ctxt and 'services' in vmware_ctxt:
        for s in vmware_ctxt['services']:
            if s not in resource_map[NOVA_CONF]['services']:
                resource_map[NOVA_CONF]['services'].append(s)

    return resource_map
示例#2
0
                                        service_user='******'),
         glance_contexts.GlanceContext(),
         glance_contexts.CephGlanceContext(),
         glance_contexts.ObjectStoreContext(),
         glance_contexts.CinderStoreContext(),
         glance_contexts.HAProxyContext(),
         context.SyslogContext(),
         glance_contexts.LoggingConfigContext(),
         glance_contexts.GlanceIPv6Context(),
         context.WorkerConfigContext(),
         glance_contexts.MultiStoreContext(),
         context.OSConfigFlagContext(charm_flag='api-config-flags',
                                     template_flag='api_config_flags'),
         context.InternalEndpointContext('glance-common'),
         context.SubordinateConfigContext(interface=['storage-backend'],
                                          service=['glance-api'],
                                          config_file=GLANCE_API_CONF),
         context.MemcacheContext()
     ],
     'services': ['glance-api']
 }),
 (ceph_config_file(), {
     'hook_contexts': [context.CephContext()],
     'services': ['glance-api', 'glance-registry']
 }),
 (HAPROXY_CONF, {
     'hook_contexts': [
         context.HAProxyContext(singlenode_mode=True),
         glance_contexts.HAProxyContext()
     ],
     'services': ['haproxy'],
示例#3
0
def resource_map(actual_services=True):
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.

    :param actual_services: Whether to return the actual services that run on a
        unit (ie. apache2) or the services defined in BASE_SERVICES
        (ie.nova-placement-api).
    '''
    resource_map = deepcopy(BASE_RESOURCE_MAP)

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

    resource_map[NOVA_CONF]['contexts'].append(
        nova_cc_context.NeutronCCContext())

    release = os_release('nova-common')
    cmp_os_release = CompareOpenStackReleases(release)
    if cmp_os_release >= 'mitaka':
        resource_map[NOVA_CONF]['contexts'].append(
            nova_cc_context.NovaAPISharedDBContext(relation_prefix='novaapi',
                                                   database='nova_api',
                                                   ssl_dir=NOVA_CONF_DIR))

    if console_attributes('services'):
        resource_map[NOVA_CONF]['services'] += console_attributes('services')
        # nova-consoleauth will be managed by pacemaker, if
        # single-nova-consoleauth is used, then don't monitor for the
        # nova-consoleauth service to be started (LP: #1660244).
        if config('single-nova-consoleauth') and relation_ids('ha'):
            services = resource_map[NOVA_CONF]['services']
            if 'nova-consoleauth' in services:
                services.remove('nova-consoleauth')

    if (config('enable-serial-console') and cmp_os_release >= 'juno'):
        resource_map[NOVA_CONF]['services'] += SERIAL_CONSOLE['services']

    # also manage any configs that are being updated by subordinates.
    vmware_ctxt = context.SubordinateConfigContext(interface='nova-vmware',
                                                   service='nova',
                                                   config_file=NOVA_CONF)
    vmware_ctxt = vmware_ctxt()
    if vmware_ctxt and 'services' in vmware_ctxt:
        for s in vmware_ctxt['services']:
            if s not in resource_map[NOVA_CONF]['services']:
                resource_map[NOVA_CONF]['services'].append(s)

    if enable_memcache(release=release):
        resource_map[MEMCACHED_CONF] = {
            'contexts': [context.MemcacheContext()],
            'services': ['memcached']
        }

    if actual_services and placement_api_enabled():
        for cfile in resource_map:
            svcs = resource_map[cfile]['services']
            if 'nova-placement-api' in svcs:
                svcs.remove('nova-placement-api')
                if 'apache2' not in svcs:
                    svcs.append('apache2')
        wsgi_script = "/usr/bin/nova-placement-api"
        resource_map[WSGI_NOVA_PLACEMENT_API_CONF] = {
            'contexts': [
                context.WSGIWorkerConfigContext(name="nova",
                                                script=wsgi_script),
                nova_cc_context.HAProxyContext()
            ],
            'services': ['apache2']
        }
    elif not placement_api_enabled():
        for cfile in resource_map:
            svcs = resource_map[cfile]['services']
            if 'nova-placement-api' in svcs:
                svcs.remove('nova-placement-api')

    return resource_map
示例#4
0

BASE_RESOURCE_MAP = OrderedDict([
    (NOVA_CONF, {
        'services':
        resolve_services(),
        'contexts': [
            context.AMQPContext(ssl_dir=NOVA_CONF_DIR),
            context.SharedDBContext(relation_prefix='nova',
                                    ssl_dir=NOVA_CONF_DIR),
            context.OSConfigFlagContext(charm_flag='nova-alchemy-flags',
                                        template_flag='nova_alchemy_flags'),
            context.ImageServiceContext(),
            context.OSConfigFlagContext(),
            context.SubordinateConfigContext(interface='nova-vmware',
                                             service='nova',
                                             config_file=NOVA_CONF),
            nova_cc_context.NovaCellContext(),
            context.SyslogContext(),
            context.LogLevelContext(),
            nova_cc_context.HAProxyContext(),
            nova_cc_context.IdentityServiceContext(service='nova',
                                                   service_user='******'),
            nova_cc_context.VolumeServiceContext(),
            context.ZeroMQContext(),
            context.NotificationDriverContext(),
            nova_cc_context.NovaIPv6Context(),
            nova_cc_context.NeutronCCContext(),
            nova_cc_context.NovaConfigContext(),
            nova_cc_context.InstanceConsoleContext(),
            nova_cc_context.ConsoleSSLContext(),
 NOVA_CONF: {
     'services': ['nova-compute'],
     'contexts': [
         context.AMQPContext(ssl_dir=NOVA_CONF_DIR),
         context.SharedDBContext(relation_prefix='nova',
                                 ssl_dir=NOVA_CONF_DIR),
         context.ImageServiceContext(),
         context.OSConfigFlagContext(),
         CloudComputeContext(),
         LxdContext(),
         NovaComputeLibvirtContext(),
         NovaComputeCephContext(),
         context.SyslogContext(),
         context.SubordinateConfigContext(interface=[
             'neutron-plugin', 'nova-ceilometer', 'ephemeral-backend'
         ],
                                          service=['nova-compute', 'nova'],
                                          config_file=NOVA_CONF),
         InstanceConsoleContext(),
         context.ZeroMQContext(),
         context.NotificationDriverContext(),
         MetadataServiceContext(),
         HostIPContext(),
         NovaComputeVirtContext(),
         context.LogLevelContext(),
         context.InternalEndpointContext(),
         context.VolumeAPIContext('nova-common'),
         SerialConsoleContext(),
         NovaComputeAvailabilityZoneContext(),
         context.WorkerConfigContext(),
         vaultlocker.VaultKVContext(vaultlocker.VAULTLOCKER_BACKEND),
示例#6
0
def resource_map():
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    resource_map = deepcopy(BASE_RESOURCE_MAP)

    if relation_ids('nova-volume-service'):
        # if we have a relation to a nova-volume service, we're
        # also managing the nova-volume API endpoint (legacy)
        resource_map['/etc/nova/nova.conf']['services'].append(
            'nova-api-os-volume')

    net_manager = network_manager()

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

    resource_map[NOVA_CONF]['contexts'].append(
        nova_cc_context.NeutronCCContext())
    # pop out irrelevant resources from the OrderedDict (easier than adding
    # them late)
    if net_manager != 'quantum':
        [
            resource_map.pop(k) for k in list(resource_map.iterkeys())
            if 'quantum' in k
        ]
    if net_manager != 'neutron':
        [
            resource_map.pop(k) for k in list(resource_map.iterkeys())
            if 'neutron' in k
        ]
    # add neutron plugin requirements. nova-c-c only needs the
    # neutron-server associated with configs, not the plugin agent.
    if net_manager in ['quantum', 'neutron']:
        plugin = neutron_plugin()
        if plugin:
            conf = neutron_plugin_attribute(plugin, 'config', net_manager)
            ctxts = (neutron_plugin_attribute(plugin, 'contexts', net_manager)
                     or [])
            services = neutron_plugin_attribute(plugin, 'server_services',
                                                net_manager)
            resource_map[conf] = {}
            resource_map[conf]['services'] = services
            resource_map[conf]['contexts'] = ctxts
            resource_map[conf]['contexts'].append(
                nova_cc_context.NeutronCCContext())

            # update for postgres
            resource_map[conf]['contexts'].append(
                nova_cc_context.NeutronPostgresqlDBContext())

    if is_relation_made('neutron-api'):
        for k in list(resource_map.iterkeys()):
            # neutron-api runs neutron services
            if 'quantum' in k or 'neutron' in k:
                resource_map[k]['services'] = []
        resource_map[NOVA_CONF]['contexts'].append(
            nova_cc_context.NeutronAPIContext())

    # nova-conductor for releases >= G.
    if os_release('nova-common') not in ['essex', 'folsom']:
        resource_map['/etc/nova/nova.conf']['services'] += ['nova-conductor']

    if console_attributes('services'):
        resource_map['/etc/nova/nova.conf']['services'] += \
            console_attributes('services')

    # also manage any configs that are being updated by subordinates.
    vmware_ctxt = context.SubordinateConfigContext(interface='nova-vmware',
                                                   service='nova',
                                                   config_file=NOVA_CONF)
    vmware_ctxt = vmware_ctxt()
    if vmware_ctxt and 'services' in vmware_ctxt:
        for s in vmware_ctxt['services']:
            if s not in resource_map[NOVA_CONF]['services']:
                resource_map[NOVA_CONF]['services'].append(s)

    return resource_map
NOVA_CONF = '{}/nova.conf'.format(NOVA_CONF_DIR)

BASE_RESOURCE_MAP = {
    NOVA_CONF: {
        'services': ['openstack-nova-compute'],
        'contexts': [
            context.AMQPContext(ssl_dir=NOVA_CONF_DIR),
            context.ImageServiceContext(),
            context.OSConfigFlagContext(),
            CloudComputeContext(),
            NovaComputeVirtContext(),
            SerialConsoleContext(),
            context.SyslogContext(),
            context.LogLevelContext(),
            context.SubordinateConfigContext(interface='nova-ceilometer',
                                             service='nova',
                                             config_file=NOVA_CONF)
        ],
    },
}

NEUTRON_CONF_DIR = "{}/etc/neutron".format(CHARM_SCRATCH_DIR)
NEUTRON_CONF = '{}/neutron.conf'.format(NEUTRON_CONF_DIR)

OVS_AGENT_CONF = ('{}/etc/neutron/plugins/ml2/'
                  'openvswitch_agent.ini'.format(CHARM_SCRATCH_DIR))

NEUTRON_RESOURCES = {
    NEUTRON_CONF: {
        'services': ['neutron-openvswitch-agent'],
        'contexts': [