Merge "XenAPI: resolve the fetch_bandwidth failure"

This commit is contained in:
Jenkins 2016-09-20 19:43:15 +00:00 committed by Gerrit Code Review
commit 014b503a57
2 changed files with 6 additions and 2 deletions

View File

@ -32,7 +32,8 @@ class BandwidthTestCase(plugin_test.PluginTestBase):
'if|bw_in i1 i2 i3 i4 i5 i6 i7|bw_out o1 o2 o3 o4 o5 o6 o7',
'xenbr1: 1 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0',
'vif2.0: 2 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0',
'vif2.1: 3 0 0 0 0 0 0 0 13 0 0 0 0 0 0 0\n']
'vif2.1: 3 0 0 0 0 0 0 0 13 0 0 0 0 0 0 0',
'vifabcd1234-c: 4 0 0 0 0 0 0 0 14 0 0 0 0 0 0 0\n']
expect_devmap = {'2': {'1': {'bw_in': 13, 'bw_out': 3},
'0': {'bw_in': 12, 'bw_out': 2}
}

View File

@ -24,6 +24,8 @@ import utils
import pluginlib_nova
import re
pluginlib_nova.configure_logging('bandwidth')
@ -40,7 +42,8 @@ def _get_bandwitdth_from_proc():
devs = [l.strip() for l in _read_proc_net()]
# ignore headers
devs = devs[2:]
dlist = [d.split(':', 1) for d in devs if d.startswith('vif')]
vif_pattern = re.compile("^vif(\d+)\.(\d+)")
dlist = [d.split(':', 1) for d in devs if vif_pattern.match(d)]
devmap = dict()
for name, stats in dlist:
slist = stats.split()