QoS refactor required changes
Commit b3ca00f7a603d3f1763c7a031baf476b85f790bc broke the implementation. Change-Id: Id8d686658c8943ccc3ab2c643f84aae83bdbdef1
This commit is contained in:
parent
6b70244374
commit
584b2bd6a3
@ -18,6 +18,7 @@ from neutron.api.rpc.callbacks import events as callbacks_events
|
||||
from neutron import context as n_context
|
||||
from neutron import manager
|
||||
from neutron.objects.qos import policy as qos_policy
|
||||
from neutron.objects.qos import rule as rule_object
|
||||
from neutron.plugins.common import constants
|
||||
|
||||
from oslo_log import log as logging
|
||||
@ -62,27 +63,23 @@ class NsxVQosRule(object):
|
||||
# read the neutron policy restrictions
|
||||
if qos_policy_id is not None:
|
||||
plugin = self._get_qos_plugin()
|
||||
# read the QoS BW rule from DB
|
||||
rules_obj = plugin.get_policy_bandwidth_limit_rules(
|
||||
rules_obj = plugin.get_policies(
|
||||
context, qos_policy_id)
|
||||
if rules_obj is not None and len(rules_obj) > 0:
|
||||
rule_obj = rules_obj[0] # neutron supports only 1 rule for now
|
||||
self.bandwidthEnabled = True
|
||||
# averageBandwidth: kbps (neutron) -> bps (nsxv)
|
||||
self.averageBandwidth = rule_obj['max_kbps'] * 1024
|
||||
# peakBandwidth: the same as the average value because the
|
||||
# neutron qos configuration supports only 1 value
|
||||
self.peakBandwidth = self.averageBandwidth
|
||||
# burstSize: kbps (neutron) -> Bytes (nsxv)
|
||||
self.burstSize = rule_obj['max_burst_kbps'] * 128
|
||||
|
||||
# read the QoS DSCP marking rule from DB
|
||||
rules_obj = plugin.get_policy_dscp_marking_rules(
|
||||
context, qos_policy_id)
|
||||
if rules_obj is not None and len(rules_obj) > 0:
|
||||
rule_obj = rules_obj[0] # neutron supports only 1 rule for now
|
||||
self.dscpMarkEnabled = True
|
||||
self.dscpMarkValue = rule_obj['dscp_mark']
|
||||
for rule_obj in rules_obj:
|
||||
if isinstance(rule_obj, rule_object.QosBandwidthLimitRule):
|
||||
self.bandwidthEnabled = True
|
||||
# averageBandwidth: kbps (neutron) -> bps (nsxv)
|
||||
self.averageBandwidth = rule_obj['max_kbps'] * 1024
|
||||
# peakBandwidth: the same as the average value
|
||||
# because the neutron qos configuration supports
|
||||
# only 1 value
|
||||
self.peakBandwidth = self.averageBandwidth
|
||||
# burstSize: kbps (neutron) -> Bytes (nsxv)
|
||||
self.burstSize = rule_obj['max_burst_kbps'] * 128
|
||||
elif isinstance(rule_obj, rule_object.QosDscpMarkingRule):
|
||||
self.dscpMarkEnabled = True
|
||||
self.dscpMarkValue = rule_obj['dscp_mark']
|
||||
|
||||
return self
|
||||
|
||||
|
@ -126,22 +126,18 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase,
|
||||
setattr(_policy, "rules", [self.rule, self.dscp_rule])
|
||||
|
||||
with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
|
||||
'get_policy_bandwidth_limit_rules',
|
||||
'get_policies',
|
||||
return_value=self._rules) as get_rules_mock:
|
||||
with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
|
||||
'get_policy_dscp_marking_rules',
|
||||
return_value=self._dscp_rules) as get_dscp_mock:
|
||||
# create the network to use this policy
|
||||
net = self._create_net()
|
||||
# create the network to use this policy
|
||||
net = self._create_net()
|
||||
|
||||
# make sure the network-policy binding was updated
|
||||
update_bindings_mock.assert_called_once_with(
|
||||
self.ctxt, net['id'], self.policy.id)
|
||||
# make sure the qos rule was found
|
||||
get_rules_mock.assert_called_with(self.ctxt, self.policy.id)
|
||||
get_dscp_mock.assert_called_with(self.ctxt, self.policy.id)
|
||||
# make sure the dvs was updated
|
||||
self.assertTrue(dvs_update_mock.called)
|
||||
# make sure the network-policy binding was updated
|
||||
update_bindings_mock.assert_called_once_with(
|
||||
self.ctxt, net['id'], self.policy.id)
|
||||
# make sure the qos rule was found
|
||||
get_rules_mock.assert_called_with(self.ctxt, self.policy.id)
|
||||
# make sure the dvs was updated
|
||||
self.assertTrue(dvs_update_mock.called)
|
||||
|
||||
def _test_rule_action_notification(self, action):
|
||||
with mock.patch.object(qos_com_utils, 'update_network_policy_binding'):
|
||||
@ -157,7 +153,7 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase,
|
||||
setattr(_policy, "rules", [self.rule])
|
||||
|
||||
with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
|
||||
'get_policy_bandwidth_limit_rules',
|
||||
'get_policies',
|
||||
return_value=self._rules) as get_rules_mock:
|
||||
with mock.patch('neutron.objects.qos.policy.'
|
||||
'QosPolicy.get_object',
|
||||
@ -214,7 +210,7 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase,
|
||||
setattr(_policy, "rules", [self.dscp_rule])
|
||||
plugin = self.qos_plugin
|
||||
with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
|
||||
'get_policy_dscp_marking_rules',
|
||||
'get_policies',
|
||||
return_value=self._dscp_rules) as rules_mock:
|
||||
with mock.patch('neutron.objects.qos.policy.'
|
||||
'QosPolicy.get_object',
|
||||
|
Loading…
x
Reference in New Issue
Block a user