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 test_configset(self): self.test_relation.set( {'neutron-plugin-config': '/etc/neutron/superplugin.ini'}) self.relation_ids.return_value = ['rid2'] self.related_units.return_value = ['unit1'] napisdn_ctxt = context.NeutronApiSDNConfigFileContext()() self.assertEquals(napisdn_ctxt, {'config': '/etc/neutron/superplugin.ini'})
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 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()) # update for postgres resource_map[conf]['contexts'].append( context.PostgresqlDBContext(database=config('database'))) else: resource_map[NEUTRON_CONF]['contexts'].append( neutron_api_context.NeutronApiSDNContext() ) resource_map[NEUTRON_DEFAULT]['contexts'] = \ [neutron_api_context.NeutronApiSDNConfigFileContext()] return resource_map
def test_default(self): self.relation_ids.return_value = [] napisdn_ctxt = context.NeutronApiSDNConfigFileContext()() self.assertEquals(napisdn_ctxt, {'config': '/etc/neutron/plugins/ml2/ml2_conf.ini'})
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