Add ability to query for ComputeNodes by their mapped value

Related to blueprint discover-hosts-faster
Change-Id: Ic0068e12cd19824789872e2aa3acaf64c96ccd6b
This commit is contained in:
Dan Smith 2017-02-01 12:21:23 -08:00 committed by Matt Riedemann
parent 669a97776e
commit ca2c68a492
2 changed files with 21 additions and 0 deletions
nova/db
api.py
sqlalchemy

@ -254,6 +254,19 @@ def compute_node_get_all(context):
return IMPL.compute_node_get_all(context)
def compute_node_get_all_mapped_less_than(context, mapped_less_than):
"""Get all ComputeNode objects with specific mapped values.
:param context: The security context
:param mapped_less_than: Get compute nodes with mapped less than this
value
:returns: List of dictionaries each containing compute node properties
"""
return IMPL.compute_node_get_all_mapped_less_than(context,
mapped_less_than)
def compute_node_get_all_by_pagination(context, limit=None, marker=None):
"""Get compute nodes by pagination.
:param context: The security context

@ -625,6 +625,8 @@ def _compute_node_select(context, filters=None, limit=None, marker=None):
if "hypervisor_hostname" in filters:
hyp_hostname = filters["hypervisor_hostname"]
select = select.where(cn_tbl.c.hypervisor_hostname == hyp_hostname)
if "mapped" in filters:
select = select.where(cn_tbl.c.mapped < filters['mapped'])
if marker is not None:
try:
compute_node_get(context, marker)
@ -702,6 +704,12 @@ def compute_node_get_all(context):
return _compute_node_fetchall(context)
@pick_context_manager_reader
def compute_node_get_all_mapped_less_than(context, mapped_less_than):
return _compute_node_fetchall(context,
{'mapped': mapped_less_than})
@pick_context_manager_reader
def compute_node_get_all_by_pagination(context, limit=None, marker=None):
return _compute_node_fetchall(context, limit=limit, marker=marker)