NSX|v+v3: QoS BW translations should be rounded

When translating kbps->Mbps, or multiplying BW values by the
qos_peak_bw_multiplier, the result should be round in order to make
it more reasonable.

Change-Id: I69e9a6b6ea8bf5400308552f63713db5192209d9
This commit is contained in:
Adit Sarfaty 2016-10-30 11:27:49 +02:00
parent db4ba11c4f
commit 875105af5a
3 changed files with 7 additions and 6 deletions

View File

@ -78,9 +78,9 @@ class NsxVQosRule(object):
# peakBandwidth: a Multiplying on the average BW
# because the neutron qos configuration supports
# only 1 value
self.peakBandwidth = int(
self.peakBandwidth = int(round(
self.averageBandwidth *
cfg.CONF.NSX.qos_peak_bw_multiplier)
cfg.CONF.NSX.qos_peak_bw_multiplier))
# burstSize: kbps (neutron) -> Bytes (nsxv)
self.burstSize = rule_obj['max_burst_kbps'] * 128
if rule_obj['type'] == qos_consts.RULE_TYPE_DSCP_MARKING:

View File

@ -149,13 +149,13 @@ class QosNotificationsHandler(object):
burst_size = int(bw_rule.max_burst_kbps) * 128
# translate kbps -> Mbps
average_bandwidth = int(float(bw_rule.max_kbps) / 1024)
average_bandwidth = int(round(float(bw_rule.max_kbps) / 1024))
# peakBandwidth: a Multiplying on the average BW
# because the neutron qos configuration supports
# only 1 value
peak_bandwidth = int(average_bandwidth *
cfg.CONF.NSX.qos_peak_bw_multiplier)
peak_bandwidth = int(round(average_bandwidth *
cfg.CONF.NSX.qos_peak_bw_multiplier))
else:
shaping_enabled = False
burst_size = None

View File

@ -162,7 +162,8 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
# validate the data on the profile
rule_dict = self.rule_data['bandwidth_limit_rule']
expected_bw = rule_dict['max_kbps'] // 1024
expected_bw = int(round(float(
rule_dict['max_kbps']) / 1024))
expected_burst = rule_dict['max_burst_kbps'] * 128
expected_peak = int(expected_bw * self.peak_bw_multiplier)
update_profile.assert_called_once_with(