Example #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)
Example #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)
Example #3
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'
Example #4
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"
Example #5
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'
Example #6
0
 def set_coalesce(self, cdata):
     try:
         ethtool.set_coalesce(self._name, cdata)
     except IOError as e:
         logging.error("Failed to set coalesce settings: %s", e)
Example #7
0
 def set_coalesce(self, cdata):
     try:
         ethtool.set_coalesce(self._name, cdata)
     except IOError as e:
         logging.error("Failed to set coalesce settings: %s", e)