Add missing key attribute to AggregateList.get_by_host()
This simply adds the ability to pass the key attribute to the by-host lookup for aggregates. Related to blueprint compute-manager-objects Change-Id: I7651bc1470845b1e3586aa3616809bdf2ef2b4a2
This commit is contained in:
parent
2b17aa7f5a
commit
6a0b110878
|
@ -145,6 +145,10 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject):
|
|||
|
||||
|
||||
class AggregateList(base.ObjectListBase, base.NovaObject):
|
||||
# Version 1.0: Initial version
|
||||
# Version 1.1: Added key argument to get_by_host()
|
||||
VERSION = '1.1'
|
||||
|
||||
@base.remotable_classmethod
|
||||
def get_all(cls, context):
|
||||
db_aggregates = db.aggregate_get_all(context)
|
||||
|
@ -152,7 +156,7 @@ class AggregateList(base.ObjectListBase, base.NovaObject):
|
|||
db_aggregates)
|
||||
|
||||
@base.remotable_classmethod
|
||||
def get_by_host(cls, context, host):
|
||||
db_aggregates = db.aggregate_get_by_host(context, host)
|
||||
def get_by_host(cls, context, host, key=None):
|
||||
db_aggregates = db.aggregate_get_by_host(context, host, key=key)
|
||||
return base.obj_make_list(context, AggregateList(), Aggregate,
|
||||
db_aggregates)
|
||||
|
|
|
@ -133,7 +133,7 @@ class _TestAggregateObject(object):
|
|||
|
||||
def test_by_host(self):
|
||||
self.mox.StubOutWithMock(db, 'aggregate_get_by_host')
|
||||
db.aggregate_get_by_host(self.context, 'fake-host'
|
||||
db.aggregate_get_by_host(self.context, 'fake-host', key=None,
|
||||
).AndReturn([fake_aggregate])
|
||||
self.mox.ReplayAll()
|
||||
aggs = aggregate.AggregateList.get_by_host(self.context, 'fake-host')
|
||||
|
|
Loading…
Reference in New Issue