From 8e9bdd77c8986fa9a688bc263a71c72a0fddc77b Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Fri, 7 Dec 2012 11:19:03 -0800 Subject: Use conductor for bw_usage operations This patch moves bw_usage operations from compute manager to conductor. In an effort to reduce the number of API points we're adding to the conductor RPC API, this patch actually only adds an update function, which also returns the current values. This is used by the public conductor API layer to provide both get and update calls through a single remote function. Discussion and comments on this approach are welcomed. Related to blueprint no-db-compute Change-Id: Iabe4cef2bccc8ffcf0ddc76bf7b328c2c4d87112 --- nova/compute/manager.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 9dc6f2c3b..ce2642b13 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2950,20 +2950,19 @@ class ComputeManager(manager.SchedulerDependentManager): bw_out = 0 last_ctr_in = None last_ctr_out = None - usage = self.db.bw_usage_get(context, - bw_ctr['uuid'], - start_time, - bw_ctr['mac_address']) + usage = self.conductor_api.bw_usage_get(context, + bw_ctr['uuid'], + start_time, + bw_ctr['mac_address']) if usage: bw_in = usage['bw_in'] bw_out = usage['bw_out'] last_ctr_in = usage['last_ctr_in'] last_ctr_out = usage['last_ctr_out'] else: - usage = self.db.bw_usage_get(context, - bw_ctr['uuid'], - prev_time, - bw_ctr['mac_address']) + usage = self.conductor_api.bw_usage_get( + context, bw_ctr['uuid'], prev_time, + bw_ctr['mac_address']) if usage: last_ctr_in = usage['last_ctr_in'] last_ctr_out = usage['last_ctr_out'] @@ -2982,15 +2981,15 @@ class ComputeManager(manager.SchedulerDependentManager): else: bw_out += (bw_ctr['bw_out'] - last_ctr_out) - self.db.bw_usage_update(context, - bw_ctr['uuid'], - bw_ctr['mac_address'], - start_time, - bw_in, - bw_out, - bw_ctr['bw_in'], - bw_ctr['bw_out'], - last_refreshed=refreshed) + self.conductor_api.bw_usage_update(context, + bw_ctr['uuid'], + bw_ctr['mac_address'], + start_time, + bw_in, + bw_out, + bw_ctr['bw_in'], + bw_ctr['bw_out'], + last_refreshed=refreshed) def _get_host_volume_bdms(self, context, host): """Return all block device mappings on a compute host""" -- cgit