File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/win_license.cpython-310.pyc
Back
o ;j � @ sf d Z ddlZddlZddlZe�e�ZdZdd� Z dd� Z dd � Zd d� Zdd � Z dd� Zdd� ZdS )z� This module allows you to manage windows licensing via slmgr.vbs .. code-block:: bash salt '*' license.install XXXXX-XXXXX-XXXXX-XXXXX-XXXXX � N�licensec C s t jj�� rtS dS )z Only work on Windows )Fz9Module win_license: module only works on Windows systems.)�salt�utils�platformZ is_windows�__virtualname__� r r �L/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/win_license.py�__virtual__ s r c C s d}t d |�}| dd� |v S )a� Check to see if the product key is already installed. Note: This is not 100% accurate as we can only see the last 5 digits of the license. Args: product_key (str): The product key to check. Returns: bool: ``True`` if the last 5 digits match the current product key, otherwise ``False``. CLI Example: .. code-block:: bash salt '*' license.installed XXXXX-XXXXX-XXXXX-XXXXX-XXXXX �*cscript C:\Windows\System32\slmgr.vbs /dli�cmd.run���N��__salt__)�product_key�cmd�outr r r � installed s r c C s d| � �}t d |�S )a Install the given product key Args: product_key (str): The product key to install. Returns: str: The output of the ``slmgr.vbs`` script CLI Example: .. code-block:: bash salt '*' license.install XXXXX-XXXXX-XXXXX-XXXXX-XXXXX z+cscript C:\Windows\System32\slmgr.vbs /ipk r r )r r r r r �install5 s r c C � d} t d | �S )z{ Uninstall the current product key CLI Example: .. code-block:: bash salt '*' license.uninstall z*cscript C:\Windows\System32\slmgr.vbs /upkr r �r r r r � uninstallJ � r c C r )z� Attempt to activate the current machine via Windows Activation CLI Example: .. code-block:: bash salt '*' license.activate z*cscript C:\Windows\System32\slmgr.vbs /ator r r r r r �activateX r r c C s d} t d | �}d|v S )z� Return true if the current machine is licensed correctly CLI Example: .. code-block:: bash salt '*' license.licensed r r zLicense Status: Licensedr )r r r r r �licensedf s r c C sV d} t d | �}t�d|tj�}|dur)|�� }|d |d |d d|d v d �S dS )z� Return information about the license, if the license is not correctly activated this will return None. CLI Example: .. code-block:: bash salt '*' license.info r r zTName: (.*)\r\nDescription: (.*)\r\nPartial Product Key: (.*)\r\nLicense Status: (.*)Nr � � ZLicensed� )�name�descriptionZpartial_keyr )r �re�search� MULTILINE�groups)r r �matchr"