summaryrefslogtreecommitdiff
path: root/ironic/db/sqlalchemy/api.py
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-01-23 16:33:14 +0000
committerGerrit Code Review <review@openstack.org>2019-01-23 16:33:14 +0000
commit5db6c2567afb5d61f2db23d0f7817d9a0630bfb3 (patch)
treefe4237a4ba58b2044f8d2c4a3753e0cdfc0d32bd /ironic/db/sqlalchemy/api.py
parent53823d7f9376cedb9fe794bc46aa69275157448a (diff)
parent1b019ddf84586fd2012f29b473b38ec271b928f2 (diff)
downloadironic-5db6c2567afb5d61f2db23d0f7817d9a0630bfb3.tar.gz
Merge "Allocation API: allow picking random conductor for RPC topic"
Diffstat (limited to 'ironic/db/sqlalchemy/api.py')
-rw-r--r--ironic/db/sqlalchemy/api.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/ironic/db/sqlalchemy/api.py b/ironic/db/sqlalchemy/api.py
index a6d110dc1..3d7f8cb70 100644
--- a/ironic/db/sqlalchemy/api.py
+++ b/ironic/db/sqlalchemy/api.py
@@ -924,10 +924,14 @@ class Connection(api.Connection):
def get_offline_conductors(self):
interval = CONF.conductor.heartbeat_timeout
limit = timeutils.utcnow() - datetime.timedelta(seconds=interval)
- result = (model_query(models.Conductor).filter_by()
- .filter(models.Conductor.updated_at < limit)
- .all())
- return [row['hostname'] for row in result]
+ result = (model_query(models.Conductor.hostname)
+ .filter(models.Conductor.updated_at < limit))
+ return [row[0] for row in result]
+
+ def get_online_conductors(self):
+ query = model_query(models.Conductor.hostname)
+ query = _filter_active_conductors(query)
+ return [row[0] for row in query]
def list_conductor_hardware_interfaces(self, conductor_id):
query = (model_query(models.ConductorHardwareInterfaces)