Supports paginate query for two get nodes DB APIs

In DB APIs that return a list of nodes, limiting and sorting the
output is necessary for a large number of output nodes. This is
especially important for the GUI that uses the APIs where the view
is limited. This patch adds limit, marker, sort_key and sort_dir
to get_associated_nodes and get_unassociated_nodes DB APIs.

Change-Id: Ia2c616fff65a03bace1244fe646bdf0cf5f30a29
This commit is contained in:
linggao
2013-10-22 21:13:39 +00:00
parent 1eedfc290f
commit 5f2bac17b6
2 changed files with 29 additions and 6 deletions

View File

@@ -195,16 +195,20 @@ class Connection(api.Connection):
sort_key, sort_dir, query)
@objects.objectify(objects.Node)
def get_associated_nodes(self):
def get_associated_nodes(self, limit=None, marker=None,
sort_key=None, sort_dir=None):
query = model_query(models.Node).\
filter(models.Node.instance_uuid != None)
return query.all()
filter(models.Node.instance_uuid != None)
return _paginate_query(models.Node, limit, marker,
sort_key, sort_dir, query)
@objects.objectify(objects.Node)
def get_unassociated_nodes(self):
def get_unassociated_nodes(self, limit=None, marker=None,
sort_key=None, sort_dir=None):
query = model_query(models.Node).\
filter(models.Node.instance_uuid == None)
return query.all()
filter(models.Node.instance_uuid == None)
return _paginate_query(models.Node, limit, marker,
sort_key, sort_dir, query)
@objects.objectify(objects.Node)
def reserve_nodes(self, tag, nodes):