HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/ethtool.cpython-310.pyc
o

�N�g'�@sNdZddlZddlmZe�e�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�ZdS)a�
Configuration of network device

.. versionadded:: 2016.11.0

:codeauthor:    Krzysztof Pawlowski <msciciel@msciciel.eu>
:maturity:      new
:depends:       python-ethtool
:platform:      linux

.. code-block:: yaml

    eth0:
      ethtool.coalesce:
        - name: eth0
        - rx_usecs: 24
        - tx_usecs: 48

    eth0:
      ethtool.ring:
        - name: eth0
        - rx: 1024
        - tx: 1024

    eth0:
      ethtool.offload:
        - name: eth0
        - tcp_segmentation_offload: on

�N)�CommandExecutionErrorcCsdtvrdSdS)z
    Provide ethtool state
    zethtool.show_driverZethtool)Fz"ethtool module could not be loaded)�__salt__�rr�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/ethtool.py�__virtual__(src

Ks�|idd|�d�d�}d}d|vrt�dd�|d<zutd|�}t|t�s3d|d<d	�|�|d
<|WSi}g}|��D]\}}||vrZ|||krZ|�||i�|�|�d|���q;|drx|sd|WS|rxd|d<d
�|d�	|��|d
<|WS|r�d}d|�d�|d
<d�	|�|dd<Wnt
y�}	zd|d<t|	�|d
<|WYd}	~	Sd}	~	ww|r�z
td|fi|��W|St
y�}	zd|d<t|	�|d
<|WYd}	~	Sd}	~	ww|S)am
    Manage coalescing settings of network device

    name
        Interface name to apply coalescing settings

    .. code-block:: yaml

        eth0:
          ethtool.coalesce:
            - name: eth0
            - adaptive_rx: on
            - adaptive_tx: on
            - rx_usecs: 24
            - rx_frame: 0
            - rx_usecs_irq: 0
            - rx_frames_irq: 0
            - tx_usecs: 48
            - tx_frames: 0
            - tx_usecs_irq: 0
            - tx_frames_irq: 0
            - stats_block_usecs: 0
            - pkt_rate_low: 0
            - rx_usecs_low: 0
            - rx_frames_low: 0
            - tx_usecs_low: 0
            - tx_frames_low: 0
            - pkt_rate_high: 0
            - rx_usecs_high: 0
            - rx_frames_high: 0
            - tx_usecs_high: 0
            - tx_frames_high: 0
            - sample_interval: 0

    T�Network device z$ coalescing settings are up to date.��name�changes�result�commentF�testzethtool.show_coalescerz/Device {} coalescing settings are not supportedr�: Nz7Device {} coalescing settings are set to be updated:
{}�
�Device z coalescing settings updated.r
Zethtool_coalescezethtool.set_coalesce)�__opts__�getr�
isinstance�dict�format�items�update�append�join�AttributeError�str)
r	�kwargs�retZapply_coalescing�old�new�diff�key�value�errorrrr�coalesce1sn%
�
��
��������r$c

Ks�|idd|�d�d�}d}d|vrt�dd�|d<z�td|�}t|t�s4d|d<d	|�d
�|d<|WSi}g}|��D]*\}}||vrf|dkrO||�d
�}|||krf|�||i�|�|�d|���q<|dr�|sp|WS|r�d|d<d�|d�	|��|d<|WS|r�d}d	|�d�|d<d�	|�|dd<Wnt
y�}	zd|d<t|	�|d<|WYd}	~	Sd}	~	ww|r�z
td|fi|��W|St
y�}	zd|d<t|	�|d<|WYd}	~	Sd}	~	ww|S)a]
    Manage rx/tx ring parameters of network device

    Use 'max' word to set with factory maximum

    name
        Interface name to apply ring parameters

    .. code-block:: yaml

        eth0:
          ethtool.ring:
            - name: eth0
            - rx: 1024
            - rx_mini: 0
            - rx_jumbo: 0
            - tx: max

    Trz  ring parameters are up to date.rFr
zethtool.show_ringrrz" ring parameters are not supportedr�maxZ_maxrNz3Device {} ring parameters are set to be updated:
{}rz ring parameters updated.r
Zethtool_ringzethtool.set_ring�rrrrrrrrrrrr)
r	rrZ
apply_ringrrr r!r"r#rrr�ring�sp
�
�
��������r'c

Ks�|idd|�d�d�}d}d|vrt�dd�|d<z|td|�}t|t�s4d|d<d	|�d
�|d<|WSi}g}|��D]%\}}|rDdpEd
}||vra|||kra|�||i�|�|�d|���q<|dr|sk|WS|rd|d<d�|d�	|��|d<|WS|r�d}d	|�d�|d<d�	|�|dd<Wnt
y�}	zd|d<t|	�|d<|WYd}	~	Sd}	~	ww|r�z
td|fi|��W|St
y�}	zd|d<t|	�|d<|WYd}	~	Sd}	~	ww|S)a

    Manage protocol offload and other features of network device

    name
        Interface name to apply coalescing settings

    .. code-block:: yaml

        eth0:
          ethtool.offload:
            - name: eth0
            - tcp_segmentation_offload: on

    Trz! offload settings are up to date.rFr
zethtool.show_offloadrrz# offload settings are not supportedr�on�offrNz4Device {} offload settings are set to be updated:
{}rz offload settings updated.r
Zethtool_offloadzethtool.set_offloadr&)
r	rrZ
apply_offloadrrr r!r"r#rrr�offload�sl
�
�
��������r*c
Ks�|idd|�d�d�}d}ztd|�}Wnty,d|d<d|�d	�|d
<|YSwdddd
�}i}g}|��D]2\}}	|��}||vrm|	|||krm|�||	i�|	dur]d}	n|	durcd}	|�|�d|	���q;|sr|Stdr�d|d<d�|d�|��|d
<|Sztd|fi|��d|�d�|d
<d�|�|dd<W|Sty�}
zd|d<t	|
�|d
<|WYd}
~
Sd}
~
ww)a/
    .. versionadded:: 3006.0

    Manage pause parameters of network device

    name
        Interface name to apply pause parameters

    .. code-block:: yaml

        eth0:
          ethtool.pause:
            - name: eth0
            - autoneg: off
            - rx: off
            - tx: off

    Trz! pause parameters are up to date.rFzethtool.show_pauserrz# pause parameters are not supportedrZ
AutonegotiateZRX)Zautoneg�rxZtxr(r)rr
Nz4Device {} pause parameters are set to be updated:
{}rzethtool.set_pausez pause parameters updated.r
Z
ethtool_pause)
rrr�lowerrrrrrr)r	rrZapply_pauserZ	pause_maprr r!r"�excrrr�pause<sb
����
����r.)�__doc__�loggingZsalt.exceptionsr�	getLogger�__name__�logrr$r'r*r.rrrr�<module>s
	eWO