def _register_and_validate_hardware_interfaces(self, hardware_types): """Register and validate hardware interfaces for this conductor. Registers a row in the database for each combination of (hardware type, interface type, interface) that is supported and enabled. TODO: Validates against other conductors to check if the set of registered hardware interfaces for a given hardware type is the same, and warns if not (we can't error out, otherwise all conductors must be restarted at once to change configuration). :param hardware_types: Dictionary mapping hardware type name to hardware type object. :raises: ConductorHardwareInterfacesAlreadyRegistered :raises: InterfaceNotFoundInEntrypoint :raises: NoValidDefaultForInterface if the default value cannot be calculated and is not provided in the configuration """ # first unregister, in case we have cruft laying around self.conductor.unregister_all_hardware_interfaces() for ht_name, ht in hardware_types.items(): interface_map = driver_factory.enabled_supported_interfaces(ht) for interface_type, interface_names in interface_map.items(): default_interface = driver_factory.default_interface( ht, interface_type, driver_name=ht_name) self.conductor.register_hardware_interfaces( ht_name, interface_type, interface_names, default_interface)
def _register_and_validate_hardware_interfaces(self, hardware_types): """Register and validate hardware interfaces for this conductor. Registers a row in the database for each combination of (hardware type, interface type, interface) that is supported and enabled. TODO: Validates against other conductors to check if the set of registered hardware interfaces for a given hardware type is the same, and warns if not (we can't error out, otherwise all conductors must be restarted at once to change configuration). :param hardware_types: Dictionary mapping hardware type name to hardware type object. :raises: ConductorHardwareInterfacesAlreadyRegistered :raises: InterfaceNotFoundInEntrypoint :raises: NoValidDefaultForInterface if the default value cannot be calculated and is not provided in the configuration """ # first unregister, in case we have cruft laying around self.conductor.unregister_all_hardware_interfaces() for ht_name, ht in hardware_types.items(): interface_map = driver_factory.enabled_supported_interfaces(ht) for interface_type, interface_names in interface_map.items(): default_interface = driver_factory.default_interface( ht, interface_type, driver_name=ht_name) self.conductor.register_hardware_interfaces(ht_name, interface_type, interface_names, default_interface)
def get_properties(self): """Get the properties of the hardware type. Note that this returns properties for the default interface of each type, for this hardware type. Since this is not node-aware, interface overrides can't be detected. :returns: dictionary of <property name>:<property description> entries. """ # NOTE(jroll) this avoids a circular import from ironic.common import driver_factory properties = {} for iface_type in driver_base.ALL_INTERFACES: try: default_iface = driver_factory.default_interface(self, iface_type) except (exception.InterfaceNotFoundInEntrypoint, exception.NoValidDefaultForInterface): continue iface = driver_factory.get_interface(self, iface_type, default_iface) properties.update(iface.get_properties()) return properties
def get_properties(self): """Get the properties of the hardware type. Note that this returns properties for the default interface of each type, for this hardware type. Since this is not node-aware, interface overrides can't be detected. :returns: dictionary of <property name>:<property description> entries. """ # NOTE(jroll) this avoids a circular import from ironic.common import driver_factory properties = {} for iface_type in driver_base.ALL_INTERFACES: try: default_iface = driver_factory.default_interface(self, iface_type) except (exception.InterfaceNotFoundInEntrypoint, exception.NoValidDefaultForInterface): continue iface = driver_factory.get_interface(self, iface_type, default_iface) properties.update(iface.get_properties()) return properties
def test_calculated_with_unsupported(self): self.config(default_deploy_interface=None) # manual-management doesn't support fake deploy self.config(enabled_deploy_interfaces=['fake', 'direct']) iface = driver_factory.default_interface(self.driver, 'deploy') self.assertEqual('direct', iface)
def test_calculated_with_two(self): self.config(default_deploy_interface=None) self.config(enabled_deploy_interfaces=['iscsi', 'direct']) iface = driver_factory.default_interface(self.driver, 'deploy') self.assertEqual('iscsi', iface)
def test_network_from_additional_defaults_neutron_dhcp(self): self.config(default_network_interface=None) self.config(dhcp_provider='neutron', group='dhcp') iface = driver_factory.default_interface( driver_factory.get_driver_or_hardware_type('fake'), 'network') self.assertEqual('flat', 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_from_additional_defaults(self): self.config(default_storage_interface=None) iface = driver_factory.default_interface(self.driver, 'storage') self.assertEqual('noop', iface)
def test_from_config(self): self.config(default_deploy_interface='direct') iface = driver_factory.default_interface(self.driver, 'deploy') self.assertEqual('direct', iface)
def test_from_config(self): self.config(default_deploy_interface='direct') iface = driver_factory.default_interface(self.driver, 'deploy') self.assertEqual('direct', iface)
def test_calculated_with_one(self): self.config(default_deploy_interface=None) self.config(enabled_deploy_interfaces=['ansible']) iface = driver_factory.default_interface(self.driver, 'deploy') self.assertEqual('ansible', iface)
def test_calculated_with_unsupported(self): self.config(default_deploy_interface=None) # manual-management doesn't support fake deploy self.config(enabled_deploy_interfaces=['fake', 'direct']) iface = driver_factory.default_interface(self.driver, 'deploy') self.assertEqual('direct', iface)
def test_calculated_with_two(self): self.config(default_deploy_interface=None) self.config(enabled_deploy_interfaces=['iscsi', 'direct']) iface = driver_factory.default_interface(self.driver, 'deploy') self.assertEqual('iscsi', iface)
def test_network_from_additional_defaults_neutron_dhcp(self): self.config(default_network_interface=None) self.config(dhcp_provider='neutron', group='dhcp') iface = driver_factory.default_interface(self.driver, 'network') self.assertEqual('flat', iface)
def test_from_additional_defaults(self): self.config(default_storage_interface=None) iface = driver_factory.default_interface(self.driver, 'storage') self.assertEqual('noop', iface)
def test_network_from_additional_defaults(self): self.config(default_network_interface=None) self.config(dhcp_provider='none', group='dhcp') iface = driver_factory.default_interface(self.driver, 'network') 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)