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
def register_configs(): """ Register config files with their respective contexts. Regstration of some configs may not be required depending on existing of certain relations. """ # if called without anything installed (eg during install hook) # just default to earliest supported release. configs dont get touched # till post-install, anyway. release = get_os_codename_package('ceilometer-common', fatal=False) configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, openstack_release=release) if not release: log("Not installed yet, no way to determine the OS release. " "Skipping register configs", DEBUG) return configs if CompareOpenStackReleases(release) >= 'queens': for conf in QUEENS_CONFIG_FILES: configs.register(conf, QUEENS_CONFIG_FILES[conf]['hook_contexts']) configs.register(PIPELINE_CONF, [RemoteSinksContext()]) else: for conf in (CEILOMETER_CONF, HAPROXY_CONF): configs.register(conf, CONFIG_FILES[conf]['hook_contexts']) if init_is_systemd(): configs.register( CEILOMETER_API_SYSTEMD_CONF, CONFIG_FILES[CEILOMETER_API_SYSTEMD_CONF]['hook_contexts'] ) if os.path.exists('/etc/apache2/conf-available'): configs.register( HTTPS_APACHE_24_CONF, CONFIG_FILES[HTTPS_APACHE_24_CONF]['hook_contexts'] ) else: configs.register( HTTPS_APACHE_CONF, CONFIG_FILES[HTTPS_APACHE_CONF]['hook_contexts'] ) if enable_memcache(release=release): configs.register(MEMCACHED_CONF, [context.MemcacheContext()]) if run_in_apache(): wsgi_script = "/usr/share/ceilometer/app.wsgi" configs.register( WSGI_CEILOMETER_API_CONF, [context.WSGIWorkerConfigContext(name="ceilometer", script=wsgi_script), CeilometerContext(), HAProxyContext()] ) if CompareOpenStackReleases(release) >= 'mitaka': configs.register(PIPELINE_CONF, [RemoteSinksContext()]) return configs
def resource_map(release=None): ''' Dynamically generate a map of resources that will be managed for a single hook execution. ''' release = release or os_release('neutron-common') resource_map = deepcopy(BASE_RESOURCE_MAP) if CompareOpenStackReleases(release) >= 'liberty': resource_map.update(LIBERTY_RESOURCE_MAP) if os.path.exists('/etc/apache2/conf-available'): resource_map.pop(APACHE_CONF) else: resource_map.pop(APACHE_24_CONF) if manage_plugin(): # add neutron plugin requirements. nova-c-c only needs the # neutron-server associated with configs, not the plugin agent. plugin = config('neutron-plugin') conf = neutron_plugin_attribute(plugin, 'config', 'neutron') ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or []) services = neutron_plugin_attribute(plugin, 'server_services', 'neutron') resource_map[conf] = {} resource_map[conf]['services'] = services resource_map[conf]['contexts'] = ctxts resource_map[conf]['contexts'].append( neutron_api_context.NeutronCCContext()) if ('kilo' <= CompareOpenStackReleases(release) <= 'mitaka' and config('enable-sriov')): resource_map[ML2_SRIOV_INI] = {} resource_map[ML2_SRIOV_INI]['services'] = services resource_map[ML2_SRIOV_INI]['contexts'] = [] if (config('enable-arista')): resource_map[NEUTRON_DEFAULT]['contexts'] = \ [neutron_api_context.NeutronApiSDNConfigFileContext()] else: resource_map[NEUTRON_CONF]['contexts'].append( neutron_api_context.NeutronApiSDNContext()) resource_map[NEUTRON_DEFAULT]['contexts'] = \ [neutron_api_context.NeutronApiSDNConfigFileContext()] if enable_memcache(release=release): resource_map[MEMCACHED_CONF] = { 'contexts': [context.MemcacheContext()], 'services': ['memcached'] } return resource_map
def register_configs(): # Register config files with their respective contexts. # Regstration of some configs may not be required depending on # existing of certain relations. release = os_release('glance-common') cmp_release = CompareOpenStackReleases(release) configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, openstack_release=release) confs = [GLANCE_REGISTRY_CONF, GLANCE_API_CONF, HAPROXY_CONF] if relation_ids('ceph'): mkdir(os.path.dirname(ceph_config_file())) mkdir(os.path.dirname(CEPH_CONF)) # Install ceph config as an alternative for co-location with # ceph and ceph-osd charms - glance ceph.conf will be # lower priority that 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()) confs.append(ceph_config_file()) for conf in confs: if cmp_release >= 'stein' and conf == GLANCE_REGISTRY_CONF: continue configs.register(conf, CONFIG_FILES[conf]['hook_contexts']) if os.path.exists('/etc/apache2/conf-available'): configs.register(HTTPS_APACHE_24_CONF, CONFIG_FILES[HTTPS_APACHE_24_CONF]['hook_contexts']) else: configs.register(HTTPS_APACHE_CONF, CONFIG_FILES[HTTPS_APACHE_CONF]['hook_contexts']) if enable_memcache(release=release): configs.register(MEMCACHED_CONF, [context.MemcacheContext()]) if cmp_release >= 'mitaka': configs.register(GLANCE_SWIFT_CONF, CONFIG_FILES[GLANCE_SWIFT_CONF]['hook_contexts']) if cmp_release >= 'ussuri': configs.register(GLANCE_POLICY_YAML, CONFIG_FILES[GLANCE_POLICY_YAML]['hook_contexts']) return configs
def register_configs(): """ Register config files with their respective contexts. Regstration of some configs may not be required depending on existing of certain relations. """ # if called without anything installed (eg during install hook) # just default to earliest supported release. configs dont get touched # till post-install, anyway. release = get_os_codename_package('ceilometer-common', fatal=False) \ or 'icehouse' configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, openstack_release=release) for conf in CONFIG_FILES: configs.register(conf, CONFIG_FILES[conf]['hook_contexts']) if enable_memcache(release=release): configs.register(MEMCACHED_CONF, [context.MemcacheContext()]) return configs
return CHARM_CEPH_CONF.format(service_name()) CONFIG_FILES = OrderedDict([ (GLANCE_REGISTRY_CONF, { 'hook_contexts': [ context.SharedDBContext(ssl_dir=GLANCE_CONF_DIR), context.IdentityServiceContext(service='glance', service_user='******'), context.SyslogContext(), glance_contexts.LoggingConfigContext(), glance_contexts.GlanceIPv6Context(), context.WorkerConfigContext(), context.OSConfigFlagContext(charm_flag='registry-config-flags', template_flag='registry_config_flags'), context.MemcacheContext() ], 'services': ['glance-registry'] }), (GLANCE_API_CONF, { 'hook_contexts': [ context.SharedDBContext(ssl_dir=GLANCE_CONF_DIR), context.AMQPContext(ssl_dir=GLANCE_CONF_DIR), context.IdentityServiceContext(service='glance', service_user='******'), glance_contexts.GlanceContext(), glance_contexts.CephGlanceContext(), glance_contexts.ObjectStoreContext(), glance_contexts.CinderStoreContext(), glance_contexts.HAProxyContext(), context.SyslogContext(),
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
CEILOMETER_ROLE = "ResellerAdmin" SVC = 'ceilometer' WSGI_CEILOMETER_API_CONF = '/etc/apache2/sites-enabled/wsgi-openstack-api.conf' PACKAGE_CEILOMETER_API_CONF = '/etc/apache2/sites-enabled/ceilometer-api.conf' QUEENS_CONFIG_FILES = OrderedDict([ (CEILOMETER_CONF, { 'hook_contexts': [ context.IdentityCredentialsContext(service=SVC, service_user=SVC), context.AMQPContext(ssl_dir=CEILOMETER_CONF_DIR), LoggingConfigContext(), MongoDBContext(), CeilometerContext(), context.SyslogContext(), context.MemcacheContext(), MetricServiceContext(), context.WorkerConfigContext()], 'services': QUEENS_SERVICES }), ]) CONFIG_FILES = OrderedDict([ (CEILOMETER_CONF, { 'hook_contexts': [context.IdentityServiceContext(service=SVC, service_user=SVC), context.AMQPContext(ssl_dir=CEILOMETER_CONF_DIR), context.InternalEndpointContext('ceilometer-common'), LoggingConfigContext(), MongoDBContext(), CeilometerContext(),
def resource_map(release=None): ''' Dynamically generate a map of resources that will be managed for a single hook execution. ''' release = release or os_release('neutron-common') resource_map = deepcopy(BASE_RESOURCE_MAP) if CompareOpenStackReleases(release) >= 'liberty': resource_map.update(LIBERTY_RESOURCE_MAP) if CompareOpenStackReleases(release) >= 'train': resource_map.pop(NEUTRON_LBAAS_CONF) if os.path.exists('/etc/apache2/conf-available'): resource_map.pop(APACHE_CONF) else: resource_map.pop(APACHE_24_CONF) if manage_plugin(): # add neutron plugin requirements. nova-c-c only needs the # neutron-server associated with configs, not the plugin agent. plugin = config('neutron-plugin') conf = neutron_plugin_attribute(plugin, 'config', 'neutron') ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or []) services = neutron_plugin_attribute(plugin, 'server_services', 'neutron') resource_map[conf] = {} resource_map[conf]['services'] = services resource_map[conf]['contexts'] = ctxts resource_map[conf]['contexts'].append( neutron_api_context.NeutronCCContext()) if ('kilo' <= CompareOpenStackReleases(release) <= 'mitaka' and config('enable-sriov')): resource_map[ML2_SRIOV_INI] = {} resource_map[ML2_SRIOV_INI]['services'] = services resource_map[ML2_SRIOV_INI]['contexts'] = [] else: plugin_ctxt_instance = neutron_api_context.NeutronApiSDNContext() if (plugin_ctxt_instance.is_default('core_plugin') and plugin_ctxt_instance.is_default('neutron_plugin_config')): # The default core plugin is ML2. If the driver provided by plugin # subordinate is built on top of ML2, the subordinate will have use # for influencing existing template variables as well as injecting # sections into the ML2 configuration file. conf = neutron_plugin_attribute('ovs', 'config', 'neutron') services = neutron_plugin_attribute('ovs', 'server_services', 'neutron') if conf not in resource_map: resource_map[conf] = {} resource_map[conf]['services'] = services resource_map[conf]['contexts'] = [ neutron_api_context.NeutronCCContext(), ] resource_map[conf]['contexts'].append( neutron_api_context.NeutronApiSDNContext( config_file=conf) ) resource_map[NEUTRON_CONF]['contexts'].append( plugin_ctxt_instance, ) resource_map[NEUTRON_DEFAULT]['contexts'] = \ [neutron_api_context.NeutronApiSDNConfigFileContext()] if enable_memcache(release=release): resource_map[MEMCACHED_CONF] = { 'contexts': [context.MemcacheContext()], 'services': ['memcached']} return resource_map
'services': BASE_SERVICES, 'contexts': [ context.AMQPContext(ssl_dir=HEAT_DIR), context.SharedDBContext(relation_prefix='heat', ssl_dir=HEAT_DIR), context.OSConfigFlagContext(), context.InternalEndpointContext(), HeatIdentityServiceContext(service=SVC, service_user=SVC), HeatHAProxyContext(), HeatSecurityContext(), InstanceUserContext(), context.SyslogContext(), context.LogLevelContext(), context.WorkerConfigContext(), context.BindHostContext(), context.MemcacheContext(), context.OSConfigFlagContext() ], }), (HEAT_API_PASTE, { 'services': [s for s in BASE_SERVICES if 'api' in s], 'contexts': [HeatIdentityServiceContext()], }), (HAPROXY_CONF, { 'contexts': [context.HAProxyContext(singlenode_mode=True), HeatHAProxyContext()], 'services': ['haproxy'], }), (HTTPS_APACHE_CONF, { 'contexts': [HeatApacheSSLContext()],