def create_luks(ns, device, passphrase):
    """
    Format given device with LUKS encryption format. All data on the device
    will be deleted! Encryption key and algorithm will be chosen automatically.

    :type device: LMIInstance/CIM_StorageExtent or string
    :param device: Device to format with LUKS data
    :type passphrase: string
    :param passphrase: Password to open the encrypted data. This is not the
            encryption key.
    :rtype: LMIInstance/LMI_EncryptionFormat
    """
    device = common.str2device(ns, device)
    service = ns.LMI_ExtentEncryptionConfigurationService.first_instance()
    (ret, outparams, err) = service.SyncCreateEncryptionFormat(
            InExtent=device,
            Passphrase=passphrase)
    if ret != 0:
        if err:
            raise LmiFailed("Cannot create LUKS format: %s." % err)
        values = service.CreateEncryptionFormat.CreateEncryptionFormatValues
        raise LmiFailed("Cannot create LUKS format: %s."
                % (values.value_name(ret),))

    LOG().info("Created LUKS on %s", device.Name)
    return outparams['Format']
dataset/ETHPy150Open openlmi/openlmi-scripts/commands/storage/lmi/scripts/storage/luks.py/create_luks/original