Skip to content

Commit 2afc5fe

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "conf: Add '[neutron] physnets' and related options"
2 parents 9c88fdc + 9dfac2f commit 2afc5fe

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed

nova/compute/manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,8 @@ def init_host(self):
11731173
# if the configuration is wrong.
11741174
whitelist.Whitelist(CONF.pci.passthrough_whitelist)
11751175

1176+
nova.conf.neutron.register_dynamic_opts(CONF)
1177+
11761178
self.driver.init_host(host=self.host)
11771179
context = nova.context.get_admin_context()
11781180
instances = objects.InstanceList.get_by_host(

nova/conf/neutron.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,42 @@
7676
needs to create a resource in Neutron it will requery Neutron for the
7777
extensions that it has loaded. Setting value to 0 will refresh the
7878
extensions with no wait.
79+
"""),
80+
cfg.ListOpt('physnets',
81+
default=[],
82+
help="""
83+
List of physnets present on this host.
84+
85+
For each *physnet* listed, an additional section,
86+
``[neutron_physnet_$PHYSNET]``, will be added to the configuration file. Each
87+
section must be configured with a single configuration option, ``numa_nodes``,
88+
which should be a list of node IDs for all NUMA nodes this physnet is
89+
associated with. For example::
90+
91+
[neutron]
92+
physnets = foo, bar
93+
94+
[neutron_physnet_foo]
95+
numa_nodes = 0
96+
97+
[neutron_physnet_bar]
98+
numa_nodes = 0,1
99+
100+
Any *physnet* that is not listed using this option will be treated as having no
101+
particular NUMA node affinity.
102+
103+
Tunnelled networks (VXLAN, GRE, ...) cannot be accounted for in this way and
104+
are instead configured using the ``[neutron_tunnel]`` group. For example::
105+
106+
[neutron_tunnel]
107+
numa_nodes = 1
108+
109+
Related options:
110+
111+
* ``[neutron_tunnel] numa_nodes`` can be used to configure NUMA affinity for
112+
all tunneled networks
113+
* ``[neutron_physnet_$PHYSNET] numa_nodes`` must be configured for each value
114+
of ``$PHYSNET`` specified by this option
79115
"""),
80116
]
81117

@@ -118,6 +154,26 @@ def register_opts(conf):
118154
confutils.register_ksa_opts(conf, neutron_group, DEFAULT_SERVICE_TYPE)
119155

120156

157+
def register_dynamic_opts(conf):
158+
"""Register dynamically-generated options and groups.
159+
160+
This must be called by the service that wishes to use the options **after**
161+
the initial configuration has been loaded.
162+
"""
163+
opt = cfg.ListOpt('numa_nodes', default=[], item_type=cfg.types.Integer())
164+
165+
# Register the '[neutron_tunnel] numa_nodes' opt, implicitly
166+
# registering the '[neutron_tunnel]' group in the process. This could
167+
# be done statically but is done to avoid this group appearing in
168+
# nova.conf documentation while the other group does not.
169+
conf.register_opt(opt, group='neutron_tunnel')
170+
171+
# Register the '[neutron_physnet_$PHYSNET] numa_nodes' opts, implicitly
172+
# registering the '[neutron_physnet_$PHYSNET]' groups in the process
173+
for physnet in conf.neutron.physnets:
174+
conf.register_opt(opt, group='neutron_physnet_%s' % physnet)
175+
176+
121177
def list_opts():
122178
return {
123179
neutron_group: (

nova/tests/unit/conf/__init__.py

Whitespace-only changes.

nova/tests/unit/conf/test_neutron.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2018 Red Hat, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4+
# not use this file except in compliance with the License. You may obtain
5+
# a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
15+
import nova.conf
16+
from nova import test
17+
18+
19+
CONF = nova.conf.CONF
20+
21+
22+
class NeutronConfTestCase(test.NoDBTestCase):
23+
24+
def test_register_dynamic_opts(self):
25+
self.flags(physnets=['foo', 'bar', 'baz'], group='neutron')
26+
27+
self.assertNotIn('neutron_physnet_foo', CONF)
28+
self.assertNotIn('neutron_physnet_bar', CONF)
29+
30+
nova.conf.neutron.register_dynamic_opts(CONF)
31+
32+
self.assertIn('neutron_physnet_foo', CONF)
33+
self.assertIn('neutron_physnet_bar', CONF)

0 commit comments

Comments
 (0)