diff options
author | Dmitry Tantsur <divius.inside@gmail.com> | 2019-01-08 17:02:55 +0100 |
---|---|---|
committer | Dmitry Tantsur <divius.inside@gmail.com> | 2019-01-09 13:21:30 +0100 |
commit | 1b019ddf84586fd2012f29b473b38ec271b928f2 (patch) | |
tree | bd409182e382aa9d7a786535149e41f5fa86c8d7 /ironic/db/sqlalchemy | |
parent | cea8d74914db22cb8478d6382e281140dd071253 (diff) | |
download | ironic-1b019ddf84586fd2012f29b473b38ec271b928f2.tar.gz |
Allocation API: allow picking random conductor for RPC topic
Allocations are not initially tied to nodes, so to process them we need
to pick a random alive conductor. This change enables that.
Change-Id: I6c950bc4f49aa03026bc7925f8c699d10cedc310
Story: #2004341
Diffstat (limited to 'ironic/db/sqlalchemy')
-rw-r--r-- | ironic/db/sqlalchemy/api.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ironic/db/sqlalchemy/api.py b/ironic/db/sqlalchemy/api.py index beaca9339..65c436e96 100644 --- a/ironic/db/sqlalchemy/api.py +++ b/ironic/db/sqlalchemy/api.py @@ -916,10 +916,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) |