Coverage for nova/conf/neutron.py: 95%
20 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-17 15:08 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-17 15:08 +0000
1# Copyright 2016 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
16from keystoneauth1 import loading as ks_loading
17from oslo_config import cfg
19from nova.conf import utils as confutils
22DEFAULT_SERVICE_TYPE = 'network'
23NEUTRON_GROUP = 'neutron'
25neutron_group = cfg.OptGroup(
26 NEUTRON_GROUP,
27 title='Neutron Options',
28 help="""
29Configuration options for neutron (network connectivity as a service).
30""")
32neutron_opts = [
33 cfg.StrOpt('ovs_bridge',
34 default='br-int',
35 help="""
36Default name for the Open vSwitch integration bridge.
38Specifies the name of an integration bridge interface used by OpenvSwitch.
39This option is only used if Neutron does not specify the OVS bridge name in
40port binding responses.
41"""),
42 cfg.StrOpt('default_floating_pool',
43 default='nova',
44 help="""
45Default name for the floating IP pool.
47Specifies the name of floating IP pool used for allocating floating IPs. This
48option is only used if Neutron does not specify the floating IP pool name in
49port binding responses.
50"""),
51 cfg.IntOpt('extension_sync_interval',
52 default=600,
53 min=0,
54 help="""
55Integer value representing the number of seconds to wait before querying
56Neutron for extensions. After this number of seconds the next time Nova
57needs to create a resource in Neutron it will requery Neutron for the
58extensions that it has loaded. Setting value to 0 will refresh the
59extensions with no wait.
60"""),
61 cfg.ListOpt('physnets',
62 default=[],
63 help="""
64List of physnets present on this host.
66For each *physnet* listed, an additional section,
67``[neutron_physnet_$PHYSNET]``, will be added to the configuration file. Each
68section must be configured with a single configuration option, ``numa_nodes``,
69which should be a list of node IDs for all NUMA nodes this physnet is
70associated with. For example::
72 [neutron]
73 physnets = foo, bar
75 [neutron_physnet_foo]
76 numa_nodes = 0
78 [neutron_physnet_bar]
79 numa_nodes = 0,1
81Any *physnet* that is not listed using this option will be treated as having no
82particular NUMA node affinity.
84Tunnelled networks (VXLAN, GRE, ...) cannot be accounted for in this way and
85are instead configured using the ``[neutron_tunnel]`` group. For example::
87 [neutron_tunnel]
88 numa_nodes = 1
90Related options:
92* ``[neutron_tunnel] numa_nodes`` can be used to configure NUMA affinity for
93 all tunneled networks
94* ``[neutron_physnet_$PHYSNET] numa_nodes`` must be configured for each value
95 of ``$PHYSNET`` specified by this option
96"""),
97 cfg.IntOpt('http_retries',
98 default=3,
99 min=0,
100 help="""
101Number of times neutronclient should retry on any failed http call.
1030 means connection is attempted only once. Setting it to any positive integer
104means that on failure connection is retried that many times e.g. setting it
105to 3 means total attempts to connect will be 4.
107Possible values:
109* Any integer value. 0 means connection is attempted only once
110"""),
111]
113metadata_proxy_opts = [
114 cfg.BoolOpt("service_metadata_proxy",
115 default=False,
116 help="""
117When set to True, this option indicates that Neutron will be used to proxy
118metadata requests and resolve instance ids. Otherwise, the instance ID must be
119passed to the metadata request in the 'X-Instance-ID' header.
121Related options:
123* metadata_proxy_shared_secret
124"""),
125 cfg.StrOpt("metadata_proxy_shared_secret",
126 default="",
127 secret=True,
128 help="""
129This option holds the shared secret string used to validate proxy requests to
130Neutron metadata requests. In order to be used, the
131'X-Metadata-Provider-Signature' header must be supplied in the request.
133Related options:
135* service_metadata_proxy
136"""),
137]
139ALL_OPTS = (neutron_opts + metadata_proxy_opts)
142def register_opts(conf):
143 conf.register_group(neutron_group)
144 conf.register_opts(ALL_OPTS, group=neutron_group)
145 confutils.register_ksa_opts(conf, neutron_group, DEFAULT_SERVICE_TYPE)
148def register_dynamic_opts(conf):
149 """Register dynamically-generated options and groups.
151 This must be called by the service that wishes to use the options **after**
152 the initial configuration has been loaded.
153 """
154 opt = cfg.ListOpt('numa_nodes', default=[], item_type=cfg.types.Integer())
156 # Register the '[neutron_tunnel] numa_nodes' opt, implicitly
157 # registering the '[neutron_tunnel]' group in the process. This could
158 # be done statically but is done to avoid this group appearing in
159 # nova.conf documentation while the other group does not.
160 conf.register_opt(opt, group='neutron_tunnel')
162 # Register the '[neutron_physnet_$PHYSNET] numa_nodes' opts, implicitly
163 # registering the '[neutron_physnet_$PHYSNET]' groups in the process
164 for physnet in conf.neutron.physnets:
165 conf.register_opt(opt, group='neutron_physnet_%s' % physnet)
168def list_opts():
169 return {
170 neutron_group: (
171 ALL_OPTS +
172 ks_loading.get_session_conf_options() +
173 ks_loading.get_auth_common_conf_options() +
174 ks_loading.get_auth_plugin_conf_options('password') +
175 ks_loading.get_auth_plugin_conf_options('v2password') +
176 ks_loading.get_auth_plugin_conf_options('v3password') +
177 confutils.get_ksa_adapter_opts(DEFAULT_SERVICE_TYPE))
178 }