From 6a0b110878b63f7e42efaa9a7abe563f5f18a190 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 8 Oct 2013 09:37:54 -0700 Subject: [PATCH] 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 --- nova/objects/aggregate.py | 8 ++++++-- nova/tests/objects/test_aggregate.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nova/objects/aggregate.py b/nova/objects/aggregate.py index a38cc5dfec3a..c9528c07b0ca 100644 --- a/nova/objects/aggregate.py +++ b/nova/objects/aggregate.py @@ -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) diff --git a/nova/tests/objects/test_aggregate.py b/nova/tests/objects/test_aggregate.py index a35d2bd1e4d8..7b2c0157a920 100644 --- a/nova/tests/objects/test_aggregate.py +++ b/nova/tests/objects/test_aggregate.py @@ -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')