diff --git a/nova/db/api.py b/nova/db/api.py index fd285e53d..377178404 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -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 diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 80dad6dc5..498091737 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -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)