NSX|V+V3: Fix QoS peak bandwidth calculation

The NSX backend supports configuration of Peak Bandwidth, but if it is the same
as the average bandwidth, bursts are not allowed.
To fix this, we added a new configuration multiplier that will be used to
calculate the peak bw out of the neutron max bw.

Change-Id: I38ca66dfccdf09aca2ea31015174f0615cf83656
This commit is contained in:
Adit Sarfaty 2016-07-20 14:00:37 +03:00
parent c52f4d73fe
commit 2576e7dddd
5 changed files with 31 additions and 8 deletions

View File

@ -111,6 +111,12 @@ base_opts = [
"does not want to deploy a service node). In order to "
"leverage distributed routers, replication_mode should "
"be set to 'service'.")),
#TODO(asarfaty): add min/max values to FloatOpt. This value should be > 1
cfg.FloatOpt('qos_peak_bw_multiplier', default=2.0,
help=_("The QoS rules peak bandwidth value will be the "
"configured maximum bandwidth of the QoS rule, "
"multiplied by this value. Value must be bigger than"
" 1")),
]
sync_opts = [

View File

@ -27,4 +27,9 @@
[qos]
notification_drivers = vmware_nsxv3_message_queue
5. run ``stack.sh``
5. Optional: Update the nsx qos_peak_bw_multiplier in nsx.ini (default value is 2.0)::
[NSX]
qos_peak_bw_multiplier = <i.e 10.0>
6. run ``stack.sh``

View File

@ -21,6 +21,7 @@ from neutron.objects.qos import policy as qos_policy
from neutron.plugins.common import constants
from neutron.services.qos import qos_consts
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx.db import db as nsx_db
@ -74,10 +75,12 @@ class NsxVQosRule(object):
self.bandwidthEnabled = True
# averageBandwidth: kbps (neutron) -> bps (nsxv)
self.averageBandwidth = rule_obj['max_kbps'] * 1024
# peakBandwidth: the same as the average value
# peakBandwidth: a Multiplying on the average BW
# because the neutron qos configuration supports
# only 1 value
self.peakBandwidth = self.averageBandwidth
self.peakBandwidth = int(
self.averageBandwidth *
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

@ -19,6 +19,7 @@ from neutron import context as n_context
from neutron.objects.qos import policy as qos_policy
from neutron.services.qos import qos_consts
from neutron_lib.api import validators
from oslo_config import cfg
from oslo_log import log as logging
from vmware_nsx._i18n import _, _LW
@ -136,9 +137,13 @@ class QosNotificationsHandler(object):
burst_size = int(bw_rule.max_burst_kbps) * 128
# translate kbps -> Mbps
peak_bandwidth = int(float(bw_rule.max_kbps) / 1024)
# neutron QoS does not support this parameter
average_bandwidth = peak_bandwidth
average_bandwidth = int(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)
else:
shaping_enabled = False
burst_size = None

View File

@ -83,6 +83,8 @@ class TestQosNsxV3Notification(nsxlib_testcase.NsxClientTestCase,
mock.patch.object(nsx_db, 'get_switch_profile_by_qos_policy',
return_value=self.fake_profile_id).start()
self.peak_bw_multiplier = cfg.CONF.NSX.qos_peak_bw_multiplier
@mock.patch(
'neutron.objects.rbac_db.RbacNeutronDbObjectMixin'
'.create_rbac_policy')
@ -156,11 +158,12 @@ class TestQosNsxV3Notification(nsxlib_testcase.NsxClientTestCase,
rule_dict = self.rule_data['bandwidth_limit_rule']
expected_bw = 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(
self.fake_profile_id,
average_bandwidth=expected_bw,
burst_size=expected_burst,
peak_bandwidth=expected_bw,
peak_bandwidth=expected_peak,
shaping_enabled=True,
qos_marking='trusted',
dscp=0
@ -196,11 +199,12 @@ class TestQosNsxV3Notification(nsxlib_testcase.NsxClientTestCase,
rule_dict = rule_data['bandwidth_limit_rule']
expected_bw = qos_utils.MAX_KBPS_MIN_VALUE / 1024
expected_burst = rule_dict['max_burst_kbps'] * 128
expected_peak = int(expected_bw * self.peak_bw_multiplier)
update_profile.assert_called_once_with(
self.fake_profile_id,
average_bandwidth=expected_bw,
burst_size=expected_burst,
peak_bandwidth=expected_bw,
peak_bandwidth=expected_peak,
shaping_enabled=True,
dscp=0,
qos_marking='trusted'