Merge "Only set default network interface flat if enabled in config"
This commit is contained in:
commit
abb14290fb
@ -175,10 +175,19 @@ def default_interface(driver_or_hw_type, interface_type,
|
|||||||
hardware_type.AbstractHardwareType)
|
hardware_type.AbstractHardwareType)
|
||||||
# Explicit interface defaults
|
# Explicit interface defaults
|
||||||
additional_defaults = {
|
additional_defaults = {
|
||||||
'network': 'flat' if CONF.dhcp.dhcp_provider == 'neutron' else 'noop',
|
|
||||||
'storage': 'noop'
|
'storage': 'noop'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not is_hardware_type:
|
||||||
|
# For non hardware types we need to set a fallback for the network
|
||||||
|
# interface however hardware_types specify their own defaults if not in
|
||||||
|
# the config file.
|
||||||
|
if (CONF.dhcp.dhcp_provider == 'neutron' and
|
||||||
|
'flat' in CONF.enabled_network_interfaces):
|
||||||
|
additional_defaults['network'] = 'flat'
|
||||||
|
elif 'noop' in CONF.enabled_network_interfaces:
|
||||||
|
additional_defaults['network'] = 'noop'
|
||||||
|
|
||||||
# The fallback default from the configuration
|
# The fallback default from the configuration
|
||||||
impl_name = getattr(CONF, 'default_%s_interface' % interface_type)
|
impl_name = getattr(CONF, 'default_%s_interface' % interface_type)
|
||||||
if impl_name is None:
|
if impl_name is None:
|
||||||
|
@ -80,3 +80,10 @@ class FakeHardware(hardware_type.AbstractHardwareType):
|
|||||||
def supported_vendor_interfaces(self):
|
def supported_vendor_interfaces(self):
|
||||||
"""List of classes of supported rescue interfaces."""
|
"""List of classes of supported rescue interfaces."""
|
||||||
return [fake.FakeVendorB, fake.FakeVendorA]
|
return [fake.FakeVendorB, fake.FakeVendorA]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_network_interfaces(self):
|
||||||
|
# import late to avoid circular imports
|
||||||
|
from ironic.drivers.modules.network import flat
|
||||||
|
from ironic.drivers.modules.network import noop
|
||||||
|
return [flat.FlatNetwork, noop.NoopNetwork]
|
||||||
|
@ -480,7 +480,8 @@ class CheckAndUpdateNodeInterfacesTestCase(db_base.DbTestCase):
|
|||||||
class DefaultInterfaceTestCase(db_base.DbTestCase):
|
class DefaultInterfaceTestCase(db_base.DbTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DefaultInterfaceTestCase, self).setUp()
|
super(DefaultInterfaceTestCase, self).setUp()
|
||||||
self.config(enabled_hardware_types=['manual-management'])
|
self.config(enabled_hardware_types=['manual-management'],
|
||||||
|
enabled_drivers=['fake'])
|
||||||
self.driver = driver_factory.get_hardware_type('manual-management')
|
self.driver = driver_factory.get_hardware_type('manual-management')
|
||||||
|
|
||||||
def test_from_config(self):
|
def test_from_config(self):
|
||||||
@ -493,16 +494,27 @@ class DefaultInterfaceTestCase(db_base.DbTestCase):
|
|||||||
iface = driver_factory.default_interface(self.driver, 'storage')
|
iface = driver_factory.default_interface(self.driver, 'storage')
|
||||||
self.assertEqual('noop', iface)
|
self.assertEqual('noop', iface)
|
||||||
|
|
||||||
|
def test_network_from_additional_defaults_hardware_type(self):
|
||||||
|
self.config(default_network_interface=None)
|
||||||
|
self.config(dhcp_provider='none', group='dhcp')
|
||||||
|
self.config(enabled_network_interfaces=['neutron'])
|
||||||
|
iface = driver_factory.default_interface(self.driver, 'network')
|
||||||
|
self.assertEqual('neutron', iface)
|
||||||
|
|
||||||
def test_network_from_additional_defaults(self):
|
def test_network_from_additional_defaults(self):
|
||||||
self.config(default_network_interface=None)
|
self.config(default_network_interface=None)
|
||||||
self.config(dhcp_provider='none', group='dhcp')
|
self.config(dhcp_provider='none', group='dhcp')
|
||||||
iface = driver_factory.default_interface(self.driver, 'network')
|
iface = driver_factory.default_interface(
|
||||||
|
driver_factory.get_driver_or_hardware_type('fake'),
|
||||||
|
'network')
|
||||||
self.assertEqual('noop', iface)
|
self.assertEqual('noop', iface)
|
||||||
|
|
||||||
def test_network_from_additional_defaults_neutron_dhcp(self):
|
def test_network_from_additional_defaults_neutron_dhcp(self):
|
||||||
self.config(default_network_interface=None)
|
self.config(default_network_interface=None)
|
||||||
self.config(dhcp_provider='neutron', group='dhcp')
|
self.config(dhcp_provider='neutron', group='dhcp')
|
||||||
iface = driver_factory.default_interface(self.driver, 'network')
|
iface = driver_factory.default_interface(
|
||||||
|
driver_factory.get_driver_or_hardware_type('fake'),
|
||||||
|
'network')
|
||||||
self.assertEqual('flat', iface)
|
self.assertEqual('flat', iface)
|
||||||
|
|
||||||
def test_calculated_with_one(self):
|
def test_calculated_with_one(self):
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes a bug seen when no ``default_network_interface`` is set, because the
|
||||||
|
conductor tries use the ``flat`` network interface instead even if it is
|
||||||
|
not included in the conductor's ``enabled_network_interfaces`` config
|
||||||
|
option. Resulting in `Failed to register hardware types` error. See
|
||||||
|
`bug 1744332 <https://bugs.launchpad.net/ironic/+bug/1744332>`_
|
||||||
|
for more information.
|
Loading…
Reference in New Issue
Block a user