@staticmethod
def init_qdisc(intf: str, show_error=False, enable_pyroute2=False, default_gbr=DEFAULT_RATE) -> int:
    if (TrafficClass.tc_ops is None):
        if enable_pyroute2:
            TrafficClass.tc_ops = TcOpsPyRoute2()
        else:
            TrafficClass.tc_ops = TcOpsCmd()
    cmd_list = []
    speed = DEFAULT_INTF_SPEED
    qid_hex = hex(ROOT_QID)
    fn = '/sys/class/net/{intf}/speed'.format(intf=intf)
    try:
        with open(fn, encoding='utf-8') as f:
            speed = f.read().strip()
    except OSError:
        LOG.error('unable to read speed from %s defaulting to %s', fn, speed)
    qdisc_type = TrafficClass._get_qdisc_type(intf)
    if (qdisc_type != 'htb'):
        qdisc_cmd = 'tc qdisc add dev {intf} root handle 1: htb'.format(intf=intf)
        cmd_list.append(qdisc_cmd)
        LOG.info('Created root qdisc')
    parent_q_cmd = 'tc class replace dev {intf} parent 1: classid 1:{root_qid} htb '
    parent_q_cmd += 'rate {speed}Mbit ceil {speed}Mbit'
    parent_q_cmd = parent_q_cmd.format(intf=intf, root_qid=qid_hex, speed=speed)
    cmd_list.append(parent_q_cmd)
    tc_cmd = 'tc class replace dev {intf} parent 1:{root_qid} classid 1:1 htb '
    tc_cmd += 'rate {rate} ceil {speed}Mbit'
    tc_cmd = tc_cmd.format(intf=intf, root_qid=qid_hex, rate=default_gbr, speed=speed)
    cmd_list.append(tc_cmd)
    return run_cmd(cmd_list, show_error)
@staticmethod
def init_qdisc(intf: str, show_error=False, enable_pyroute2=False, default_gbr=DEFAULT_RATE) -> int:
    if (TrafficClass.tc_ops is None):
        if enable_pyroute2:
            TrafficClass.tc_ops = TcOpsPyRoute2()
        else:
            TrafficClass.tc_ops = TcOpsCmd()
    cmd_list = []
    speed = DEFAULT_INTF_SPEED
    qid_hex = hex(ROOT_QID)
    fn = '/sys/class/net/{intf}/speed'.format(intf=intf)
    try:
        with open(fn, encoding='utf-8') as f:
            speed = f.read().strip()
    except OSError:
        LOG.error('unable to read speed from %s defaulting to %s', fn, speed)
    qdisc_type = TrafficClass._get_qdisc_type(intf)
    if (qdisc_type != 'htb'):
        qdisc_cmd = 'tc qdisc add dev {intf} root handle 1: htb'.format(intf=intf)
        cmd_list.append(qdisc_cmd)
        LOG.info('Created root qdisc')
    parent_q_cmd = 'tc class replace dev {intf} parent 1: classid 1:{root_qid} htb '
    parent_q_cmd += 'rate {speed}Mbit ceil {speed}Mbit'
    parent_q_cmd = parent_q_cmd.format(intf=intf, root_qid=qid_hex, speed=speed)
    cmd_list.append(parent_q_cmd)
    tc_cmd = 'tc class replace dev {intf} parent 1:{root_qid} classid 1:1 htb '
    tc_cmd += 'rate {rate} ceil {speed}Mbit'
    tc_cmd = tc_cmd.format(intf=intf, root_qid=qid_hex, rate=default_gbr, speed=speed)
    cmd_list.append(tc_cmd)
    return run_cmd(cmd_list, show_error)