diff options
author | Jenkins <jenkins@review.openstack.org> | 2012-12-19 19:55:26 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2012-12-19 19:55:26 +0000 |
commit | b8bc88cafab17e88c07782fb09f945359171d155 (patch) | |
tree | 34543d2b08aa7494b7d7e1086b86828bafcb0a26 /nova | |
parent | e91b9d4ea75802ba271a5f44584366ab3d0ff2e9 (diff) | |
parent | 7f2ed0cc193febe0246604a74bf4b178af70dd1a (diff) | |
download | nova-b8bc88cafab17e88c07782fb09f945359171d155.tar.gz nova-b8bc88cafab17e88c07782fb09f945359171d155.tar.xz nova-b8bc88cafab17e88c07782fb09f945359171d155.zip |
Merge "Move aggregate_get() to conductor"
Diffstat (limited to 'nova')
-rw-r--r-- | nova/compute/manager.py | 4 | ||||
-rw-r--r-- | nova/conductor/api.py | 6 | ||||
-rw-r--r-- | nova/conductor/manager.py | 7 | ||||
-rw-r--r-- | nova/conductor/rpcapi.py | 5 | ||||
-rw-r--r-- | nova/tests/conductor/test_conductor.py | 7 |
5 files changed, 26 insertions, 3 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 6efc83fb9..7c33a8c8a 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -3347,7 +3347,7 @@ class ComputeManager(manager.SchedulerDependentManager): aggregate=None, aggregate_id=None): """Notify hypervisor of change (for hypervisor pools).""" if not aggregate: - aggregate = self.db.aggregate_get(context, aggregate_id) + aggregate = self.conductor_api.aggregate_get(context, aggregate_id) try: self.driver.add_to_aggregate(context, aggregate, host, @@ -3364,7 +3364,7 @@ class ComputeManager(manager.SchedulerDependentManager): aggregate=None, aggregate_id=None): """Removes a host from a physical hypervisor pool.""" if not aggregate: - aggregate = self.db.aggregate_get(context, aggregate_id) + aggregate = self.conductor_api.aggregate_get(context, aggregate_id) try: self.driver.remove_from_aggregate(context, aggregate, host, diff --git a/nova/conductor/api.py b/nova/conductor/api.py index 4c2f031e6..8c248d9f9 100644 --- a/nova/conductor/api.py +++ b/nova/conductor/api.py @@ -90,6 +90,9 @@ class LocalAPI(object): def aggregate_host_delete(self, context, aggregate, host): return self._manager.aggregate_host_delete(context, aggregate, host) + def aggregate_get(self, context, aggregate_id): + return self._manager.aggregate_get(context, aggregate_id) + def aggregate_get_by_host(self, context, host, key=None): return self._manager.aggregate_get_by_host(context, host, key) @@ -166,6 +169,9 @@ class API(object): return self.conductor_rpcapi.aggregate_host_delete(context, aggregate, host) + def aggregate_get(self, context, aggregate_id): + return self.conductor_rpcapi.aggregate_get(context, aggregate_id) + def aggregate_get_by_host(self, context, host, key=None): return self.conductor_rpcapi.aggregate_get_by_host(context, host, key) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 712644738..ab02117f5 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -43,7 +43,7 @@ datetime_fields = ['launched_at', 'terminated_at'] class ConductorManager(manager.SchedulerDependentManager): """Mission: TBD""" - RPC_API_VERSION = '1.10' + RPC_API_VERSION = '1.11' def __init__(self, *args, **kwargs): super(ConductorManager, self).__init__(service_name='conductor', @@ -101,6 +101,11 @@ class ConductorManager(manager.SchedulerDependentManager): self.db.aggregate_host_delete(context.elevated(), aggregate['id'], host) + @rpc_common.client_exceptions(exception.AggregateNotFound) + def aggregate_get(self, context, aggregate_id): + aggregate = self.db.aggregate_get(context.elevated(), aggregate_id) + return jsonutils.to_primitive(aggregate) + def aggregate_get_by_host(self, context, host, key=None): aggregates = self.db.aggregate_get_by_host(context.elevated(), host, key) diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py index 0beeb3d2f..e7484d91f 100644 --- a/nova/conductor/rpcapi.py +++ b/nova/conductor/rpcapi.py @@ -39,6 +39,7 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy): security_group_rule_get_by_security_group 1.9 - Added provider_fw_rule_get_all 1.10 - Added agent_build_get_by_triple + 1.11 - Added aggregate_get """ BASE_RPC_API_VERSION = '1.0' @@ -86,6 +87,10 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy): host=host) return self.call(context, msg, version='1.3') + def aggregate_get(self, context, aggregate_id): + msg = self.make_msg('aggregate_get', aggregate_id=aggregate_id) + return self.call(context, msg, version='1.11') + def aggregate_get_by_host(self, context, host, key=None): msg = self.make_msg('aggregate_get_by_host', host=host, key=key) return self.call(context, msg, version='1.7') diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index 734dba9ed..3f7787e9a 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -157,6 +157,13 @@ class _BaseTestCase(object): db.aggregate_delete(self.context.elevated(), aggregate_ref['id']) + def test_aggregate_get(self): + aggregate_ref = self._setup_aggregate_with_host() + aggregate = self.conductor.aggregate_get(self.context, + aggregate_ref['id']) + self.assertEqual(jsonutils.to_primitive(aggregate_ref), aggregate) + 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') |