Esempio n. 1
0
def set_ringparam(interface, args):
    try:
        ring = ethtool.get_ringparam(interface)
    except IOError:
        printtab("ring parameters NOT supported on %s!" % interface)
        return

    changed = False
    args = [a.lower() for a in args]
    for arg, value in [(args[i], args[i + 1]) for i in range(0, len(args), 2)]:
        if not ethtool_ringparam_map.has_key(arg):
            continue
        try:
            value = int(value)
        except:
            continue
        real_arg = ethtool_ringparam_map[arg]
        if ring[real_arg] != value:
            ring[real_arg] = value
            changed = True

    if not changed:
        return

    ethtool.set_ringparam(interface, ring)
Esempio n. 2
0
def set_ring(devname, **kwargs):
    '''
    Changes the rx/tx ring parameters of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_ring <devname> [rx=N] [rx_mini=N] [rx_jumbo=N] [tx=N]
    '''

    try:
        ring = ethtool.get_ringparam(devname)
    except IOError:
        log.error('Ring parameters not supported on {0}'.format(devname))
        return 'Not supported'

    changed = False
    for param, value in kwargs.items():
        if param in ethtool_ring_map:
            param = ethtool_ring_map[param]
            if param in ring:
                if ring[param] != value:
                    ring[param] = value
                    changed = True

    try:
        if changed:
            ethtool.set_ringparam(devname, ring)
        return show_ring(devname)
    except IOError:
        log.error('Invalid ring arguments on {0}: {1}'.format(devname, ring))
        return 'Invalid arguments'
Esempio n. 3
0
def set_ringparam(interface, args):
        try:
                ring = ethtool.get_ringparam(interface)
        except IOError:
                printtab("ring parameters NOT supported on %s!" % interface)
                return

        changed = False
        args = [a.lower() for a in args]
        for arg, value in [ ( args[i], args[i + 1] ) for i in range(0, len(args), 2) ]:
                if not ethtool_ringparam_map.has_key(arg):
                        continue
                try:
                        value = int(value)
                except:
                        continue
                real_arg = ethtool_ringparam_map[arg]
                if ring[real_arg] != value:
                        ring[real_arg] = value
                        changed = True

        if not changed:
                return

        ethtool.set_ringparam(interface, ring)
Esempio n. 4
0
def set_ring(devname, **kwargs):
    '''
    Changes the rx/tx ring parameters of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_ring <devname> [ring=N] [rx_mini=N] [rx_jumbo=N] [tx=N]
    '''

    try:
        ring = ethtool.get_ringparam(devname)
    except IOError:
        log.error(
            'Ring parameters not supported on {0}'.format(
                devname
            )
        )
        return 'Not supported'

    changed = False
    for param, value in kwargs.items():
        if param in ethtool_ring_map:
            param = ethtool_ring_map[param]
            if param in ring:
                if ring[param] != value:
                    ring[param] = value
                    changed = True

    try:
        if changed:
            ethtool.set_ringparam(devname, ring)
        return show_ring(devname)
    except IOError:
        log.error(
            'Invalid ring arguments on {0}: {1}'.format(
                devname, ring
            )
        )
        return 'Invalid arguments'
Esempio n. 5
0
def tune_ring_buf(phy_int):
    print('Tunning ring param for ConnectX-4 and 5')
    ring = ethtool.get_ringparam(phy_int)
    ring['rx_pending'] = 8192
    ring['tx_pending'] = 8192
    ethtool.set_ringparam(phy_int, ring)