Open a crypt device using ``cryptsetup``. The ``keyfile`` must not be
    ``None`` or ``'none'``, because ``cryptsetup`` will otherwise ask for the
    password interactively.

    CLI Example:

    .. code-block:: bash

        salt '*' cryptdev.open foo /dev/sdz1 /path/to/keyfile

def open(name, device, keyfile):
    '''
    Open a crypt device using ``cryptsetup``. The ``keyfile`` must not be
    ``None`` or ``'none'``, because ``cryptsetup`` will otherwise ask for the
    password interactively.

    CLI Example:

    .. code-block:: bash

        salt '*' cryptdev.open foo /dev/sdz1 /path/to/keyfile
    '''
    if keyfile is None or keyfile == 'none' or keyfile == '-':
        raise CommandExecutionError('For immediate crypt device mapping, keyfile must not be none')

    code = __salt__['cmd.retcode']('cryptsetup open --key-file {0} {1} {2}'
                                   .format(keyfile, device, name))
    return code == 0