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~~~~

def capability_installed(name,
                         source=None,
                         limit_access=False,
                         image=None,
                         restart=False):
    '''
    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~~~~
    '''
    ret = {'name': name,
           'result': True,
           'comment': '',
           'changes': {}}

    old = __salt__['dism.installed_capabilities']()

    if name in old:
        ret['comment'] = 'The capability {0} is already installed'.format(name)
        return ret

    if __opts__['test']:
        ret['changes']['capability'] = '{0} will be installed'.format(name)
        ret['result'] = None
        return ret

    # Install the capability
    status = __salt__['dism.add_capability'](
        name, source, limit_access, image, restart)

    if status['retcode'] not in [0, 1641, 3010]:
        ret['comment'] = 'Failed to install {0}: {1}'\
            .format(name, status['stdout'])
        ret['result'] = False

    new = __salt__['dism.installed_capabilities']()
    changes = salt.utils.data.compare_lists(old, new)

    if changes:
        ret['comment'] = 'Installed {0}'.format(name)
        ret['changes'] = status
        ret['changes']['capability'] = changes

    return ret