diff options
Diffstat (limited to 'ironic/conductor/base_manager.py')
-rw-r--r-- | ironic/conductor/base_manager.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ironic/conductor/base_manager.py b/ironic/conductor/base_manager.py index 6c88708ba..2c409ccf0 100644 --- a/ironic/conductor/base_manager.py +++ b/ironic/conductor/base_manager.py @@ -148,6 +148,21 @@ class BaseConductorManager(object): self.conductor = objects.Conductor.register( admin_context, self.host, driver_names, update_existing=True) + # register hardware types and interfaces supported by this conductor + # and validate them against other conductors + try: + self._register_and_validate_hardware_interfaces() + except (exception.DriverLoadError, exception.DriverNotFound, + exception.ConductorHardwareInterfacesAlreadyRegistered, + exception.InterfaceNotFoundInEntrypoint): + with excutils.save_and_reraise_exception(): + LOG.error(_LE('Failed to register hardware types')) + self.del_host() + + # TODO(jroll) validate here that at least one driver OR + # hardware type is loaded. If not, call del_host and raise + # NoDriversLoaded. + # Start periodic tasks self._periodic_tasks_worker = self._executor.submit( self._periodic_tasks.start, allow_empty=True) @@ -219,6 +234,28 @@ class BaseConductorManager(object): self._executor.shutdown(wait=True) self._started = False + def _register_and_validate_hardware_interfaces(self): + # NOTE(jroll) may raise ConductorHardwareInterfacesAlreadyRegistered + # or InterfaceNotFoundInEntrypoint, + # we intentionally let this bubble up to the caller. + + # first unregister, in case we have cruft laying around + self.conductor.unregister_all_hardware_interfaces() + + hardware_types = driver_factory.hardware_types() + 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) + self.conductor.register_hardware_interfaces(ht_name, + interface_type, + interface_names, + default_interface) + + # TODO(jroll) validate against other conductor, warn if different + # how do we do this performantly? :| + def _collect_periodic_tasks(self, obj, args): """Collect periodic tasks from a given object. |