summaryrefslogtreecommitdiff
path: root/ironic/db
diff options
context:
space:
mode:
Diffstat (limited to 'ironic/db')
-rw-r--r--ironic/db/api.py3
-rw-r--r--ironic/db/sqlalchemy/api.py9
2 files changed, 9 insertions, 3 deletions
diff --git a/ironic/db/api.py b/ironic/db/api.py
index c7be8258d..28e0f10f3 100644
--- a/ironic/db/api.py
+++ b/ironic/db/api.py
@@ -518,9 +518,10 @@ class Connection(object):
"""
@abc.abstractmethod
- def get_active_hardware_type_dict(self):
+ def get_active_hardware_type_dict(self, use_groups=False):
"""Retrieve hardware types for the registered and active conductors.
+ :param use_groups: Whether to factor conductor_group into the keys.
:returns: A dict which maps hardware type names to the set of hosts
which support them. For example:
diff --git a/ironic/db/sqlalchemy/api.py b/ironic/db/sqlalchemy/api.py
index bcc22a527..9e3c9918c 100644
--- a/ironic/db/sqlalchemy/api.py
+++ b/ironic/db/sqlalchemy/api.py
@@ -855,7 +855,7 @@ class Connection(api.Connection):
'powering process, their power state can be incorrect: '
'%(nodes)s', {'nodes': nodes})
- def get_active_hardware_type_dict(self):
+ def get_active_hardware_type_dict(self, use_groups=False):
query = (model_query(models.ConductorHardwareInterfaces,
models.Conductor)
.join(models.Conductor))
@@ -863,7 +863,12 @@ class Connection(api.Connection):
d2c = collections.defaultdict(set)
for iface_row, cdr_row in result:
- d2c[iface_row['hardware_type']].add(cdr_row['hostname'])
+ hw_type = iface_row['hardware_type']
+ if use_groups:
+ key = '%s:%s' % (cdr_row['conductor_group'], hw_type)
+ else:
+ key = hw_type
+ d2c[key].add(cdr_row['hostname'])
return d2c
def get_offline_conductors(self):