예제 #1
0
def set_coalesce(interface, args):
    try:
        coal = ethtool.get_coalesce(interface)
    except IOError:
        printtab("Interrupt coalescing 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)]:
        real_arg = get_coalesce_dict_entry(arg)
        if not real_arg:
            continue
        if value == "on":
            value = 1
        elif value == "off":
            value = 0
        else:
            try:
                value = int(value)
            except:
                continue
        if coal[real_arg] != value:
            coal[real_arg] = value
            changed = True

    if not changed:
        return

    ethtool.set_coalesce(interface, coal)
예제 #2
0
def set_coalesce(interface, args):
        try:
                coal = ethtool.get_coalesce(interface)
        except IOError:
                printtab("Interrupt coalescing 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) ]:
                real_arg = get_coalesce_dict_entry(arg)
                if not real_arg:
                        continue
                if value == "on":
                        value = 1
                elif value == "off":
                        value = 0
                else:
                        try:
                                value = int(value)
                        except:
                                continue
                if coal[real_arg] != value:
                        coal[real_arg] = value
                        changed = True

        if not changed:
                return

        ethtool.set_coalesce(interface, coal)
예제 #3
0
def show_coalesce(interface, args=None):
    printtab("Coalesce parameters for %s:" % interface)
    try:
        coal = ethtool.get_coalesce(interface)
    except IOError:
        printtab("  NOT supported!")
        return

    printtab("Adaptive RX: %s  TX: %s" %
             (coal["use_adaptive_rx_coalesce"] and "on"
              or "off", coal["use_adaptive_tx_coalesce"] and "on" or "off"))

    printed = ["use_adaptive_rx_coalesce", "use_adaptive_tx_coalesce"]
    for tunable in ethtool_coalesce_msgs:
        if tunable[0] == '\n':
            print
        else:
            printtab("%s: %s" % (tunable[0], coal[tunable[1]]))
            printed.append(tunable[1])

    coalkeys = coal.keys()
    if len(coalkeys) != len(printed):
        print
        for tunable in coalkeys:
            if tunable not in printed:
                printtab("%s %s" % (tunable, coal[tunable]))
예제 #4
0
def show_coalesce(interface, args = None):
        printtab("Coalesce parameters for %s:" % interface)
        try:
                coal = ethtool.get_coalesce(interface)
        except IOError:
                printtab("  NOT supported!")
                return

        printtab("Adaptive RX: %s  TX: %s" % (coal["use_adaptive_rx_coalesce"] and "on" or "off",
                                              coal["use_adaptive_tx_coalesce"] and "on" or "off"))

        printed = [ "use_adaptive_rx_coalesce",
                    "use_adaptive_tx_coalesce" ]
        for tunable in ethtool_coalesce_msgs:
                if tunable[0] == '\n':
                        print
                else:
                        printtab("%s: %s" % (tunable[0], coal[tunable[1]]))
                        printed.append(tunable[1])

        coalkeys = coal.keys()
        if len(coalkeys) != len(printed):
                print
                for tunable in coalkeys:
                        if tunable not in printed:
                                printtab("%s %s" % (tunable, coal[tunable]))
예제 #5
0
def show_coalesce(devname):
    '''
    Queries the specified network device for coalescing information

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.show_coalesce <devname>
    '''

    try:
        coalesce = ethtool.get_coalesce(devname)
    except IOError:
        log.error(
            'Interrupt coalescing not supported on {0}'.format(
                devname
            )
        )
        return 'Not supported'

    ret = {}
    for key, value in coalesce.items():
        ret[ethtool_coalesce_remap[key]] = coalesce[key]

    return ret
예제 #6
0
def set_coalesce(devname, **kwargs):
    '''
    Changes the coalescing settings of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_coalesce <devname> [adaptive_rx=on|off] [adaptive_tx=on|off] [rx_usecs=N] [rx_frames=N]
            [rx_usecs_irq=N] [rx_frames_irq=N] [tx_usecs=N] [tx_frames=N] [tx_usecs_irq=N] [tx_frames_irq=N]
            [stats_block_usecs=N] [pkt_rate_low=N] [rx_usecs_low=N] [rx_frames_low=N] [tx_usecs_low=N] [tx_frames_low=N]
            [pkt_rate_high=N] [rx_usecs_high=N] [rx_frames_high=N] [tx_usecs_high=N] [tx_frames_high=N]
            [sample_interval=N]
    '''

    try:
        coalesce = ethtool.get_coalesce(devname)
    except IOError:
        log.error(
            'Interrupt coalescing not supported on {0}'.format(
                devname
            )
        )
        return 'Not supported'

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

    try:
        if changed:
            ethtool.set_coalesce(devname, coalesce)
        return show_coalesce(devname)
    except IOError:
        log.error(
            'Invalid coalesce arguments on {0}: {1}'.format(
                devname, coalesce
            )
        )
        return 'Invalid arguments'
예제 #7
0
파일: ethtool.py 프로젝트: scubahub/salt
def show_coalesce(devname):
    '''
    Queries the specified network device for coalescing information

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.show_coalesce <devname>
    '''

    try:
        coalesce = ethtool.get_coalesce(devname)
    except IOError:
        log.error('Interrupt coalescing not supported on {0}'.format(devname))
        return 'Not supported'

    ret = {}
    for key, value in coalesce.items():
        ret[ethtool_coalesce_remap[key]] = coalesce[key]

    return ret
예제 #8
0
def set_coalesce(devname, **kwargs):
    """
    Changes the coalescing settings of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_coalesce <devname> [adaptive_rx=on|off] [adaptive_tx=on|off] [rx_usecs=N] [rx_frames=N]
            [rx_usecs_irq=N] [rx_frames_irq=N] [tx_usecs=N] [tx_frames=N] [tx_usecs_irq=N] [tx_frames_irq=N]
            [stats_block_usecs=N] [pkt_rate_low=N] [rx_usecs_low=N] [rx_frames_low=N] [tx_usecs_low=N] [tx_frames_low=N]
            [pkt_rate_high=N] [rx_usecs_high=N] [rx_frames_high=N] [tx_usecs_high=N] [tx_frames_high=N]
            [sample_interval=N]
    """

    try:
        coalesce = ethtool.get_coalesce(devname)
    except IOError:
        log.error("Interrupt coalescing not supported on %s", devname)
        return "Not supported"

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

    try:
        if changed:
            # pylint: disable=too-many-function-args
            ethtool.set_coalesce(devname, coalesce)
            # pylint: enable=too-many-function-args
        return show_coalesce(devname)
    except IOError:
        log.error("Invalid coalesce arguments on %s: %s", devname, coalesce)
        return "Invalid arguments"
예제 #9
0
파일: ethtool.py 프로젝트: scubahub/salt
def set_coalesce(devname, **kwargs):
    '''
    Changes the coalescing settings of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_coalesce <devname> [adaptive_rx=on|off] [adaptive_tx=on|off] [rx_usecs=N] [rx_frames=N]
            [rx_usecs_irq=N] [rx_frames_irq=N] [tx_usecs=N] [tx_frames=N] [tx_usecs_irq=N] [tx_frames_irq=N]
            [stats_block_usecs=N] [pkt_rate_low=N] [rx_usecs_low=N] [rx_frames_low=N] [tx_usecs_low=N] [tx_frames_low=N]
            [pkt_rate_high=N] [rx_usecs_high=N] [rx_frames_high=N] [tx_usecs_high=N] [tx_frames_high=N]
            [sample_interval=N]
    '''

    try:
        coalesce = ethtool.get_coalesce(devname)
    except IOError:
        log.error('Interrupt coalescing not supported on {0}'.format(devname))
        return 'Not supported'

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

    try:
        if changed:
            ethtool.set_coalesce(devname, coalesce)
        return show_coalesce(devname)
    except IOError:
        log.error('Invalid coalesce arguments on {0}: {1}'.format(
            devname, coalesce))
        return 'Invalid arguments'
예제 #10
0
 def get_coalesce(self):
     try:
         return ethtool.get_coalesce(self._name)
     except IOError as e:
         logging.error("Failed to get coalesce settings: %s", e)
         return {}
예제 #11
0
 def get_coalesce(self):
     try:
         return ethtool.get_coalesce(self._name)
     except IOError as e:
         logging.error("Failed to get coalesce settings: %s", e)
         return {}