From a6051acc332333030271f2e696dae234bfccabaf Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 11 Dec 2012 10:30:49 -0800 Subject: Move remaining aggregate operations to conductor This patch moves the following aggregate operations from compute to conductor: aggregate_get_by_host() aggregate_metadata_add() aggregate_metadata_delete() In order to do that, it also changes the signature of the corresponding VirtAPI methods to take the aggregate object instead of just the id, so that we don't re-introduce any db messaging behavior. I debated about using the set_delete mechanism in the metadata_add API to avoid adding a separate conductor API for delete, but decided that it wasn't worth the extra round trips, no matter how much I may wish it were. Change-Id: Ic0117879c8ce576cdc8e6c5af018bb918a15d4c0 --- nova/tests/conductor/test_conductor.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index cace21984..04cf95d5e 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -14,6 +14,8 @@ """Tests for the conductor service""" +import mox + from nova.compute import instance_types from nova.compute import vm_states from nova import conductor @@ -155,6 +157,33 @@ class ConductorTestCase(BaseTestCase): db.aggregate_delete(self.context.elevated(), aggregate_ref['id']) + def test_aggregate_get_by_host(self): + self._setup_aggregate_with_host() + aggregates = self.conductor.aggregate_get_by_host(self.context, 'bar') + self.assertEqual(aggregates[0]['availability_zone'], 'foo') + + def test_aggregate_metadata_add(self): + aggregate = {'name': 'fake aggregate', 'id': 'fake-id'} + metadata = {'foo': 'bar'} + self.mox.StubOutWithMock(db, 'aggregate_metadata_add') + db.aggregate_metadata_add( + mox.IgnoreArg(), aggregate['id'], metadata, False).AndReturn( + metadata) + self.mox.ReplayAll() + result = self.conductor.aggregate_metadata_add(self.context, + aggregate, + metadata) + self.assertEqual(result, metadata) + + def test_aggregate_metadata_delete(self): + aggregate = {'name': 'fake aggregate', 'id': 'fake-id'} + self.mox.StubOutWithMock(db, 'aggregate_metadata_delete') + db.aggregate_metadata_delete(mox.IgnoreArg(), aggregate['id'], 'fake') + self.mox.ReplayAll() + result = self.conductor.aggregate_metadata_delete(self.context, + aggregate, + 'fake') + def test_bw_usage_update(self): self.mox.StubOutWithMock(db, 'bw_usage_update') self.mox.StubOutWithMock(db, 'bw_usage_get') -- cgit