Browse Source

Merge "[OVN] Update QoS related code from networking-ovn"

changes/02/706802/1
Zuul 1 week ago
parent
commit
48e5a5d138
2 changed files with 32 additions and 9 deletions
  1. +11
    -3
      neutron/services/qos/drivers/ovn/driver.py
  2. +21
    -6
      neutron/tests/unit/services/qos/drivers/ovn/test_driver.py

+ 11
- 3
neutron/services/qos/drivers/ovn/driver.py View File

@@ -34,8 +34,11 @@ SUPPORTED_RULES = {
qos_consts.MAX_BURST: {
'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]},
qos_consts.DIRECTION: {
'type:values': [constants.EGRESS_DIRECTION]}
'type:values': constants.VALID_DIRECTIONS},
},
qos_consts.RULE_TYPE_DSCP_MARKING: {
qos_consts.DSCP_MARK: {'type:values': constants.VALID_DSCP_MARKS},
}
}

VIF_TYPES = [portbindings.VIF_TYPE_OVS, portbindings.VIF_TYPE_VHOST_USER]
@@ -101,9 +104,14 @@ class OVNQosDriver(object):
for rule in all_rules:
if isinstance(rule, qos_rule.QosBandwidthLimitRule):
if rule.max_kbps:
options['qos_max_rate'] = str(rule.max_kbps * 1000)
options['qos_max_rate'] = str(rule.max_kbps)
if rule.max_burst_kbps:
options['qos_burst'] = str(rule.max_burst_kbps * 1000)
options['qos_burst'] = str(rule.max_burst_kbps)
if rule.direction:
options['direction'] = rule.direction
if isinstance(rule, qos_rule.QosDscpMarkingRule):
options['dscp_mark'] = rule.dscp_mark
options['direction'] = constants.EGRESS_DIRECTION
return options

def get_qos_options(self, port):

+ 21
- 6
neutron/tests/unit/services/qos/drivers/ovn/test_driver.py View File

@@ -65,14 +65,24 @@ class TestOVNQosDriver(base.BaseTestCase):
self.network_policy_id = uuidutils.generate_uuid()
self.policy = self._create_fake_policy()
self.port = self._create_fake_port()
self.rule = self._create_bw_limit_rule()
self.expected = {'qos_max_rate': '1000', 'qos_burst': '100000'}
self.bw_rule = self._create_bw_limit_rule()
self.bw_expected = {'direction': 'egress', 'qos_max_rate': '1000',
'qos_burst': '100000'}
self.dscp_rule = self._create_dscp_rule()
self.dscp_expected = {'dscp_mark': 16, 'direction': 'egress'}

def _create_bw_limit_rule(self):
rule_obj = qos_rule.QosBandwidthLimitRule()
rule_obj.id = uuidutils.generate_uuid()
rule_obj.max_kbps = 1
rule_obj.max_burst_kbps = 100
rule_obj.max_kbps = 1000
rule_obj.max_burst_kbps = 100000
rule_obj.obj_reset_changes()
return rule_obj

def _create_dscp_rule(self):
rule_obj = qos_rule.QosDscpMarkingRule()
rule_obj.id = uuidutils.generate_uuid()
rule_obj.dscp_mark = 16
rule_obj.obj_reset_changes()
return rule_obj

@@ -117,8 +127,13 @@ class TestOVNQosDriver(base.BaseTestCase):
def test__generate_port_options_no_rules(self):
self._generate_port_options(self.policy_id, [], {})

def test__generate_port_options_with_rule(self):
self._generate_port_options(self.policy_id, [self.rule], self.expected)
def test__generate_port_options_with_bw_rule(self):
self._generate_port_options(self.policy_id, [self.bw_rule],
self.bw_expected)

def test__generate_port_options_with_dscp_rule(self):
self._generate_port_options(self.policy_id, [self.dscp_rule],
self.dscp_expected)

def _get_qos_options(self, port, port_policy, network_policy):
with mock.patch.object(qos_policy.QosPolicy, 'get_network_policy',

Loading…
Cancel
Save