Fix bandwidth polling exception.

When the bandwidth polling task tries to update bw usage for an
instance that does not have an entry for the last two periods already
in the bw_usage_cache table, it will throw an exception in the
polling task. This was just a misses 'if' statement.

Also:
xenserver: fix swapped bw data in xs plugin.

This fixes bug 1075255

Change-Id: I44bb143039fcdfc8dacb13b67ae8f79dc5f38777
This commit is contained in:
Monsyne Dragon 2012-11-05 17:46:55 +00:00
parent 10979da33c
commit 65644195fe
2 changed files with 4 additions and 3 deletions

View File

@ -2815,8 +2815,9 @@ class ComputeManager(manager.SchedulerDependentManager):
bw_ctr['uuid'],
prev_time,
bw_ctr['mac_address'])
last_ctr_in = usage['last_ctr_in']
last_ctr_out = usage['last_ctr_out']
if usage:
last_ctr_in = usage['last_ctr_in']
last_ctr_out = usage['last_ctr_out']
if last_ctr_in is not None:
if bw_ctr['bw_in'] < last_ctr_in:

View File

@ -38,7 +38,7 @@ def _read_proc_net():
dev = devmap.get(dom, {})
# Note, we deliberately swap in and out, as instance traffic
# shows up inverted due to going though the bridge. (mdragon)
dev[vifnum] = dict(bw_in=int(slist[0]), bw_out=int(slist[8]))
dev[vifnum] = dict(bw_in=int(slist[8]), bw_out=int(slist[0]))
devmap[dom] = dev
return devmap