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__/win_dism.cpython-310.pyc
o

�N�g0;�@s�dZddlZddlZddlZddlZe�e�ZdZ	dd�Z
	ddd�Zdd	d
�Z						ddd�Z
dd
d�Z	ddd�Zddd�Zddd�ZdS)a

Installing of Windows features using DISM
=========================================

Install windows features/capabilties with DISM

.. code-block:: yaml

    Language.Basic~~~en-US~0.0.1.0:
      dism.capability_installed

    NetFx3:
      dism.feature_installed
�NZdismcCstjj��sdStS)zA
    Only work on Windows where the DISM module is available
    )Fz Module only available on Windows)�salt�utils�platformZ
is_windows�__virtualname__�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/win_dism.py�__virtual__srFc
Cs�|ddid�}td�}||vrd|�d�|d<|Stdr-|�d	�|d
d<d|d
<|Std|||||�}|ddvrKd�||d�|d<d|d
<td�}tjj�||�}	|	rkd|��|d<||d
<|	|d
d<|S)a5
    Install a DISM capability

    Args:
        name (str): The capability to install
        source (str): The optional source of the capability
        limit_access (bool): Prevent DISM from contacting Windows Update for
            online images
        image (Optional[str]): The path to the root directory of an offline
            Windows image. If `None` is passed, the running operating system is
            targeted. Default is None.
        restart (Optional[bool]): Reboot the machine if required by the install

    Example:
        Run ``dism.available_capabilities`` to get a list of available
        capabilities. This will help you get the proper name to use.

        .. code-block:: yaml

            install_dotnet35:
              dism.capability_installed:
                - name: NetFX3~~~~
    T���name�result�comment�changes�dism.installed_capabilities�The capability � is already installedr
�test� will be installedr�
capabilityNrzdism.add_capability�retcode�riii��Failed to install {}: {}�stdoutF�
Installed ��__salt__�__opts__�formatrr�data�
compare_lists)
r�source�limit_access�image�restart�ret�old�status�newrrrr�capability_installed$s(

r(cCs�|ddid�}td�}||vrd|�d�|d<|Stdr-|�d	�|d
d<d|d
<|Std|||�}|ddvrId�||d�|d<d|d
<td�}tjj�||�}|rid|��|d<||d
<||d
d<|S)a�
    Uninstall a DISM capability

    Args:
        name (str): The capability to uninstall
        image (Optional[str]): The path to the root directory of an offline
            Windows image. If `None` is passed, the running operating system is
            targeted. Default is None.
        restart (Optional[bool]): Reboot the machine if required by the
            uninstall

    Example:
        Run ``dism.installed_capabilities`` to get a list of installed
        capabilities. This will help you get the proper name to use.

        .. code-block:: yaml

            remove_dotnet35:
              dism.capability_removed:
                - name: NetFX3~~~~
    Tr	r
rr� is already removedr
r� will be removedrrNrzdism.remove_capabilityrr�Failed to remove {}: {}rF�Removed r)rr"r#r$r%r&r'rrrr�capability_removed]s(

r-cCs�|ddid�}td�}||vrd|�d�|d<|Stdr-|�d	�|d
d<d|d
<|Std|||||||�}	|	ddvrMd�||	d�|d<d|d
<td�}
tjj�||
�}|rmd|��|d<|	|d
<||d
d<|S)a�
    Install a DISM feature

    Args:
        name (str): The feature in which to install
        package (Optional[str]): The parent package for the feature. You do not
            have to specify the package if it is the Windows Foundation Package.
            Otherwise, use package to specify the parent package of the feature
        source (str): The optional source of the feature
        limit_access (bool): Prevent DISM from contacting Windows Update for
            online images
        enable_parent (Optional[bool]): True will enable all parent features of
            the specified feature
        image (Optional[str]): The path to the root directory of an offline
            Windows image. If `None` is passed, the running operating system is
            targeted. Default is None.
        restart (Optional[bool]): Reboot the machine if required by the install

    Example:
        Run ``dism.available_features`` to get a list of available features.
        This will help you get the proper name to use.

        .. code-block:: yaml

            install_telnet_client:
              dism.feature_installed:
                - name: TelnetClient
    Tr	r
�dism.installed_features�The feature rr
rrr�featureNrzdism.add_featurerrrrFrr)r�packager r!Z
enable_parentr"r#r$r%r&r'rrrr�feature_installed�s,%
�
r2c	Cs�|ddid�}td�}||vrd|�d�|d<|Stdr-|�d	�|d
d<d|d
<|Std||||�}|ddvrJd�||d�|d<d|d
<td�}tjj�||�}|rjd|��|d<||d
<||d
d<|S)a:
    Disables a feature.

    Args:
        name (str): The feature to disable
        remove_payload (Optional[bool]): Remove the feature's payload. Must
            supply source when enabling in the future.
        image (Optional[str]): The path to the root directory of an offline
            Windows image. If `None` is passed, the running operating system is
            targeted. Default is None.
        restart (Optional[bool]): Reboot the machine if required by the
            uninstall

    Example:
        Run ``dism.installed_features`` to get a list of installed features.
        This will help you get the proper name to use.

        .. code-block:: yaml

            remove_telnet_client:
              dism.feature_removed:
                - name: TelnetClient
                - remove_payload: True
    Tr	r
r.r/r)r
rr*rr0Nrzdism.remove_featurerrr+rFr,r)	rZremove_payloadr"r#r$r%r&r'rrrr�feature_removed�s(

r3cCs0|ddid�}d|vr(tj�|�s(tdrd|d<nd|d<d	|�d
�|d<|Std�}td
|�}|d|vrEd�||d�|d<|StdrX|�d�|dd<d|d<|Std|||||�}|ddvrvd�||d�|d<d|d<td�}	tjj�	||	�}
|
r�d|��|d<||d<|
|dd<|S)a;
    Install a package.

    Args:
        name (str): The package to install. Can be a .cab file, a .msu file,
            or a folder
        ignore_check (Optional[bool]): Skip installation of the package if the
            applicability checks fail
        prevent_pending (Optional[bool]): Skip the installation of the package
            if there are pending online actions
        image (Optional[str]): The path to the root directory of an offline
            Windows image. If `None` is passed, the running operating system is
            targeted. Default is None.
        restart (Optional[bool]): Reboot the machine if required by the install

    Example:

        .. code-block:: yaml

            install_KB123123123:
              dism.package_installed:
                - name: C:\Packages\KB123123123.cab
    Tr	r
�~rNrF�
Package path � does not existr
�dism.installed_packages�dism.package_info�Package Identityz'The package {} is already installed: {}rrr1zdism.add_packagerrrrr�
�os�path�existsrrrrrrr)rZignore_checkZprevent_pendingr"r#r$r%�package_infor&r'rrrr�package_installeds>

�
�
r?c	Cs0|ddid�}d|vr(tj�|�s(tdrd|d<nd|d<d	|�d
�|d<|Std�}td
|�}d|vs=|d|vrGd|�d�|d<|StdrZ|�d�|dd<d|d<|Std|||�}|ddvrvd�||d�|d<d|d<td�}tjj�	||�}|r�d|��|d<||d<||dd<|S)a

    Uninstall a package

    Args:
        name (str): The full path to the package. Can be either a .cab file or a
            folder. Should point to the original source of the package, not to
            where the file is installed. This can also be the name of a package as listed in
            ``dism.installed_packages``
        image (Optional[str]): The path to the root directory of an offline
            Windows image. If `None` is passed, the running operating system is
            targeted. Default is None.
        restart (Optional[bool]): Reboot the machine if required by the
            uninstall

    Example:

        .. code-block:: yaml

            # Example using source
            remove_KB1231231:
              dism.package_installed:
                - name: C:\Packages\KB1231231.cab

            # Example using name from ``dism.installed_packages``
            remove_KB1231231:
              dism.package_installed:
                - name: Package_for_KB1231231~31bf3856ad364e35~amd64~~10.0.1.3
    Tr	r
r4rNrFr5r6r
r7r8r9zThe package r)r*rr1zdism.remove_packagerrr+rr,r:)	rr"r#r$r%r>r&r'rrrr�package_removedYs8


r@c	Cs�|ddid�}td||d�}|dur|�d�|d<|Std	r/|�d
�|dd<d|d
<|Std�}td|||d�}|ddvrSd�||d�|d<d|d
<|Std�}tjj�||�}|rsd|��|d<||d<||dd<|S)a
    Uninstall a KB package

    .. versionadded:: 3006.0

    Args:
        name (str): The name of the KB. Can be with or without the KB at the
            beginning.
        image (Optional[str]): The path to the root directory of an offline
            Windows image. If `None` is passed, the running operating system is
            targeted. Default is None.
        restart (Optional[bool]): Reboot the machine if required by the
            uninstall

    Example:

        .. code-block:: yaml

            # Example using full KB name
            remove_KB1231231:
              dism.package_installed:
                - name: KB1231231

            # Example using just he KB number
            remove_KB1231231:
              dism.package_installed:
                - name: 1231231
    Tr	r
zdism.get_kb_package_name)�kbr"Nz is not installedr
rr*rr1rr7zdism.remove_kb)rAr"r#rrr+rFr,r)	rr"r#r$�pkg_namer%r&r'rrrr�
kb_removed�s,

rC)NFNF)NF)NNFFNF)FNF)FFNF)�__doc__�loggingr;Zsalt.utils.datarZsalt.utils.platform�	getLogger�__name__�logrrr(r-r2r3r?r@rCrrrr�<module>s.

�
97
�
F9
�
IM