PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/win_license.py

"""
Installation and activation of windows licenses
===============================================

Install and activate windows licenses

.. code-block:: yaml

    XXXXX-XXXXX-XXXXX-XXXXX-XXXXX:
      license.activate
"""

import logging

import salt.utils.platform

log = logging.getLogger(__name__)
__virtualname__ = "license"


def __virtual__():
    """
    Only work on Windows
    """
    if salt.utils.platform.is_windows():
        return __virtualname__
    return (False, "Only Windows OS supported")


def activate(name):
    """
    Install and activate the given product key

    name
        The 5x5 product key given to you by Microsoft

    """
    ret = {"name": name, "result": True, "comment": "", "changes": {}}

    product_key = name

    license_info = __salt__["license.info"]()
    licensed = False
    key_match = False
    if license_info is not None:
        licensed = license_info["licensed"]
        key_match = license_info["partial_key"] in product_key

    if not key_match:
        out = __salt__["license.install"](product_key)
        licensed = False
        if "successfully" not in out:
            ret["result"] = False
            ret["comment"] += "Unable to install the given product key is it valid?"
            return ret
    if not licensed:
        out = __salt__["license.activate"]()
        if "successfully" not in out:
            ret["result"] = False
            ret["comment"] += "Unable to activate the given product key."
            return ret
        ret["comment"] += "Windows is now activated."
    else:
        ret["comment"] += "Windows is already activated."
    return ret