Merge "Add a single option to override the default hypervisor name"
This commit is contained in:
commit
ca3ec4133b
@ -71,24 +71,27 @@ def is_agent_down(heart_beat_time):
|
||||
|
||||
|
||||
# TODO(bence romsics): rehome this to neutron_lib.placement.utils
|
||||
def default_rp_hypervisors(hypervisors, device_mappings):
|
||||
def default_rp_hypervisors(hypervisors, device_mappings,
|
||||
default_hypervisor=None):
|
||||
"""Fill config option 'resource_provider_hypervisors' with defaults.
|
||||
|
||||
Default hypervisor names to socket.gethostname(). Since libvirt knows
|
||||
itself by the same name, the default is good for libvirt.
|
||||
Default hypervisor names to socket.gethostname() unless default_hypervisor
|
||||
is set.
|
||||
|
||||
:param hypervisors: Config option 'resource_provider_hypervisors'
|
||||
as parsed by oslo.config, that is a dict with keys of physical devices
|
||||
and values of hypervisor names.
|
||||
:param device_mappings: Device mappings standardized to the list-valued
|
||||
format.
|
||||
:param default_hypervisor: Default hypervisor hostname.
|
||||
"""
|
||||
default_hypervisor = socket.gethostname()
|
||||
_default_hypervisor = default_hypervisor or socket.gethostname()
|
||||
|
||||
rv = {}
|
||||
for _physnet, devices in device_mappings.items():
|
||||
for device in devices:
|
||||
if device in hypervisors:
|
||||
rv[device] = hypervisors[device]
|
||||
else:
|
||||
rv[device] = default_hypervisor
|
||||
rv[device] = _default_hypervisor
|
||||
return rv
|
||||
|
@ -65,8 +65,13 @@ sriov_nic_opts = [
|
||||
"hypervisor name is used to locate the parent of the "
|
||||
"resource provider tree. Only needs to be set in the "
|
||||
"rare case when the hypervisor name is different from "
|
||||
"the DEFAULT.host config option value as known by the "
|
||||
"nova-compute managing that hypervisor.")),
|
||||
"the resource_provider_default_hypervisor config "
|
||||
"option value as known by the nova-compute managing "
|
||||
"that hypervisor.")),
|
||||
cfg.StrOpt('resource_provider_default_hypervisor',
|
||||
help=_("The default hypervisor name used to locate the parent "
|
||||
"of the resource provider. If this option is not set, "
|
||||
"socket.gethostname() is used")),
|
||||
cfg.DictOpt('resource_provider_inventory_defaults',
|
||||
default={'allocation_ratio': 1.0,
|
||||
'min_unit': 1,
|
||||
|
@ -84,8 +84,13 @@ ovs_opts = [
|
||||
"hypervisor name is used to locate the parent of the "
|
||||
"resource provider tree. Only needs to be set in the "
|
||||
"rare case when the hypervisor name is different from "
|
||||
"the DEFAULT.host config option value as known by the "
|
||||
"nova-compute managing that hypervisor.")),
|
||||
"the resource_provider_default_hypervisor config "
|
||||
"option value as known by the nova-compute managing "
|
||||
"that hypervisor.")),
|
||||
cfg.StrOpt('resource_provider_default_hypervisor',
|
||||
help=_("The default hypervisor name used to locate the parent "
|
||||
"of the resource provider. If this option is not set, "
|
||||
"socket.gethostname() is used")),
|
||||
cfg.DictOpt('resource_provider_inventory_defaults',
|
||||
default={'allocation_ratio': 1.0,
|
||||
'min_unit': 1,
|
||||
|
@ -521,7 +521,8 @@ class SriovNicAgentConfigParser(object):
|
||||
cfg.CONF.SRIOV_NIC.resource_provider_inventory_defaults)
|
||||
self.rp_hypervisors = utils.default_rp_hypervisors(
|
||||
cfg.CONF.SRIOV_NIC.resource_provider_hypervisors,
|
||||
self.device_mappings
|
||||
self.device_mappings,
|
||||
cfg.CONF.SRIOV_NIC.resource_provider_default_hypervisor,
|
||||
)
|
||||
self._validate()
|
||||
|
||||
|
@ -222,7 +222,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
||||
ovs_conf.resource_provider_inventory_defaults)
|
||||
self.rp_hypervisors = utils.default_rp_hypervisors(
|
||||
ovs_conf.resource_provider_hypervisors,
|
||||
{k: [v] for k, v in self.bridge_mappings.items()}
|
||||
{k: [v] for k, v in self.bridge_mappings.items()},
|
||||
ovs_conf.resource_provider_default_hypervisor
|
||||
)
|
||||
|
||||
self.setup_physical_bridges(self.bridge_mappings)
|
||||
|
@ -89,6 +89,7 @@ class TestDefaultRpHypervisors(base.BaseTestCase):
|
||||
utils.default_rp_hypervisors(
|
||||
hypervisors={},
|
||||
device_mappings={'physnet0': ['eth0', 'eth1']},
|
||||
default_hypervisor=None,
|
||||
)
|
||||
)
|
||||
|
||||
@ -97,5 +98,24 @@ class TestDefaultRpHypervisors(base.BaseTestCase):
|
||||
utils.default_rp_hypervisors(
|
||||
hypervisors={'eth0': 'thathost'},
|
||||
device_mappings={'physnet0': ['eth0', 'eth1']},
|
||||
default_hypervisor=None,
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
{'eth0': 'defaulthost', 'eth1': 'defaulthost'},
|
||||
utils.default_rp_hypervisors(
|
||||
hypervisors={},
|
||||
device_mappings={'physnet0': ['eth0', 'eth1']},
|
||||
default_hypervisor='defaulthost',
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
{'eth0': 'thathost', 'eth1': 'defaulthost'},
|
||||
utils.default_rp_hypervisors(
|
||||
hypervisors={'eth0': 'thathost'},
|
||||
device_mappings={'physnet0': ['eth0', 'eth1']},
|
||||
default_hypervisor='defaulthost',
|
||||
)
|
||||
)
|
||||
|
@ -0,0 +1,9 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
The new ``resource_provider_defualt_hypervisor`` option has been added,
|
||||
to replace the default hypervisor name to locates the root resource
|
||||
provider without giving a complete list of interfaces or bridges in
|
||||
the ``resource_provider_hypervisors`` option. This option is located in
|
||||
the ``[ovs]`` ini-section for ``ovs-agent`` and ``[sriov_nic]`` ini-section
|
||||
for ``sriov-agent``.
|
Loading…
x
Reference in New Issue
Block a user