Merge "Only TC class "htb" is supported"
This commit is contained in:
commit
0fa2e3720f
@ -376,15 +376,13 @@ def delete_tc_qdisc(device, parent=None, is_ingress=False,
|
|||||||
raise_qdisc_not_found=raise_qdisc_not_found, namespace=namespace)
|
raise_qdisc_not_found=raise_qdisc_not_found, namespace=namespace)
|
||||||
|
|
||||||
|
|
||||||
def add_tc_policy_class(device, parent, classid, qdisc_type,
|
def add_tc_policy_class(device, parent, classid, min_kbps=None, max_kbps=None,
|
||||||
min_kbps=None, max_kbps=None, burst_kb=None,
|
burst_kb=None, namespace=None):
|
||||||
namespace=None):
|
|
||||||
"""Add a TC policy class
|
"""Add a TC policy class
|
||||||
|
|
||||||
:param device: (string) device name
|
:param device: (string) device name
|
||||||
:param parent: (string) qdisc parent class ('root', 'ingress', '2:10')
|
:param parent: (string) qdisc parent class ('root', 'ingress', '2:10')
|
||||||
:param classid: (string) major:minor handler identifier ('10:20')
|
:param classid: (string) major:minor handler identifier ('10:20')
|
||||||
:param qdisc_type: (string) qdisc type ("sfq", "htb", "u32", etc)
|
|
||||||
:param min_kbps: (int) (optional) minimum bandwidth in kbps
|
:param min_kbps: (int) (optional) minimum bandwidth in kbps
|
||||||
:param max_kbps: (int) (optional) maximum bandwidth in kbps
|
:param max_kbps: (int) (optional) maximum bandwidth in kbps
|
||||||
:param burst_kb: (int) (optional) burst size in kb
|
:param burst_kb: (int) (optional) burst size in kb
|
||||||
@ -404,7 +402,7 @@ def add_tc_policy_class(device, parent, classid, qdisc_type,
|
|||||||
args['ceil'] = int(max_kbps * 1024 / 8)
|
args['ceil'] = int(max_kbps * 1024 / 8)
|
||||||
if burst_kb:
|
if burst_kb:
|
||||||
args['burst'] = int(burst_kb * 1024 / 8)
|
args['burst'] = int(burst_kb * 1024 / 8)
|
||||||
priv_tc_lib.add_tc_policy_class(device, parent, classid, qdisc_type,
|
priv_tc_lib.add_tc_policy_class(device, parent, classid, 'htb',
|
||||||
namespace=namespace, **args)
|
namespace=namespace, **args)
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,13 +98,13 @@ def delete_tc_qdisc(device, parent=None, kind=None, namespace=None,
|
|||||||
|
|
||||||
|
|
||||||
@privileged.default.entrypoint
|
@privileged.default.entrypoint
|
||||||
def add_tc_policy_class(device, parent, classid, qdisc_type, namespace=None,
|
def add_tc_policy_class(device, parent, classid, class_type, namespace=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
"""Add/replace TC policy class"""
|
"""Add/replace TC policy class"""
|
||||||
try:
|
try:
|
||||||
index = ip_lib.get_link_id(device, namespace)
|
index = ip_lib.get_link_id(device, namespace)
|
||||||
with ip_lib.get_iproute(namespace) as ip:
|
with ip_lib.get_iproute(namespace) as ip:
|
||||||
ip.tc('replace-class', kind=qdisc_type, index=index,
|
ip.tc('replace-class', kind=class_type, index=index,
|
||||||
handle=classid, parent=parent, **kwargs)
|
handle=classid, parent=parent, **kwargs)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno == errno.ENOENT:
|
if e.errno == errno.ENOENT:
|
||||||
|
@ -330,10 +330,10 @@ class TcPolicyClassTestCase(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_add_tc_policy_class(self):
|
def test_add_tc_policy_class(self):
|
||||||
tc_lib.add_tc_policy_class(
|
tc_lib.add_tc_policy_class(
|
||||||
'device', 'root', '1:10', 'qdisc_type', min_kbps=1000,
|
'device', 'root', '1:10', min_kbps=1000, max_kbps=2000,
|
||||||
max_kbps=2000, burst_kb=1600, namespace=self.namespace)
|
burst_kb=1600, namespace=self.namespace)
|
||||||
self.mock_add_tc_policy_class.assert_called_once_with(
|
self.mock_add_tc_policy_class.assert_called_once_with(
|
||||||
'device', rtnl.TC_H_ROOT, '1:10', 'qdisc_type', rate=1000 * 128,
|
'device', rtnl.TC_H_ROOT, '1:10', 'htb', rate=1000 * 128,
|
||||||
ceil=2000 * 128, burst=1600 * 128, namespace=self.namespace)
|
ceil=2000 * 128, burst=1600 * 128, namespace=self.namespace)
|
||||||
|
|
||||||
@mock.patch('pyroute2.netlink.rtnl.tcmsg.common.tick_in_usec', 15.625)
|
@mock.patch('pyroute2.netlink.rtnl.tcmsg.common.tick_in_usec', 15.625)
|
||||||
|
Loading…
Reference in New Issue
Block a user