summaryrefslogtreecommitdiff
path: root/ironic/conductor/base_manager.py
diff options
context:
space:
mode:
authorJim Rollenhagen <jim@jimrollenhagen.com>2016-12-19 17:12:01 -0500
committerJim Rollenhagen <jim@jimrollenhagen.com>2017-01-19 11:28:30 +0000
commitb7e6b737d7aea841e718d66776894986dbcab2a2 (patch)
tree3e94fcb50267ba74d760eb1b62255cb3bff5a9ba /ironic/conductor/base_manager.py
parentc1c86e81afa9d14ffd474684046e5759d923b34a (diff)
downloadironic-b7e6b737d7aea841e718d66776894986dbcab2a2.tar.gz
Register/unregister hardware interfaces for conductors
This registers the intersection of supported and enabled interfaces for each hardware type enabled in the conductor at conductor startup, and unregisters them at conductor shutdown. Validation is left as a todo for now. Change-Id: I14e88bfc304de9414de008d1cc8568dda9115ecc Partial-Bug: #1524745
Diffstat (limited to 'ironic/conductor/base_manager.py')
-rw-r--r--ironic/conductor/base_manager.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/ironic/conductor/base_manager.py b/ironic/conductor/base_manager.py
index e3a2edc21..6e1cc4132 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.