diff --git a/etc/nova/nova-config-generator.conf b/etc/nova/nova-config-generator.conf index cb2d0728ab07..d6acda41363e 100644 --- a/etc/nova/nova-config-generator.conf +++ b/etc/nova/nova-config-generator.conf @@ -8,7 +8,6 @@ namespace = nova.cache_utils namespace = nova.cells namespace = nova.compute namespace = nova.network -namespace = nova.network.neutronv2 namespace = nova.virt namespace = oslo.cache namespace = oslo.log diff --git a/nova/conf/neutron.py b/nova/conf/neutron.py index eaf2faa58905..7ec920c936f6 100644 --- a/nova/conf/neutron.py +++ b/nova/conf/neutron.py @@ -13,11 +13,16 @@ # License for the specific language governing permissions and limitations # under the License. +import copy import itertools +from keystoneauth1 import loading as ks_loading from oslo_config import cfg -neutron_group = cfg.OptGroup('neutron', title='Neutron Options') +NEUTRON_GROUP = 'neutron' + +neutron_group = cfg.OptGroup(NEUTRON_GROUP, title='Neutron Options') +neutron_options = None neutron_opts = [ cfg.StrOpt('url', @@ -52,11 +57,42 @@ ALL_OPTS = list(itertools.chain( metadata_proxy_opts )) +deprecations = {'cafile': [cfg.DeprecatedOpt('ca_certificates_file', + group=NEUTRON_GROUP)], + 'insecure': [cfg.DeprecatedOpt('api_insecure', + group=NEUTRON_GROUP)], + 'timeout': [cfg.DeprecatedOpt('url_timeout', + group=NEUTRON_GROUP)]} + + +def _gen_opts_from_plugins(): + opts = copy.deepcopy(neutron_options) + opts.insert(0, ks_loading.get_auth_common_conf_options()[0]) + # NOTE(dims): There are a lot of auth plugins, we just generate + # the config options for a few common ones + plugins = ['password', 'v2password', 'v3password'] + for name in plugins: + plugin = ks_loading.get_plugin_loader(name) + for plugin_option in ks_loading.get_auth_plugin_conf_options(plugin): + for option in opts: + if option.name == plugin_option.name: + break + else: + opts.append(plugin_option) + opts.sort(key=lambda x: x.name) + return opts + def register_opts(conf): + global neutron_options conf.register_group(neutron_group) conf.register_opts(ALL_OPTS, group=neutron_group) + neutron_options = ks_loading.register_session_conf_options( + conf, NEUTRON_GROUP, deprecated_opts=deprecations) + ks_loading.register_auth_conf_options(conf, NEUTRON_GROUP) def list_opts(): - return {neutron_group: ALL_OPTS} + return { + neutron_group: ALL_OPTS + _gen_opts_from_plugins() + } diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py index 29dd59ef5e96..f615664466a3 100644 --- a/nova/network/neutronv2/api.py +++ b/nova/network/neutronv2/api.py @@ -15,14 +15,12 @@ # under the License. # -import copy import time import uuid from keystoneauth1 import loading as ks_loading from neutronclient.common import exceptions as neutron_client_exc from neutronclient.v2_0 import client as clientv20 -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import uuidutils @@ -43,23 +41,8 @@ from nova.pci import request as pci_request from nova.pci import utils as pci_utils from nova.pci import whitelist as pci_whitelist - -NEUTRON_GROUP = 'neutron' - CONF = nova.conf.CONF -deprecations = {'cafile': [cfg.DeprecatedOpt('ca_certificates_file', - group=NEUTRON_GROUP)], - 'insecure': [cfg.DeprecatedOpt('api_insecure', - group=NEUTRON_GROUP)], - 'timeout': [cfg.DeprecatedOpt('url_timeout', - group=NEUTRON_GROUP)]} - -_neutron_options = ks_loading.register_session_conf_options( - CONF, NEUTRON_GROUP, deprecated_opts=deprecations) -ks_loading.register_auth_conf_options(CONF, NEUTRON_GROUP) - - CONF.import_opt('default_floating_pool', 'nova.network.floating_ips') LOG = logging.getLogger(__name__) @@ -72,24 +55,6 @@ _ADMIN_AUTH = None DEFAULT_SECGROUP = 'default' -def list_opts(): - opts = copy.deepcopy(_neutron_options) - opts.insert(0, ks_loading.get_auth_common_conf_options()[0]) - # NOTE(dims): There are a lot of auth plugins, we just generate - # the config options for a few common ones - plugins = ['password', 'v2password', 'v3password'] - for name in plugins: - plugin = ks_loading.get_plugin_loader(name) - for plugin_option in ks_loading.get_auth_plugin_conf_options(plugin): - for option in opts: - if option.name == plugin_option.name: - break - else: - opts.append(plugin_option) - opts.sort(key=lambda x: x.name) - return [(NEUTRON_GROUP, opts)] - - def reset_state(): global _ADMIN_AUTH global _SESSION @@ -99,7 +64,8 @@ def reset_state(): def _load_auth_plugin(conf): - auth_plugin = ks_loading.load_auth_from_conf_options(conf, NEUTRON_GROUP) + auth_plugin = ks_loading.load_auth_from_conf_options(conf, + nova.conf.neutron.NEUTRON_GROUP) if auth_plugin: return auth_plugin @@ -120,7 +86,7 @@ def get_client(context, admin=False): if not _SESSION: _SESSION = ks_loading.load_session_from_conf_options( - CONF, NEUTRON_GROUP) + CONF, nova.conf.neutron.NEUTRON_GROUP) if admin or (context.is_admin and not context.auth_token): if not _ADMIN_AUTH: