def restart_map(): '''Determine the correct resource map to be passed to charmhelpers.core.restart_on_change() based on the services configured. :returns: dict: A dictionary mapping config file to lists of services that should be restarted when file changes. ''' _map = [] cmp_release = CompareOpenStackReleases(os_release('glance-common')) for f, ctxt in CONFIG_FILES.items(): svcs = [] for svc in ctxt['services']: if cmp_release >= 'stein' and svc == 'glance-registry': continue svcs.append(svc) if svcs: _map.append((f, svcs)) if enable_memcache(source=config('openstack-origin')): _map.append((MEMCACHED_CONF, ['memcached'])) if cmp_release >= 'stein': _map.append((GLANCE_POLICY_FILE, ['glance-api'])) else: _map.append((GLANCE_POLICY_FILE, ['glance-api', 'glance-registry'])) return OrderedDict(_map)
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 restart_map(): '''Determine the correct resource map to be passed to charmhelpers.core.restart_on_change() based on the services configured. :returns: dict: A dictionary mapping config file to lists of services that should be restarted when file changes. ''' _map = [] cmp_release = CompareOpenStackReleases(os_release('glance-common')) for f, ctxt in CONFIG_FILES.items(): svcs = [] for svc in ctxt['services']: if cmp_release >= 'stein' and svc == 'glance-registry': continue svcs.append(svc) if svcs: _map.append((f, svcs)) if enable_memcache(source=config('openstack-origin')): _map.append((MEMCACHED_CONF, ['memcached'])) if cmp_release >= 'stein': glance_svcs = ['glance-api'] else: glance_svcs = ['glance-api', 'glance-registry'] _map.append((GLANCE_POLICY_FILE, glance_svcs)) if os.path.isdir(APACHE_SSL_DIR): _map.append(('{}/*'.format(APACHE_SSL_DIR), glance_svcs + ['apache2'])) return OrderedDict(_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 config_changed_postupgrade(): save_script_rc() release = os_release('keystone') if run_in_apache(release=release): # Need to ensure mod_wsgi is installed and apache2 is reloaded # immediatly as charm querys its local keystone before restart # decorator can fire apt_install(filter_installed_packages(determine_packages())) # when deployed from source, init scripts aren't installed service_pause('keystone') disable_unused_apache_sites() if WSGI_KEYSTONE_API_CONF in CONFIGS.templates: CONFIGS.write(WSGI_KEYSTONE_API_CONF) if not is_unit_paused_set(): restart_pid_check('apache2') stop_manager_instance() if enable_memcache(release=release): # If charm or OpenStack have been upgraded then the list of required # packages may have changed so ensure they are installed. apt_install(filter_installed_packages(determine_packages())) if is_leader() and fernet_enabled(): key_setup() key_leader_set() configure_https() open_port(config('service-port')) update_nrpe_config() CONFIGS.write_all() if snap_install_requested() and not is_unit_paused_set(): service_restart('snap.keystone.*') stop_manager_instance() if (is_db_initialised() and is_elected_leader(CLUSTER_RES) and not is_unit_paused_set()): ensure_initial_admin(config) if CompareOpenStackReleases( os_release('keystone')) >= 'liberty': CONFIGS.write(POLICY_JSON) update_all_identity_relation_units() update_all_domain_backends() update_all_fid_backends() for r_id in relation_ids('ha'): ha_joined(relation_id=r_id) notify_middleware_with_release_version() inform_peers_if_ready(check_api_unit_ready)
def config_changed_postupgrade(): save_script_rc() release = os_release('keystone') if run_in_apache(release=release): # Need to ensure mod_wsgi is installed and apache2 is reloaded # immediatly as charm querys its local keystone before restart # decorator can fire apt_install(filter_installed_packages(determine_packages())) # when deployed from source, init scripts aren't installed service_pause('keystone') disable_unused_apache_sites() if WSGI_KEYSTONE_API_CONF in CONFIGS.templates: CONFIGS.write(WSGI_KEYSTONE_API_CONF) if not is_unit_paused_set(): restart_pid_check('apache2') stop_manager_instance() if enable_memcache(release=release): # If charm or OpenStack have been upgraded then the list of required # packages may have changed so ensure they are installed. apt_install(filter_installed_packages(determine_packages())) if is_leader() and fernet_enabled(): key_setup() key_leader_set() configure_https() open_port(config('service-port')) update_nrpe_config() CONFIGS.write_all() if snap_install_requested() and not is_unit_paused_set(): service_restart('snap.keystone.*') stop_manager_instance() if (is_db_initialised() and is_elected_leader(CLUSTER_RES) and not is_unit_paused_set()): ensure_initial_admin(config) if CompareOpenStackReleases( os_release('keystone')) >= 'liberty': CONFIGS.write(POLICY_JSON) update_all_identity_relation_units() update_all_domain_backends() update_all_fid_backends() for r_id in relation_ids('ha'): ha_joined(relation_id=r_id) notify_middleware_with_release_version()
def config_changed_postupgrade(): # Ensure ssl dir exists and is unison-accessible ensure_ssl_dir() if not snap_install_requested(): check_call(['chmod', '-R', 'g+wrx', '/var/lib/keystone/']) ensure_ssl_dirs() save_script_rc() release = os_release('keystone') if run_in_apache(release=release): # Need to ensure mod_wsgi is installed and apache2 is reloaded # immediatly as charm querys its local keystone before restart # decorator can fire apt_install(filter_installed_packages(determine_packages())) # when deployed from source, init scripts aren't installed service_pause('keystone') disable_unused_apache_sites() if WSGI_KEYSTONE_API_CONF in CONFIGS.templates: CONFIGS.write(WSGI_KEYSTONE_API_CONF) if not is_unit_paused_set(): restart_pid_check('apache2') if enable_memcache(release=release): # If charm or OpenStack have been upgraded then the list of required # packages may have changed so ensure they are installed. apt_install(filter_installed_packages(determine_packages())) configure_https() open_port(config('service-port')) update_nrpe_config() CONFIGS.write_all() if snap_install_requested() and not is_unit_paused_set(): service_restart('snap.keystone.*') initialise_pki() update_all_identity_relation_units() update_all_domain_backends() update_all_fid_backends() # Ensure sync request is sent out (needed for any/all ssl change) send_ssl_sync_request() for r_id in relation_ids('ha'): ha_joined(relation_id=r_id)
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 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'] = [] 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 resource_map(release=None): """ Dynamically generate a map of resources that will be managed for a single hook execution. """ _release = release or os_release('heat-common', base='icehouse') _resource_map = deepcopy(CONFIG_FILES) if os.path.exists('/etc/apache2/conf-available'): _resource_map.pop(HTTPS_APACHE_CONF) else: _resource_map.pop(HTTPS_APACHE_24_CONF) if not enable_memcache(release=_release): _resource_map.pop(MEMCACHED_CONF) 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: 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']) return configs
def restart_map(): '''Determine the correct resource map to be passed to charmhelpers.core.restart_on_change() based on the services configured. :returns: dict: A dictionary mapping config file to lists of services that should be restarted when file changes. ''' _map = [] for f, ctxt in CONFIG_FILES.iteritems(): svcs = [] for svc in ctxt['services']: svcs.append(svc) if svcs: _map.append((f, svcs)) if enable_memcache(source=config('openstack-origin')): _map.append((MEMCACHED_CONF, ['memcached'])) return OrderedDict(_map)
def restart_map(): ''' Determine the correct resource map to be passed to charmhelpers.core.restart_on_change() based on the services configured. :returns: dict: A dictionary mapping config file to lists of services that should be restarted when file changes. ''' release = (get_os_codename_package('ceilometer-common', fatal=False) or 'icehouse') _map = {} for f, ctxt in CONFIG_FILES.iteritems(): svcs = [] for svc in ctxt['services']: svcs.append(svc) if svcs: _map[f] = svcs if enable_memcache(release=release): _map[MEMCACHED_CONF] = ['memcached'] return _map
def register_configs(): release = os_release('heat-common') configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, openstack_release=release) confs = [HEAT_CONF, HEAT_API_PASTE, HAPROXY_CONF, ADMIN_OPENRC] for conf in confs: configs.register(conf, CONFIG_FILES[conf]['contexts']) if os.path.exists('/etc/apache2/conf-available'): configs.register(HTTPS_APACHE_24_CONF, CONFIG_FILES[HTTPS_APACHE_24_CONF]['contexts']) else: configs.register(HTTPS_APACHE_CONF, CONFIG_FILES[HTTPS_APACHE_CONF]['contexts']) if enable_memcache(release=release): configs.register(MEMCACHED_CONF, CONFIG_FILES[MEMCACHED_CONF]['hook_contexts']) return configs
def restart_map(): ''' Determine the correct resource map to be passed to charmhelpers.core.restart_on_change() based on the services configured. :returns: dict: A dictionary mapping config file to lists of services that should be restarted when file changes. ''' release = (get_os_codename_package('ceilometer-common', fatal=False) or 'icehouse') _map = {} for f, ctxt in CONFIG_FILES.items(): svcs = [] for svc in ctxt['services']: svcs.append(svc) if svcs: _map[f] = svcs if enable_memcache(release=release): _map[MEMCACHED_CONF] = ['memcached'] return _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) \ 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
def restart_map(): """ Determine the correct resource map to be passed to charmhelpers.core.restart_on_change() based on the services configured. :returns: dict: A dictionary mapping config file to lists of services that should be restarted when file changes. """ cmp_codename = CompareOpenStackReleases( get_os_codename_install_source(config('openstack-origin'))) if cmp_codename >= 'queens': _config_files = QUEENS_CONFIG_FILES else: _config_files = CONFIG_FILES _map = {} for f, ctxt in _config_files.items(): svcs = [] for svc in ctxt['services']: svcs.append(svc) if f == CEILOMETER_CONF: for svc in ceilometer_release_services(): svcs.append(svc) if svcs: _map[f] = svcs if (cmp_codename < 'queens' and enable_memcache(source=config('openstack-origin'))): _map[MEMCACHED_CONF] = ['memcached'] if cmp_codename < 'queens' and run_in_apache(): for cfile in _map: svcs = _map[cfile] if 'ceilometer-api' in svcs: svcs.remove('ceilometer-api') if 'apache2' not in svcs: svcs.append('apache2') _map['WSGI_CEILOMETER_API_CONF'] = ['apache2'] return _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) \ 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(package='ceilometer-common')]) return configs
def test_enable_memcache(self, _get_os_codename_install_source, _os_release): # Check call with 'release' self.assertFalse(utils.enable_memcache(release='icehouse')) self.assertTrue(utils.enable_memcache(release='ocata')) # Check call with 'source' _os_release.return_value = None _get_os_codename_install_source.return_value = 'icehouse' self.assertFalse(utils.enable_memcache(source='distro')) _os_release.return_value = None _get_os_codename_install_source.return_value = 'ocata' self.assertTrue(utils.enable_memcache(source='distro')) # Check call with 'package' _os_release.return_value = 'icehouse' _get_os_codename_install_source.return_value = None self.assertFalse(utils.enable_memcache(package='pkg1')) _os_release.return_value = 'ocata' _get_os_codename_install_source.return_value = None self.assertTrue(utils.enable_memcache(package='pkg1'))
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
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
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) release = release or os_release('cinder-common', base='icehouse') 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') and hook_name() != 'ceph-relation-broken': # 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'] } if release and CompareOpenStackReleases(release) < 'queens': resource_map.pop(CINDER_POLICY_JSON) return resource_map