ZFS (on Linux) Driver¶
Manila ZFSonLinux share driver 使用 ZFS 文件系统来导出 NFS 共享。使用 Linux 版本的 ZFS 编写和测试。
需求¶
可以通过 “exportfs” 应用处理的 ‘NFS’ 守护进程。
‘ZFS’ 文件系统包,内核或 FUSE 版本。
将由 Manila 使用的 ZFS zpool 应该存在并按预期配置。Manila 不会更改 zpool 配置。
对于根据 manila-share 服务主机 SSH 安装的远程 ZFS 主机。
- 对于支持复制的 ZFS 主机
彼此之间应该使用无密码 SSH 访问。
ZFS 主机应该能够相互访问服务 IP 地址。
支持的操作¶
支持以下操作
创建 NFS 共享
删除 NFS 共享
管理 NFS 共享
取消管理 NFS 共享
- 允许 NFS 共享访问
仅支持 IP 访问类型用于 NFS
支持两种访问级别 - ‘RW’ 和 ‘RO’
拒绝 NFS 共享访问
创建快照
删除快照
管理快照
取消管理快照
从快照创建共享
扩展共享
缩小共享
- 复制 (实验性)
支持创建/更新/删除/提升副本操作
共享迁移 (实验性)
可能性¶
任何数量的 ZFS zpool 都可以被共享驱动程序使用。
允许配置用于共享创建的 ZFS 数据集的默认选项。
允许使用任何数量的嵌套数据集。
所有共享副本都是只读的,只有激活副本是可读写的。
所有共享副本都会定期同步,而不是持续同步。因此,状态 ‘in_sync’ 表示上次同步成功。同步之间的时间范围等于配置全局选项 ‘replica_state_update_interval’ 的值。
驱动程序能够使用限定的额外规范 ‘zfsonlinux:compression’。它可以包含所用 ZFS 应用支持的任何值。但是,如果通过配置选项将其禁用,值为 ‘compression=off’,则将不会使用它。
限制¶
ZFSonLinux share driver 具有以下限制
仅支持 NFS 的 IP 访问类型。
仅支持 FLAT 网络。
‘提升共享副本’ 操作将切换当前 ‘secondary’ 副本和 ‘active’ 副本的角色。它不会使超过一个副本可用。
‘SaMBa’ 基于的共享尚未实现。
‘厚配置’ 尚未实现。
已知问题¶
‘提升共享副本’ 操作将使成为 secondary 的 ZFS 文件系统在 NFS 级别上变为只读。在 ZFS 级别,系统将保持挂载状态 - 可读写。
后端配置¶
需要在 manila 配置文件中配置以下参数,用于 ZFSonLinux 驱动程序
share_driver = manila.share.drivers.zfsonlinux.driver.ZFSonLinuxShareDriver
driver_handles_share_servers = False
- replication_domain = custom_str_value_as_domain_name
如果为空,则将禁用复制
如果设置,则可以与其他具有相同值的后端用作复制对等体。
zfs_share_export_ip = <用户可见的 ZFS 主机 IP 地址>
zfs_service_ip = <ZFS 主机的服务网络接口的 IP 地址>
- zfs_zpool_list = zpoolname1,zpoolname2/nested_dataset_for_zpool2
可以是多个 zpool
可以包含嵌套数据集
- zfs_dataset_creation_options = <ZFS 数据集选项列表>
readonly,quota,sharenfs 和 sharesmb 选项将被忽略
- zfs_dataset_name_prefix = <前缀>
要在每个数据集名称中使用的前缀。
- zfs_dataset_snapshot_name_prefix = <前缀>
要在每个数据集快照名称中使用的前缀。
- zfs_use_ssh = <布尔值>
如果 ZFS 位于与 ‘manila-share’ 服务相同的宿主机上,则设置为 ‘False’
如果 ‘manila-share’ 服务应该使用 SSH 进行 ZFS 配置,则设置为 ‘True’
- zfs_ssh_username = <ssh_用户名>
复制操作需要
如果 ‘zfs_use_ssh’ 设置为 ‘True’,则需要 SSH 到 ZFS 主机
- zfs_ssh_user_password = <ssh_用户密码>
ZFS 主机的 ‘zfs_ssh_username’ 的密码。
仅当 ‘zfs_use_ssh’ 设置为 ‘True’ 时才使用
- zfs_ssh_private_key_path = <私钥 SSH 的路径>
仅当 ‘zfs_use_ssh’ 设置为 ‘True’ 时才使用
- zfs_share_helpers = NFS=manila.share.drivers.zfsonlinux.utils.NFSviaZFSHelper
设置 helpers 的方法与其他各种共享驱动程序类似
至少应该使用一个 helper。
- zfs_replica_snapshot_prefix = <前缀>
要在 ‘update replica’ 操作创建的数据集快照名称中使用的前缀。
- zfs_migration_snapshot_prefix = <前缀>
要在 ‘migration’ 操作创建的数据集快照名称中使用的前缀。
需要重新启动 manila-share 服务才能使配置更改生效。
The manila.share.drivers.zfsonlinux.driver 模块¶
使用 ZFS 文件系统资源并将其导出为共享的 ZFSonLinux share driver 模块。
- class ZFSonLinuxShareDriver(*args, **kwargs)
基于
ExecuteMixin和ShareDriver- create_replica(context, *args, **kwargs)
将活动副本复制到此后端的新的副本。
注意
此调用在创建新副本的主机上进行。
- 参数:
context – 当前上下文
replica_list – 特定共享的所有副本的列表。此列表还包含要创建的副本。 ‘active’ 副本的 ‘replica_state’ 属性将设置为 ‘active’。
示例
[ { 'id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'in_sync', ... 'share_server_id': '4ce78e7b-0ef6-4730-ac2a-fd2defefbd05', 'share_server': <models.ShareServer> or None, }, { 'id': '10e49c3e-aca9-483b-8c2d-1c337b38d6af', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'active', ... 'share_server_id': 'f63629b3-e126-4448-bec2-03f788f76094', 'share_server': <models.ShareServer> or None, }, { 'id': 'e82ff8b6-65f0-11e5-9d70-feff819cdc9f', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'in_sync', ... 'share_server_id': '07574742-67ea-4dfd-9844-9fbd8ada3d87', 'share_server': <models.ShareServer> or None, }, ... ]
- 参数:
new_replica – 共享副本字典。
示例
{ 'id': 'e82ff8b6-65f0-11e5-9d70-feff819cdc9f', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'deleted': False, 'host': 'openstack2@cmodeSSVMNFS2', 'status': 'creating', 'scheduled_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'launched_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'terminated_at': None, 'replica_state': 'out_of_sync', 'availability_zone_id': 'f6e146d0-65f0-11e5-9d70-feff819cdc9f', 'export_locations': [ models.ShareInstanceExportLocations, ], 'access_rules_status': 'out_of_sync', 'share_network_id': '4ccd5318-65f1-11e5-9d70-feff819cdc9f', 'share_server_id': 'e6155221-ea00-49ef-abf9-9f89b7dd900a', 'share_server': <models.ShareServer> or None, }
- 参数:
access_rules – 访问规则列表。这些是共享的其他实例已经遵守的规则。驱动程序应将访问规则应用于新副本,或忽略不适用的访问规则。
示例
[ { 'id': 'f0875f6f-766b-4865-8b41-cccb4cdf1676', 'deleted' = False, 'share_id' = 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'access_type' = 'ip', 'access_to' = '172.16.20.1', 'access_level' = 'rw', } ]
- 参数:
replica_snapshots – 快照实例的字典列表。此列表包括共享的每个快照的快照实例,其 ‘aggregate_status’ 属性在共享管理器启动此请求时报告为 ‘available’。每个列表成员将有两个子字典:‘active_replica_snapshot’ 和 ‘share_replica_snapshot’。 ‘active’ 副本的快照对应于在任何 ‘active’ 副本上的快照实例,而 share_replica_snapshot 对应于需要在正在创建的新共享副本上存在的特定副本的快照实例。驱动程序需要确保在将副本从 ‘out_of_sync’ 转换为 ‘in_sync’ 之前,此快照实例确实可用。 ‘aggregate_status’ 为 ‘creating’ 或 ‘deleting’ 的快照实例将在
update_replicated_snapshot方法中轮询。
示例
[ { 'active_replica_snapshot': { 'id': '8bda791c-7bb6-4e7b-9b64-fefff85ff13e', 'share_instance_id': '10e49c3e-aca9-483b-8c2d-1c337b38d6af', 'status': 'available', 'provider_location': '/2025.2/share-snapshot-10e49c3e-aca9', ... }, 'share_replica_snapshot': { 'id': '', 'share_instance_id': 'e82ff8b6-65f0-11e5-9d70-feff819cdc9f', 'status': 'available', 'provider_location': None, ... }, } ]
- 参数:
share_server – <models.ShareServer> 或 None 正在创建副本的共享服务器。
- 返回值:
None 或字典。字典可以包含 export_locations replica_state 和 access_rules_status。export_locations 是路径列表,replica_state 是 ‘active’、‘in_sync’、‘out_of_sync’ 或 ‘error’ 中的一种。
重要提示
支持 ‘writable’ 类型复制的后端应将 ‘active’ 作为 replica_state 返回。
导出位置应与在
create_share调用期间返回的格式相同。示例
{ 'export_locations': [ { 'path': '172.16.20.22/sample/export/path', 'is_admin_only': False, 'metadata': {'some_key': 'some_value'}, }, ], 'replica_state': 'in_sync', 'access_rules_status': 'in_sync', }
- create_replicated_snapshot(context, *args, **kwargs)
在活动实例上创建快照并在副本之间更新。
注意
此调用在 ‘active’ 副本的主机上进行。驱动程序应将创建的快照传输到各个副本。
驱动程序应将模型更新返回给共享管理器。如果它能够确认已创建传递在此接口中的任何数量的快照实例,则可以将它们的 status 设置为 ‘available’,作为共享管理器将 progress 属性设置为 ‘100%’ 的提示。
- 参数:
context – 当前上下文
replica_list – 特定共享的所有副本的列表。 ‘active’ 副本的 ‘replica_state’ 属性将设置为 ‘active’。
示例
[ { 'id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'in_sync', ... 'share_server_id': '4ce78e7b-0ef6-4730-ac2a-fd2defefbd05', 'share_server': <models.ShareServer> or None, }, { 'id': '10e49c3e-aca9-483b-8c2d-1c337b38d6af', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'active', ... 'share_server_id': 'f63629b3-e126-4448-bec2-03f788f76094', 'share_server': <models.ShareServer> or None, }, ... ]
- 参数:
replica_snapshots – 快照实例的字典列表。这些快照实例跟踪副本中的快照。所有实例的 status 属性都将设置为 ‘creating’。
示例
[ { 'id': 'd3931a93-3984-421e-a9e7-d9f71895450a', 'snapshot_id': '13ee5cb5-fc53-4539-9431-d983b56c5c40', 'status: 'creating', 'progress': '0%', ... }, { 'id': '8bda791c-7bb6-4e7b-9b64-fefff85ff13e', 'snapshot_id': '13ee5cb5-fc53-4539-9431-d983b56c5c40', 'status: 'creating', 'progress': '0%', ... }, ... ]
- 参数:
share_server – <models.ShareServer> 或 None
- 返回值:
快照实例的字典列表。字典可以包含需要在正在创建的快照实例上更新数据库的值。
- 引发:
异常。此方法中的任何异常都将使所有实例设置为 ‘error’。
- create_share(context, *args, **kwargs)
用于创建共享。
- create_share_from_snapshot(context, *args, **kwargs)
用于从快照创建共享。
如果需要从一个主机复制数据到另一个主机,则从快照创建共享可能比简单的克隆操作花费更长的时间。因此,驱动程序可以通过在模型更新中提供“creating_from_snapshot”状态来异步完成此创建。
当异步响应时,驱动程序必须实现“get_share_status”调用,以便为具有“creating_from_snapshot”状态的共享提供更新。
预计驱动程序将返回一个模型更新到共享管理器,其中包含:共享状态和导出位置列表。只有在“available”状态下,才需要导出位置列表。当前支持的状态是“available”和“creating_from_snapshot”。
- 参数:
context – 当前上下文
share – 包含共享数据的共享实例模型。
snapshot – 快照实例模型。
share_server – 共享服务器模型或 None。
parent_share – 包含共享数据和共享服务器模型的父快照的共享模型。
- 返回值:
包含当前共享状态及其导出位置(如果可用)的更新字典。
示例
{ 'status': 'available', 'export_locations': [{...}, {...}], }
- 引发:
ShareBackendException。此方法中的 ShareBackendException 会将实例设置为“error”,并且操作将结束。
- create_snapshot(context, *args, **kwargs)
用于创建快照。
- 参数:
context – 当前上下文
snapshot – 快照模型。可以通过 snapshot[‘share’] 检索共享模型。
share_server – 共享服务器模型或 None。
- 返回值:
None 或包含导出位置列表的字典,如果可以挂载快照。
- delete_replica(context, *args, **kwargs)
删除副本。
注意
此调用在托管要删除的副本的主机上进行。
- 参数:
context – 当前上下文
replica_list – 特定共享的所有副本的列表。此列表还包含要删除的副本。 ‘active’ 副本的 ‘replica_state’ 属性将设置为 ‘active’。
示例
[ { 'id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'in_sync', ... 'share_server_id': '4ce78e7b-0ef6-4730-ac2a-fd2defefbd05', 'share_server': <models.ShareServer> or None, }, { 'id': '10e49c3e-aca9-483b-8c2d-1c337b38d6af', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'active', ... 'share_server_id': 'f63629b3-e126-4448-bec2-03f788f76094', 'share_server': <models.ShareServer> or None, }, { 'id': 'e82ff8b6-65f0-11e5-9d70-feff819cdc9f', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'in_sync', ... 'share_server_id': '07574742-67ea-4dfd-9844-9fbd8ada3d87', 'share_server': <models.ShareServer> or None, }, ... ]
- 参数:
replica – 要删除的共享副本的字典。
示例
{ 'id': 'e82ff8b6-65f0-11e5-9d70-feff819cdc9f', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'deleted': False, 'host': 'openstack2@cmodeSSVMNFS2', 'status': 'available', 'scheduled_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'launched_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'terminated_at': None, 'replica_state': 'in_sync', 'availability_zone_id': 'f6e146d0-65f0-11e5-9d70-feff819cdc9f', 'export_locations': [ models.ShareInstanceExportLocations ], 'access_rules_status': 'out_of_sync', 'share_network_id': '4ccd5318-65f1-11e5-9d70-feff819cdc9f', 'share_server_id': '53099868-65f1-11e5-9d70-feff819cdc9f', 'share_server': <models.ShareServer> or None, }
- 参数:
replica_snapshots – 快照实例的字典列表。字典包含与要删除的共享副本关联的快照实例。在此方法中无法对快照实例进行模型更新。驱动程序应在后端完成对快照和副本本身的清理后返回。驱动程序必须处理快照尚未在此副本上完成 ‘creating’ 的情况。
示例
[ { 'id': '89dafd00-0999-4d23-8614-13eaa6b02a3b', 'snapshot_id': '3ce1caf7-0945-45fd-a320-714973e949d3', 'status: 'available', 'share_instance_id': 'e82ff8b6-65f0-11e5-9d70-feff819cdc9f' ... }, { 'id': '8bda791c-7bb6-4e7b-9b64-fefff85ff13e', 'snapshot_id': '13ee5cb5-fc53-4539-9431-d983b56c5c40', 'status: 'creating', 'share_instance_id': 'e82ff8b6-65f0-11e5-9d70-feff819cdc9f' ... }, ... ]
- 参数:
share_server – <models.ShareServer> 或 None 要删除的副本的共享服务器。
- 返回值:
None。
- 引发:
异常。引发的任何异常都将使共享副本的 ‘status’ 和 ‘replica_state’ 属性设置为 ‘error_deleting’。它不会影响属于此副本的快照。
- delete_replicated_snapshot(context, *args, **kwargs)
通过删除副本中的实例来删除快照。
注意
此调用在 ‘active’ 副本的主机上进行,因为驱动程序可能无法从单个副本删除快照。
驱动程序应将模型更新返回给共享管理器。如果它能够确认已删除传递在此接口中的任何数量的快照实例,则可以将它们的 status 设置为 ‘deleted’,作为共享管理器清理数据库中该实例的提示。
- 参数:
context – 当前上下文
replica_list – 特定共享的所有副本的列表。 ‘active’ 副本的 ‘replica_state’ 属性将设置为 ‘active’。
示例
[ { 'id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'in_sync', ... 'share_server_id': '4ce78e7b-0ef6-4730-ac2a-fd2defefbd05', 'share_server': <models.ShareServer> or None, }, { 'id': '10e49c3e-aca9-483b-8c2d-1c337b38d6af', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'active', ... 'share_server_id': 'f63629b3-e126-4448-bec2-03f788f76094', 'share_server': <models.ShareServer> or None, }, ... ]
- 参数:
replica_snapshots – 快照实例的字典列表。这些快照实例跟踪副本中的快照。所有实例的 status 属性都将设置为 ‘deleting’。
示例
[ { 'id': 'd3931a93-3984-421e-a9e7-d9f71895450a', 'snapshot_id': '13ee5cb5-fc53-4539-9431-d983b56c5c40', 'status': 'deleting', 'progress': '100%', ... }, { 'id': '8bda791c-7bb6-4e7b-9b64-fefff85ff13e', 'snapshot_id': '13ee5cb5-fc53-4539-9431-d983b56c5c40', 'status: 'deleting', 'progress': '100%', ... }, ... ]
- 参数:
share_server – <models.ShareServer> 或 None
- 返回值:
快照实例的字典列表。字典可以包含需要在正在删除的快照实例上更新数据库的值。要确认快照实例的删除,请将实例的 ‘status’ 属性设置为 ‘deleted’ (constants.STATUS_DELETED)
- 引发:
异常。此方法中的任何异常都将使所有快照实例的 status 属性设置为 ‘error_deleting’。
- delete_share(context, *args, **kwargs)
用于删除共享。
- delete_snapshot(context, *args, **kwargs)
用于删除快照。
- 参数:
context – 当前上下文
snapshot – 快照模型。可以通过 snapshot[‘share’] 检索共享模型。
share_server – 共享服务器模型或 None。
- do_setup(context)
执行基本设置和检查。
- ensure_share(context, *args, **kwargs)
调用以确保共享已导出。
驱动程序可以使用此方法更新共享的导出位置列表(如果发生更改)。为此,应返回包含导出位置的列表。
如果驱动程序实现“get_backend_info”和“ensure_shares”,则优选而不是此例程。
- 返回值:
None 或包含导出位置的列表
- extend_share(context, *args, **kwargs)
扩展现有共享的大小。
- 参数:
share – 共享模型
new_size – 共享的新大小(new_size > share[‘size’])
share_server – 可选 – 共享服务器模型
- get_network_allocations_number()
ZFS 不处理网络。返回 0。
- get_pool(share)
返回共享所在的池名称。
- 参数:
share – 由驱动程序托管的共享。
- manage_existing(share, driver_options)
管理现有的 ZFS 数据集作为 manila 共享。
ZFSonLinux驱动程序仅接受一个驱动程序选项‘size’。如果管理员提供了此选项,则将该配额设置为数据集并用作共享大小。否则,驱动程序会将配额设置为使用大小的最近的较大四舍五入整数。驱动程序不期望更改挂载点(应等于默认值,即“/%(dataset_name)s”)。
- 参数:
share – 共享数据
driver_options – 空字典或包含‘size’选项的字典。
- 返回值:
包含共享大小及其导出位置的字典。
- manage_existing_snapshot(snapshot_instance, driver_options)
使用manila管理现有的共享快照。
- 参数:
snapshot_instance – SnapshotInstance数据
driver_options – 仅期望一个可选键‘size’。
- 返回值:
包含共享快照实例字段以供更新的字典,例如
{‘size’: 1, ‘provider_location’: ‘path/to/some/dataset@some_snapshot_tag’,
}
- migration_cancel(context, *args, **kwargs)
取消将共享迁移到另一个主机的操作。
注意
在源共享的后端调用,以取消迁移。
如果可能,驱动程序可以实现一种取消正在进行中的迁移的方法。
- 参数:
context – 请求的‘context.RequestContext’对象。
source_share – 对原始共享模型的引用。
destination_share – 对将被迁移共享使用的共享模型的引用。
source_snapshots – 源共享拥有的快照列表。
snapshot_mappings – 源快照ID到目标快照模型的映射。
share_server – 共享服务器模型或 None。
destination_share_server – 目标共享服务器模型或None。
- migration_check_compatibility(context, *args, **kwargs)
检查给定共享迁移的目标兼容性。
注意
用于测试与目标后端兼容性的调用。
驱动程序应检查它是否与目标后端兼容,以便可以进行驱动程序辅助迁移。
- 参数:
context – 请求的‘context.RequestContext’对象。
source_share – 对要迁移的共享的引用。
destination_share – 对将被迁移共享使用的共享模型的引用。
share_server – 共享服务器模型或 None。
destination_share_server – 目标共享服务器模型或None。
- 返回值:
一个字典,包含指示目标后端是否兼容的值,是否可以在迁移期间保持共享可写,是否可以保留所有文件元数据以及是否可以无中断地执行给定共享的迁移。
示例
{ 'compatible': True, 'writable': True, 'preserve_metadata': True, 'nondisruptive': True, 'preserve_snapshots': True, }
- migration_complete(context, *args, **kwargs)
完成将共享迁移到另一个主机的操作。
注意
在源共享的后端调用,以完成迁移。
如果驱动程序正在实现两阶段迁移,则此方法应执行与迁移的第二阶段相关的破坏性任务,从而完成迁移。驱动程序还应从源后端删除所有原始共享数据。
- 参数:
context – 请求的‘context.RequestContext’对象。
source_share – 对原始共享模型的引用。
destination_share – 对将被迁移共享使用的共享模型的引用。
source_snapshots – 源共享拥有的快照列表。
snapshot_mappings – 源快照ID到目标快照模型的映射。
share_server – 共享服务器模型或 None。
destination_share_server – 目标共享服务器模型或None。
- 返回值:
如果迁移更改了共享导出位置、快照提供程序位置或快照导出位置,则此方法应返回一个包含相关信息的字典。在这种情况下,一个字典包含一个导出位置列表和每个快照(按其ID索引)的更新模型列表。
示例
{ 'export_locations': [ { 'path': '1.2.3.4:/foo', 'metadata': {}, 'is_admin_only': False }, { 'path': '5.6.7.8:/foo', 'metadata': {}, 'is_admin_only': True }, ], 'snapshot_updates': { 'bc4e3b28-0832-4168-b688-67fdc3e9d408': { 'provider_location': '/snapshots/foo/bar_1', 'export_locations': [ { 'path': '1.2.3.4:/snapshots/foo/bar_1', 'is_admin_only': False, }, { 'path': '5.6.7.8:/snapshots/foo/bar_1', 'is_admin_only': True, }, ], }, '2e62b7ea-4e30-445f-bc05-fd523ca62941': { 'provider_location': '/snapshots/foo/bar_2', 'export_locations': [ { 'path': '1.2.3.4:/snapshots/foo/bar_2', 'is_admin_only': False, }, { 'path': '5.6.7.8:/snapshots/foo/bar_2', 'is_admin_only': True, }, ], }, }, }
- migration_continue(context, *args, **kwargs)
继续将共享迁移到另一个主机的操作。
注意
在源共享的后端调用,以继续迁移。
驱动程序应实现此方法,以继续监视存储中的迁移进度并执行以下步骤,直到完成第一阶段为止。
- 参数:
context – 请求的‘context.RequestContext’对象。
source_share – 对原始共享模型的引用。
destination_share – 对将被迁移共享使用的共享模型的引用。
source_snapshots – 源共享拥有的快照列表。
snapshot_mappings – 源快照ID到目标快照模型的映射。
share_server – 共享服务器模型或 None。
destination_share_server – 目标共享服务器模型或None。
- 返回值:
一个布尔值,指示是否完成第一阶段。
- migration_start(context, *args, **kwargs)
开始将共享迁移到另一个主机的操作。
注意
在源共享的后端调用,以启动迁移。
如果驱动程序希望以驱动程序辅助方式执行迁移,则应实现此方法,这对于源共享的后端驱动程序与目标后端驱动程序兼容时非常有用。此方法应在后端启动迁移过程并结束。应在‘migration_continue’中完成以下步骤。
- 参数:
context – 请求的‘context.RequestContext’对象。
source_share – 对原始共享模型的引用。
destination_share – 对将被迁移共享使用的共享模型的引用。
source_snapshots – 源共享拥有的快照列表。
snapshot_mappings – 源快照ID到目标快照模型的映射。
share_server – 共享服务器模型或 None。
destination_share_server – 目标共享服务器模型或None。
- promote_replica(context, *args, **kwargs)
将副本提升到‘active’副本状态。
注意
在托管要提升的副本的主机上进行此调用。
- 参数:
context – 当前上下文
replica_list – 特定共享的所有副本列表。此列表还包含要提升的副本。‘active’副本的‘replica_state’属性将设置为‘active’。
示例
[ { 'id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'in_sync', ... 'share_server_id': '4ce78e7b-0ef6-4730-ac2a-fd2defefbd05', 'share_server': <models.ShareServer> or None, }, { 'id': '10e49c3e-aca9-483b-8c2d-1c337b38d6af', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'active', ... 'share_server_id': 'f63629b3-e126-4448-bec2-03f788f76094', 'share_server': <models.ShareServer> or None, }, { 'id': 'e82ff8b6-65f0-11e5-9d70-feff819cdc9f', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'in_sync', ... 'share_server_id': '07574742-67ea-4dfd-9844-9fbd8ada3d87', 'share_server': <models.ShareServer> or None, }, ... ]
- 参数:
replica – 要提升的副本的字典。
示例
{ 'id': 'e82ff8b6-65f0-11e5-9d70-feff819cdc9f', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'deleted': False, 'host': 'openstack2@cmodeSSVMNFS2', 'status': 'available', 'scheduled_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'launched_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'terminated_at': None, 'replica_state': 'in_sync', 'availability_zone_id': 'f6e146d0-65f0-11e5-9d70-feff819cdc9f', 'export_locations': [ models.ShareInstanceExportLocations ], 'access_rules_status': 'in_sync', 'share_network_id': '4ccd5318-65f1-11e5-9d70-feff819cdc9f', 'share_server_id': '07574742-67ea-4dfd-9844-9fbd8ada3d87', 'share_server': <models.ShareServer> or None, }
- 参数:
access_rules – 访问规则列表。其他共享实例遵守这些访问规则。
示例
[ { 'id': 'f0875f6f-766b-4865-8b41-cccb4cdf1676', 'deleted' = False, 'share_id' = 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'access_type' = 'ip', 'access_to' = '172.16.20.1', 'access_level' = 'rw', } ]
- 参数:
share_server – <models.ShareServer>或None。要提升的副本的共享服务器。
quiesce_wait_time – 秒数或None。共享副本提升静默等待时间。
- 返回值:
updated_replica_list或None。驱动程序可以返回更新后的列表,如请求参数中所述。将更新到数据库的更改是:‘export_locations’、‘access_rules_status’和‘replica_state’。
- 引发:
Exception。这可以是源自BaseException的任何异常。在进行一些必要的清理后,管理器会重新引发此异常。如果驱动程序在提升过程中引发异常,则假定共享的所有副本都处于不一致状态。仅可以通过定期更新调用和/或管理员干预来纠正受影响副本的状态(如果它们再次变得健康)。
- shrink_share(context, *args, **kwargs)
缩小现有共享的大小。
如果共享上的已用空间大于 new_size,驱动程序应引发 ShareShrinkingPossibleDataLoss 异常:raise ShareShrinkingPossibleDataLoss(share_id=share[‘id’])
- 参数:
share – 共享模型
new_size – 共享的新大小(new_size < share[‘size’])
share_server – 可选 – 共享服务器模型
:raises ShareShrinkingPossibleDataLoss, NotImplementedError
- unmanage(share)
从 Manila 管理中删除指定的共享。
- unmanage_snapshot(snapshot_instance)
取消管理数据集快照。
- update_access(context, *args, **kwargs)
更新给定共享的访问规则。
access_rules包含需要应用于共享的所有访问规则。如果驱动程序可以进行批量访问规则更新,则可以安全地忽略add_rules和delete_rules参数。如果驱动程序无法进行批量访问规则更改,则可以依赖于
add_rules中存在新规则,并且delete_rules中存在需要删除的规则。当
delete_rules中的规则从未应用时,驱动程序不得引发异常,也不应尝试将规则设置为“error”状态。add_rules和delete_rules可以是空列表,在这种情况下,驱动程序应确保access_rules中存在的规则与后端上的规则相同。强制执行此情况的一种情况是当更改所有现有规则的访问级别时(共享迁移和可读副本)。驱动程序必须注意共享副本的此调用。当在副本之一上调用“update_access”时,该调用可能会传播到属于该共享的所有副本,尤其是在添加或删除单个规则时。如果特定的访问规则在给定副本的上下文中对驱动程序没有意义,则驱动程序应小心报告正确的行为,并采取有意义的措施。例如,如果在属于“可读”类型复制的副本上请求 R/W 访问权限;驱动程序可以添加 R/O 访问权限而不是 R/W 访问权限。请注意,引发异常将导致副本和共享本身的 access_rules_status 变为“out_of_sync”。驱动程序可以在
create_replica和promote_replica调用上提供的有效访问规则上同步。- 参数:
context – 当前上下文
share – 包含共享数据的共享模型。
access_rules – 给定共享的访问规则列表
add_rules – 空列表或应添加的访问规则列表。access_rules 已经包含这些规则。
delete_rules – 空列表或应删除的访问规则列表。access_rules 不包含这些规则。
update_rules – 空列表或应更新的访问规则列表。access_rules 已经包含这些规则。
share_server – None 或共享服务器模型
- 返回值:
None,或包含格式为
{‘09960614-8574-4e03-89cf-7cf267b0bd08’: {
‘access_key’: ‘alice31493e5441b8171d2310d80e37e’, ‘state’: ‘error’,
},
’28f6eabb-4342-486a-a7f4-45688f0c0295’: {
‘access_key’: ‘bob0078aa042d5a7325480fd13228b’, ‘state’: ‘active’,
},
}
的更新字典。顶层键是需要更新的访问规则的 ‘access_id’ 字段。
access_key``s 是 授予访问权限的实体的凭据(字符串)。 ``access_rules参数中的任何规则都可以更新。重要提示
在此方法中引发异常将强制所有处于“applying”和“denying”状态的规则变为“error”。
可以显式通过此返回参数将访问规则设置为“error”状态,或者因为在此方法中引发了异常。这样的访问规则将不再发送到驱动程序后续的访问规则更新中。但是,当用户拒绝该规则时,驱动程序将被要求拒绝代表该规则的客户端的访问权限。我们期望在驱动程序上出错的规则永远不会存在于后端。因此,请勿使删除请求失败。
此外,驱动程序可能会收到请求以添加规则,该规则已经存在于后端。当共享管理器服务在驱动程序提交访问规则更改时停止工作时,可能会发生这种情况。由于我们无法确定在中断之前驱动程序是否已成功应用该规则,因此我们将所有“applying”转换规则视为新规则并重复该请求。
- update_replica_state(context, *args, **kwargs)
更新副本的replica_state。
注意
在托管要更新的副本的主机上进行此调用。
驱动程序应在此方法中修复可能中断的复制关系(如果可能)。
此方法由共享管理器定期调用;并且由管理员通过‘resync’API请求时调用。
- 参数:
context – 当前上下文
replica_list – 特定共享的所有副本列表。此列表还包含要更新的副本。‘active’副本的‘replica_state’属性将设置为‘active’。
示例
[ { 'id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'in_sync', ... 'share_server_id': '4ce78e7b-0ef6-4730-ac2a-fd2defefbd05', 'share_server': <models.ShareServer> or None, }, { 'id': '10e49c3e-aca9-483b-8c2d-1c337b38d6af', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'active', ... 'share_server_id': 'f63629b3-e126-4448-bec2-03f788f76094', 'share_server': <models.ShareServer> or None, }, { 'id': 'e82ff8b6-65f0-11e5-9d70-feff819cdc9f', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'in_sync', ... 'share_server_id': '07574742-67ea-4dfd-9844-9fbd8ada3d87', 'share_server': <models.ShareServer> or None, }, ... ]
- 参数:
replica – 正在更新的副本的字典。副本状态始终为‘in_sync’、‘out_of_sync’或‘error’。处于‘active’状态的副本将不会通过此参数传递。
示例
{ 'id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'deleted': False, 'host': 'openstack2@cmodeSSVMNFS1', 'status': 'available', 'scheduled_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'launched_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'terminated_at': None, 'replica_state': 'in_sync', 'availability_zone_id': 'e2c2db5c-cb2f-4697-9966-c06fb200cb80', 'export_locations': [ models.ShareInstanceExportLocations, ], 'access_rules_status': 'in_sync', 'share_network_id': '4ccd5318-65f1-11e5-9d70-feff819cdc9f', 'share_server_id': '4ce78e7b-0ef6-4730-ac2a-fd2defefbd05', }
- 参数:
access_rules – 访问规则列表。其他共享实例遵守这些访问规则。驱动程序可以尝试同步任何未应用的access_rules。
示例
[ { 'id': 'f0875f6f-766b-4865-8b41-cccb4cdf1676', 'deleted' = False, 'share_id' = 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'access_type' = 'ip', 'access_to' = '172.16.20.1', 'access_level' = 'rw', } ]
- 参数:
replica_snapshots – 快照实例的字典列表。这包括共享的每个快照的快照实例,其‘aggregate_status’属性报告为‘available’,当共享管理器启动此请求时。每个列表成员将有两个子字典:‘active_replica_snapshot’和‘share_replica_snapshot’。‘active’副本快照对应于共享的任何‘active’副本上的快照实例,而share_replica_snapshot对应于正在更新的特定副本的快照实例。驱动程序需要在从‘out_of_sync’过渡到‘in_sync’之前确保此快照实例真正可用。
示例
[ { 'active_replica_snapshot': { 'id': '8bda791c-7bb6-4e7b-9b64-fefff85ff13e', 'share_instance_id': '10e49c3e-aca9-483b-8c2d-1c337b38d6af', 'status': 'available', 'provider_location': '/2025.2/share-snapshot-10e49c3e-aca9', ... }, 'share_replica_snapshot': { 'id': '10e49c3e-aca9-483b-8c2d-1c337b38d6af', 'share_instance_id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'status': 'creating', 'provider_location': None, ... }, } ]
- 参数:
share_server – <models.ShareServer> 或 None
- 返回值:
replica_state:表示replica_state的字符串值。有效值为‘in_sync’和‘out_of_sync’或None(以保持当前replica_state不变)。
- update_replicated_snapshot(context, *args, **kwargs)
更新驻留在副本上的快照实例的状态。
注意
对于DR和Readable风格的复制,此调用是在副本的主机上进行的,而不是‘active’副本的主机上。
此方法由共享管理器定期调用。它将查询跟踪跨非‘active’副本的父快照的快照实例。驱动程序可以预期实例的状态为‘creating’或‘deleting’。如果驱动程序看到快照实例已从副本的后端删除,并且实例状态设置为‘deleting’,则预计会引发SnapshotResourceNotFound异常。所有其他异常会将快照实例状态设置为‘error’。如果实例未处于‘deleting’状态,则引发SnapshotResourceNotFound会将实例状态设置为‘error’。
- 参数:
context – 当前上下文
replica_list – 特定共享的所有副本的列表。 ‘active’ 副本的 ‘replica_state’ 属性将设置为 ‘active’。
示例
[ { 'id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'in_sync', ... 'share_server_id': '4ce78e7b-0ef6-4730-ac2a-fd2defefbd05', 'share_server': <models.ShareServer> or None, }, { 'id': '10e49c3e-aca9-483b-8c2d-1c337b38d6af', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'replica_state': 'active', ... 'share_server_id': 'f63629b3-e126-4448-bec2-03f788f76094', 'share_server': <models.ShareServer> or None, }, ... ]
- 参数:
share_replica – 共享副本字典。此副本与正在更新其状态的快照实例相关联。处于‘active’replica_state的副本将不会通过此参数传递。
示例
{ 'id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'deleted': False, 'host': 'openstack2@cmodeSSVMNFS1', 'status': 'available', 'scheduled_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'launched_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'terminated_at': None, 'replica_state': 'in_sync', 'availability_zone_id': 'e2c2db5c-cb2f-4697-9966-c06fb200cb80', 'export_locations': [ models.ShareInstanceExportLocations, ], 'access_rules_status': 'in_sync', 'share_network_id': '4ccd5318-65f1-11e5-9d70-feff819cdc9f', 'share_server_id': '4ce78e7b-0ef6-4730-ac2a-fd2defefbd05', }
- 参数:
replica_snapshots – 快照实例的字典列表。这些快照实例跟踪跨副本的快照。这将包括正在更新的快照实例。
示例
[ { 'id': 'd3931a93-3984-421e-a9e7-d9f71895450a', 'snapshot_id': '13ee5cb5-fc53-4539-9431-d983b56c5c40', ... }, { 'id': '8bda791c-7bb6-4e7b-9b64-fefff85ff13e', 'snapshot_id': '13ee5cb5-fc53-4539-9431-d983b56c5c40', ... }, ... ]
- 参数:
replica_snapshot – 快照实例的字典。这是要更新的实例。当通过此参数发送时,它将处于‘creating’或‘deleting’状态。
示例
{ 'name': 'share-snapshot-18825630-574f-4912-93bb-af4611ef35a2', 'share_id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'share_name': 'share-d487b88d-e428-4230-a465-a800c2cce5f8', 'status': 'creating', 'id': '18825630-574f-4912-93bb-af4611ef35a2', 'deleted': False, 'created_at': datetime.datetime(2016, 8, 3, 0, 5, 58), 'share': <models.ShareInstance>, 'updated_at': datetime.datetime(2016, 8, 3, 0, 5, 58), 'share_instance_id': 'd487b88d-e428-4230-a465-a800c2cce5f8', 'snapshot_id': '13ee5cb5-fc53-4539-9431-d983b56c5c40', 'progress': '0%', 'deleted_at': None, 'provider_location': None, }
- 参数:
share_server – <models.ShareServer> 或 None
- 返回值:
replica_snapshot_model_update:一个字典。该字典必须包含需要在副本上快照实例的数据库上更新的值。
- 引发:
exception.SnapshotResourceNotFound。对于未在后端找到且状态为‘deleting’的快照,引发此异常。
- ensure_share_server_not_provided(f)
- get_backend_configuration(backend_name)
The manila.share.drivers.zfsonlinux.utils Module¶
- 用于存储ZFSonLinux驱动程序实用程序内容的模块,例如
通用ZFS代码
共享助手
- class ExecuteMixin
Bases:
ExecuteMixin- execute(*cmd, **kwargs)
运行shell命令的通用接口。
- execute_with_retry(*cmd, **kwargs)
通用shell接口的重试包装器。
- get_zfs_option(dataset_name, option_name, **kwargs)
返回请求的zfs数据集选项的值。
- get_zpool_option(zpool_name, option_name, **kwargs)
返回请求的zpool选项的值。
- init_execute_mixin(*args, **kwargs)
在驱动程序的__init__()结束时调用的混合类的初始化方法。
- parse_zfs_answer(string)
返回ZFS shell命令返回的数据的字典列表。
- zfs(*cmd, **kwargs)
ZFS shell命令执行器。
- zfs_with_retry(*cmd, **kwargs)
ZFS shell命令执行器。
- class NASHelperBase(configuration)
基类:
object‘ZFS on Linux’驱动程序的共享助手的基类。
- abstract create_exports(dataset_name, executor)
创建共享导出。
- abstract get_exports(dataset_name, service, executor)
获取/读取共享导出。
- abstract remove_exports(dataset_name, executor)
删除共享导出。
- abstract update_access(dataset_name, access_rules, add_rules, delete_rules, executor)
更新指定的 ZFS 数据集的访问规则。
- abstract verify_setup()
执行必要的检查。
- class NFSviaZFSHelper(configuration)
继承自:
ExecuteMixin,NASHelperBase用于处理 ZFS 数据集作为 NFS 共享的辅助类。
内核版本和 Fuse 版本的 ZFS 在设置访问规则的语法上有所不同,此辅助类旨在满足两者,并进行自动检测。
- create_exports(dataset_name, executor=None)
为给定的 ZFS 数据集创建 NFS 共享导出。
- get_exports(dataset_name, executor=None)
获取/读取给定 ZFS 数据集的 NFS 共享导出。
- property is_kernel_version
指示是否正在使用内核版本的 ZFS。
- remove_exports(*args, **kwargs)
删除共享导出。
- update_access(*args, **kwargs)
更新指定的 ZFS 数据集的访问规则。
- verify_setup()
执行必要的检查。
- get_remote_shell_executor(ip, port, conn_timeout, login=None, password=None, privatekey=None, max_size=10)
- zfs_dataset_synchronized(f)