Share 基本操作

基本概念

要创建文件共享并访问它,以下基本概念是先决知识

  1. 要创建共享,请使用 openstack share create 命令并指定所需的参数:共享的大小和共享的文件系统协议。支持 NFSCIFSGlusterFSHDFSCephFSMAPRFS 共享文件系统协议。

  2. 还可以选择指定共享网络和共享类型。

  3. 共享可用后,使用 openstack share show 命令获取共享导出位置。

  4. 获取共享导出位置后,可以为共享创建 访问规则,挂载它并在远程文件系统上使用文件。

共享文件系统服务中由不同供应商创建了大量的共享驱动程序。作为 Python 类,每个共享驱动程序都可以设置为 后端并在后端运行以管理共享操作。

最初,后端有两种驱动程序模式

  • 无共享服务器模式

  • 共享服务器模式

每个共享驱动程序支持两种可能的后端模式之一,可以在 manila.conf 文件中进行配置。 manila.conf 文件中的 driver_handles_share_servers 配置选项设置共享服务器模式或无共享服务器模式,并定义共享存储生命周期管理的驱动程序模式

模式

配置选项

描述

无共享服务器

driver_handles_share_servers = False

管理员而不是共享驱动程序管理带有某些网络接口的裸机存储,而不是共享服务器的存在。

共享服务器

driver_handles_share_servers = True

共享驱动程序创建共享服务器并管理或处理共享服务器生命周期。

重要的是 共享类型 具有额外的规范,这些规范有助于调度程序过滤后端并为请求创建共享的用户选择合适的后端。每个共享类型所需的额外布尔规范是 driver_handles_share_servers。作为管理员,您可以创建具有所需规范的共享类型。有关管理共享类型和配置后端的详细信息,请参阅 共享类型多存储配置 文档。

您可以按照上述两种模式之一创建共享

在无共享服务器模式下创建共享

要在无共享服务器模式下创建文件共享,您需要

  1. 要创建共享,请使用 openstack share create 命令并指定所需的参数:共享的大小和共享的文件系统协议。支持 NFSCIFSGlusterFSHDFSCephFSMAPRFS 共享文件系统协议。

  2. 您应该指定带有 driver_handles_share_servers = False 额外规范的 共享类型

  3. 您不得指定 share network,因为未创建共享服务器。在这种模式下,共享文件系统服务期望管理员具有带有某些网络接口的裸机存储。

  4. openstack share create 命令创建共享。此命令执行以下操作

    • manila-scheduler 服务将找到带有 driver_handles_share_servers = False 模式的后端,因为过滤了共享类型的额外规范。

    • 使用在找到的后端中指定的存储创建共享。

  5. 共享可用后,使用 openstack share show 命令获取共享导出位置。

在示例中,创建的共享类型名为 dhss_false,带有 driver_handles_share_servers = False 额外规范。

检查存在的共享类型,运行

$ openstack share type list
+----------+----------+------------+------------+----------------------+----------------------+-------------+
| ID       | Name     | Visibility | Is Default | Required Extra Specs | Optional Extra Specs | Description |
+----------+----------+------------+------------+----------------------+----------------------+-------------+
| 807e5cd7 | default  | public     | True       | driver_handles_share | snapshot_support :   | None        |
| -a0e7-   |          |            |            | _servers : True      | True                 |             |
| 4912-    |          |            |            |                      | create_share_from_sn |             |
| 8f7d-    |          |            |            |                      | apshot_support :     |             |
| 352512ce |          |            |            |                      | True                 |             |
| 51c3     |          |            |            |                      | revert_to_snapshot_s |             |
|          |          |            |            |                      | upport : True        |             |
|          |          |            |            |                      | mount_snapshot_suppo |             |
|          |          |            |            |                      | rt : True            |             |
| d57dfcb5 | dhss_fal | public     | False      | driver_handles_share | snapshot_support :   | None        |
| -3026-   | se       |            |            | _servers : False     | True                 |             |
| 4018-    |          |            |            |                      | create_share_from_sn |             |
| be87-    |          |            |            |                      | apshot_support :     |             |
| 3d7ca511 |          |            |            |                      | True                 |             |
| 60cc     |          |            |            |                      | revert_to_snapshot_s |             |
|          |          |            |            |                      | upport : True        |             |
|          |          |            |            |                      | mount_snapshot_suppo |             |
|          |          |            |            |                      | rt : True            |             |
| a5e531e6 | dhss_tru | public     | False      | driver_handles_share | snapshot_support :   | None        |
| -8a89-   | e        |            |            | _servers : True      | True                 |             |
| 4333-    |          |            |            |                      | create_share_from_sn |             |
| 9920-    |          |            |            |                      | apshot_support :     |             |
| 59cd420d |          |            |            |                      | True                 |             |
| 4f79     |          |            |            |                      | revert_to_snapshot_s |             |
|          |          |            |            |                      | upport : True        |             |
|          |          |            |            |                      | mount_snapshot_suppo |             |
|          |          |            |            |                      | rt : True            |             |
+----------+----------+------------+------------+----------------------+----------------------+-------------+

创建带有 dhss_false 共享类型、NFS 共享文件系统协议和 1 GB 大小的私有共享

$ openstack share create nfs 1 --name Share1 --description "My share" --share-type dhss_false
+---------------------------------------+--------------------------------------+
| Field                                 | Value                                |
+---------------------------------------+--------------------------------------+
| id                                    | c1de2cdc-2ccf-4e8d-afe9-b25c84bf3953 |
| size                                  | 1                                    |
| availability_zone                     | None                                 |
| created_at                            | 2025-04-05T22:05:29.343767           |
| status                                | creating                             |
| name                                  | Share1                               |
| description                           | My share                             |
| project_id                            | c0bc204890ad428796f364b677a8516b     |
| snapshot_id                           | None                                 |
| share_network_id                      | None                                 |
| share_proto                           | NFS                                  |
| metadata                              | {}                                   |
| share_type                            | d57dfcb5-3026-4018-be87-3d7ca51160cc |
| volume_type                           | dhss_false                           |
| is_public                             | False                                |
| snapshot_support                      | True                                 |
| task_state                            | None                                 |
| share_type_name                       | dhss_false                           |
| access_rules_status                   | active                               |
| replication_type                      | None                                 |
| has_replicas                          | False                                |
| user_id                               | c5d0c19aae6e4484a41e241f0d8b04fb     |
| create_share_from_snapshot_support    | True                                 |
| revert_to_snapshot_support            | True                                 |
| share_group_id                        | None                                 |
| source_share_group_snapshot_member_id | None                                 |
| mount_snapshot_support                | True                                 |
| progress                              | None                                 |
| is_soft_deleted                       | False                                |
| scheduled_to_be_deleted_at            | None                                 |
| source_backup_id                      | None                                 |
| share_server_id                       | None                                 |
| host                                  |                                      |
+---------------------------------------+--------------------------------------+

新的共享 Share1 应该具有 available 状态

$ openstack share show Share1
+---------------------------------------+------------------------------------------+
| Field                                 | Value                                    |
+---------------------------------------+------------------------------------------+
| id                                    | c1de2cdc-2ccf-4e8d-afe9-b25c84bf3953     |
| size                                  | 1                                        |
| availability_zone                     | manila-zone-1                            |
| created_at                            | 2025-04-05T22:05:29.343767               |
| status                                | available                                |
| name                                  | Share1                                   |
| description                           | My share                                 |
| project_id                            | c0bc204890ad428796f364b677a8516b         |
| snapshot_id                           | None                                     |
| share_network_id                      | None                                     |
| share_proto                           | NFS                                      |
| share_type                            | d57dfcb5-3026-4018-be87-3d7ca51160cc     |
| volume_type                           | dhss_false                               |
| is_public                             | False                                    |
| snapshot_support                      | True                                     |
| task_state                            | None                                     |
| share_type_name                       | dhss_false                               |
| access_rules_status                   | active                                   |
| replication_type                      | None                                     |
| has_replicas                          | False                                    |
| user_id                               | c5d0c19aae6e4484a41e241f0d8b04fb         |
| create_share_from_snapshot_support    | True                                     |
| revert_to_snapshot_support            | True                                     |
| share_group_id                        | None                                     |
| source_share_group_snapshot_member_id | None                                     |
| mount_snapshot_support                | True                                     |
| progress                              | 100%                                     |
| is_soft_deleted                       | False                                    |
| scheduled_to_be_deleted_at            | None                                     |
| source_backup_id                      | None                                     |
| share_server_id                       | None                                     |
| host                                  | manila@paris#shares                      |
| export_locations                      |                                          |
|                                       | id =                                     |
|                                       | 30d8ad5a-05b2-401a-9dbd-caf496f4ab12     |
|                                       | path = 11.0.0.11:/shares/share_c1de2     |
|                                       | cdc_2ccf_4e8d_afe9_b25c84bf3953_86ef2    |
|                                       | fc0_acbe_444c_888a_c52c05242dce          |
|                                       | preferred = False                        |
|                                       | metadata = {}                            |
|                                       | share_instance_id =                      |
|                                       | 86ef2fc0-acbe-444c-888a-c52c05242dce     |
|                                       | is_admin_only = True                     |
|                                       | id =                                     |
|                                       | acdd47f6-aef5-4d3b-86b2-db7d73d4bbfe     |
|                                       | path = 10.0.0.10:/shares/share_c1de2     |
|                                       | cdc_2ccf_4e8d_afe9_b25c84bf3953_86ef2    |
|                                       | fc0_acbe_444c_888a_c52c05242dce          |
|                                       | preferred = True                         |
|                                       | metadata = {}                            |
|                                       | share_instance_id =                      |
|                                       | 86ef2fc0-acbe-444c-888a-c52c05242dce     |
|                                       | is_admin_only = False                    |
|                                       | id =                                     |
|                                       | 224f223f-6dea-4e08-92c5-66de161cf43d     |
|                                       | path = 10.0.0.20:shares/share_c1de2      |
|                                       | cdc_2ccf_4e8d_afe9_b25c84bf3953_86ef2    |
|                                       | fc0_acbe_444c_888a_c52c05242dce          |
|                                       | preferred = False                        |
|                                       | metadata = {}                            |
|                                       | share_instance_id =                      |
|                                       | 86ef2fc0-acbe-444c-888a-c52c05242dce     |
|                                       | is_admin_only = False                    |
| properties                            |                                          |
+---------------------------------------+------------------------------------------+

在共享服务器模式下创建共享

要在共享服务器模式下创建文件共享,您需要

  1. 要创建共享,请使用 openstack share create 命令并指定所需的参数:共享的大小和共享的文件系统协议。支持 NFSCIFSGlusterFSHDFSCephFSMAPRFS 共享文件系统协议。

  2. 您应该指定带有 driver_handles_share_servers = True 额外规范的 共享类型

  3. 您应该指定 共享网络

  4. openstack share create 命令创建共享。此命令执行以下操作

    • manila-scheduler 服务将找到带有 driver_handles_share_servers = True 模式的后端,因为过滤了共享类型的额外规范。

    • 共享驱动程序将使用共享网络创建共享服务器。有关创建资源的详细信息,请参阅 文档 的特定共享驱动程序。

  5. 共享可用后,使用 manila show 命令获取共享导出位置。

在示例中,使用了默认共享类型和已存在的共享网络。

注意

管理员启动 manila 后,默认情况下没有默认共享类型。请参阅 共享类型 以创建默认共享类型。要创建共享网络,请使用 共享网络

检查存在的共享网络,运行

$ openstack share network list
+--------------------------------------+-------+
| ID                                   | Name  |
+--------------------------------------+-------+
| 1e0b9a80-2bce-4244-9da4-f8589c6bd56b | mynet |
+--------------------------------------+-------+

使用 my_share_net 网络、default 共享类型、NFS 共享文件系统协议和 1 GB 大小创建公共共享

$ openstack share create nfs 1 \
    --name "Share2" \
    --description "My second share" \
    --share-type default \
    --share-network my_net \
    --metadata aim=testing \
    --public
+---------------------------------------+--------------------------------------+
| Property                              | Value                                |
+---------------------------------------+--------------------------------------+
| id                                    | a37c3d1d-023f-4fcf-b640-3dbbb3e89193 |
| size                                  | 1                                    |
| availability_zone                     | None                                 |
| created_at                            | 2025-04-05T22:25:51.609837           |
| status                                | creating                             |
| name                                  | Share2                               |
| description                           | My second share                      |
| project_id                            | c0bc204890ad428796f364b677a8516b     |
| snapshot_id                           | None                                 |
| share_network_id                      | 1e0b9a80-2bce-4244-9da4-f8589c6bd56b |
| share_proto                           | NFS                                  |
| metadata                              | {'aim': 'testing'}                   |
| share_type                            | 807e5cd7-a0e7-4912-8f7d-352512ce51c3 |
| is_public                             | True                                 |
| snapshot_support                      | True                                 |
| task_state                            | None                                 |
| share_type_name                       | default                              |
| access_rules_status                   | active                               |
| replication_type                      | None                                 |
| has_replicas                          | False                                |
| user_id                               | c5d0c19aae6e4484a41e241f0d8b04fb     |
| create_share_from_snapshot_support    | True                                 |
| revert_to_snapshot_support            | True                                 |
| share_group_id                        | None                                 |
| source_share_group_snapshot_member_id | None                                 |
| mount_snapshot_support                | True                                 |
| progress                              | None                                 |
| is_soft_deleted                       | False                                |
| scheduled_to_be_deleted_at            | None                                 |
| source_backup_id                      | None                                 |
| share_server_id                       | None                                 |
| host                                  |                                      |
+---------------------------------------+--------------------------------------+

还可以从共享快照创建共享。有关详细信息,请参阅 共享快照

在共享列表中查看共享

$ openstack share list
+--------------------------------------+----------------+------+-------------+--------------+-----------+-----------------+----------------------+-------------------+
| ID                                   | Name           | Size | Share Proto | Status       | Is Public | Share Type Name | Host                 | Availability Zone |
+--------------------------------------+----------------+------+-------------+--------------+-----------+-----------------+----------------------+-------------------+
| a37c3d1d-023f-4fcf-b640-3dbbb3e89193 | Share2         | 1    | NFS         | available    | True      | default         | manila@lima#shares   | manila-zone-1     |
| c1de2cdc-2ccf-4e8d-afe9-b25c84bf3953 | Share1         | 1    | NFS         | available    | False     | dhss_false      | manila@paris#shares  | manila-zone-1     |
+--------------------------------------+----------------+------+-------------+--------------+-----------+-----------------+----------------------+-------------------+

检查共享状态并查看共享导出位置。创建后,共享应具有 available 状态

$ openstack share show Share2
+---------------------------------------+------------------------------------------+
| Field                                 | Value                                    |
+---------------------------------------+------------------------------------------+
| id                                    | a37c3d1d-023f-4fcf-b640-3dbbb3e89193     |
| size                                  | 1                                        |
| availability_zone                     | manila-zone-1                            |
| created_at                            | 2025-04-05T22:25:51.609837               |
| status                                | available                                |
| name                                  | Share2                                   |
| description                           | My second share                          |
| project_id                            | c0bc204890ad428796f364b677a8516b         |
| snapshot_id                           | None                                     |
| share_network_id                      | 1e0b9a80-2bce-4244-9da4-f8589c6bd56b     |
| share_proto                           | NFS                                      |
| share_type                            | 807e5cd7-a0e7-4912-8f7d-352512ce51c3     |
| volume_type                           | default                                  |
| is_public                             | True                                     |
| snapshot_support                      | True                                     |
| task_state                            | None                                     |
| share_type_name                       | default                                  |
| access_rules_status                   | active                                   |
| replication_type                      | None                                     |
| has_replicas                          | False                                    |
| user_id                               | c5d0c19aae6e4484a41e241f0d8b04fb         |
| create_share_from_snapshot_support    | True                                     |
| revert_to_snapshot_support            | True                                     |
| share_group_id                        | None                                     |
| source_share_group_snapshot_member_id | None                                     |
| mount_snapshot_support                | True                                     |
| progress                              | None                                     |
| is_soft_deleted                       | False                                    |
| scheduled_to_be_deleted_at            | None                                     |
| source_backup_id                      | None                                     |
| share_server_id                       | None                                     |
| host                                  | manila@lima#shares                       |
| export_locations                      |                                          |
|                                       | id =                                     |
|                                       | aeac5f3e-60e3-461c-8ca8-6696e0f59f39     |
|                                       | path = 12.0.0.12:/shares/share_cdc_2c    |
|                                       | cf_4e8d_afe9_b25c84bf3953_86ef2          |
|                                       | 789-f1f5-4171-9e43-3afabddf8b5f          |
|                                       | preferred = False                        |
|                                       | metadata = {}                            |
|                                       | share_instance_id =                      |
|                                       | 86ef2fc0-acbe-444c-888a-c52c05242dce     |
|                                       | is_admin_only = True                     |
|                                       | id =                                     |
|                                       | 965aa536-9ba4-4f8b-9ddd-a6a916968597     |
|                                       | path = 10.0.0.10:/shares/share_cdc_2c    |
|                                       | cf_4e8d_afe9_b25c84bf3953_86ef2          |
|                                       | 789-f1f5-4171-9e43-3afabddf8b5f          |
|                                       | preferred = True                         |
|                                       | metadata = {}                            |
|                                       | share_instance_id =                      |
|                                       | 86ef2fc0-acbe-444c-888a-c52c05242dce     |
|                                       | is_admin_only = False                    |
|                                       | id =                                     |
|                                       | 224f223f-6dea-4e08-92c5-66de161cf43d     |
|                                       | path = 10.0.0.20:/shares/share_cdc_2c    |
|                                       | cf_4e8d_afe9_b25c84bf3953_86ef2          |
|                                       | 789-f1f5-4171-9e43-3afabddf8b5f          |
|                                       | preferred = False                        |
|                                       | metadata = {}                            |
|                                       | share_instance_id =                      |
|                                       | 86ef2fc0-acbe-444c-888a-c52c05242dce     |
| properties                            | aim='testing'                            |
+---------------------------------------+------------------------------------------+

is_public 定义了共享的可见性级别:其他项目是否可以看到共享。默认情况下,共享是私有的。

更新共享

如果您需要,请更新共享的名称、描述或所有项目的可见性级别

$ openstack share set Share2 --description "My second share. Updated" --public False

$ openstack share show Share2
+---------------------------------------+--------------------------------------+
| Field                                 | Value                                |
+---------------------------------------+--------------------------------------+
| id                                    | a37c3d1d-023f-4fcf-b640-3dbbb3e89193 |
| size                                  | 1                                    |
| availability_zone                     | manila-zone-1                        |
| created_at                            | 2025-04-05T22:25:51.609837           |
| status                                | available                            |
| name                                  | Share2                               |
| description                           | My second share. Updated             |
| project_id                            | c0bc204890ad428796f364b677a8516b     |
| snapshot_id                           | None                                 |
| share_network_id                      | 1e0b9a80-2bce-4244-9da4-f8589c6bd56b |
| share_proto                           | NFS                                  |
| share_type                            | 807e5cd7-a0e7-4912-8f7d-352512ce51c3 |
| volume_type                           | default                              |
| is_public                             | False                                |
| snapshot_support                      | True                                 |
| task_state                            | None                                 |
| share_type_name                       | default                              |
| access_rules_status                   | active                               |
| replication_type                      | None                                 |
| has_replicas                          | False                                |
| user_id                               | c5d0c19aae6e4484a41e241f0d8b04fb     |
| create_share_from_snapshot_support    | True                                 |
| revert_to_snapshot_support            | True                                 |
| share_group_id                        | None                                 |
| source_share_group_snapshot_member_id | None                                 |
| mount_snapshot_support                | True                                 |
| progress                              | None                                 |
| is_soft_deleted                       | False                                |
| scheduled_to_be_deleted_at            | None                                 |
| source_backup_id                      | None                                 |
| share_server_id                       | None                                 |
| host                                  | manila@lima#shares                   |
| export_locations                      |                                      |
| properties                            | aim='testing'                        |
+---------------------------------------+--------------------------------------+

共享可以具有以下状态值之一

状态

描述

creating

共享正在创建。

deleting

正在删除共享。

error

在共享创建过程中发生错误。

error_deleting

在共享删除过程中发生错误。

available

共享已准备好使用。

manage_starting

共享管理已启动。

manage_error

共享管理失败。

unmanage_starting

共享取消管理已启动。

unmanage_error

无法取消管理共享。

unmanaged

共享已取消管理。

extending

扩展或增加共享大小的请求已成功发出。

extending_error

扩展共享失败。

shrinking_possible_data_loss_error

由于可能的数据丢失,缩小共享失败。

shrinking

共享正在缩小。

shrinking_error

缩小共享时更新配额失败。

migrating

共享迁移正在进行中。

共享元数据

如果您想为共享设置元数据键值对,请运行

$  openstack share set Share2 --property project=my_abc

获取共享的所有元数据键值对

$ openstack share show -c properties Share2
+------------+------------------------------------------------------+
| Field      | Value                                                |
+------------+------------------------------------------------------+
| properties | aim='testing', deadline='01/20/16', project='my_abc' |
+------------+------------------------------------------------------+

您可以更新元数据

$ openstack share set Share2 --proper deadline='01/30/16'
$ openstack share show -c properties Share2
+------------+------------------------------------------------------+
| Field      | Value                                                |
+------------+------------------------------------------------------+
| properties | aim='testing', deadline='01/30/16', project='my_abc' |
+------------+------------------------------------------------------+

您还可以使用 openstack share unset <share_name> –property <key_to_unset> 取消设置元数据。

注意

如果您希望防止权限较低的用户操作某些元数据键值,则可以通过在 附加配置选项页面 中列出的仅管理员元数据配置选项提供此类键的列表。

如果您希望传递某些元数据键值以供共享驱动程序使用,则可以通过在 附加配置选项页面 中列出的驱动程序可更新元数据配置选项提供此类键的列表。

重置共享状态

作为管理员,您可以重置共享的状态。

使用 openstack share set <share> –status 命令重置共享状态,其中 state 指示要分配给共享的状态。选项包括 availableerrorcreatingdeletingerror_deleting 状态。

$ openstack share set Share2 --status deleting

$ openstack share show Share2
+---------------------------------------+--------------------------------------+
| Field                                 | Value                                |
+---------------------------------------+--------------------------------------+
| id                                    | a37c3d1d-023f-4fcf-b640-3dbbb3e89193 |
| size                                  | 1                                    |
| availability_zone                     | manila-zone-1                        |
| created_at                            | 2025-04-05T22:25:51.609837           |
| status                                | deleting                             |
| name                                  | Share2                               |
| description                           | My second share. Updated             |
| project_id                            | c0bc204890ad428796f364b677a8516b     |
| snapshot_id                           | None                                 |
| share_network_id                      | 1e0b9a80-2bce-4244-9da4-f8589c6bd56b |
| share_proto                           | NFS                                  |
| share_type                            | 807e5cd7-a0e7-4912-8f7d-352512ce51c3 |
| volume_type                           | default                              |
| is_public                             | False                                |
| snapshot_support                      | True                                 |
| task_state                            | None                                 |
| share_type_name                       | default                              |
| access_rules_status                   | active                               |
| replication_type                      | None                                 |
| has_replicas                          | False                                |
| user_id                               | c5d0c19aae6e4484a41e241f0d8b04fb     |
| create_share_from_snapshot_support    | True                                 |
| revert_to_snapshot_support            | True                                 |
| share_group_id                        | None                                 |
| source_share_group_snapshot_member_id | None                                 |
| mount_snapshot_support                | True                                 |
| progress                              | None                                 |
| is_soft_deleted                       | False                                |
| scheduled_to_be_deleted_at            | None                                 |
| source_backup_id                      | None                                 |
| share_server_id                       | None                                 |
| host                                  | manila@lima#shares                   |
| export_locations                      |                                      |
| properties                            | deadline='01/30/16'                  |
+---------------------------------------+--------------------------------------+

删除和强制删除共享

您还可以强制删除共享。无法在过渡状态下删除共享。过渡状态是共享的 creatingdeletingmanagingunmanagingmigratingextendingshrinking 状态。强制删除会删除任何状态下的对象。使用 policy.yaml 文件向其他角色授予此操作的权限。

提示

policy.yaml 配置文件可以从不同的位置使用。默认情况下,/etc/manila/policy.yaml 是预期的路径之一。

使用 openstack share delete <share_name_or_ID> 命令删除指定的共享

$ openstack share delete %share_name_or_id%
$ openstack share delete %share_name_or_id% --share-group %share-group-id%
$ openstack share delete Share2

打印所有项目的共享列表

$ openstack share delete --force Share2

$ openstack share list --all
+--------------------------------------+----------------+------+-------------+--------------+-----------+-----------------+------------------------+-------------------+
| ID                                   | Name           | Size | Share Proto | Status       | Is Public | Share Type Name | Host                   | Availability Zone |
+--------------------------------------+----------------+------+-------------+--------------+-----------+-----------------+------------------------+-------------------+
| c1de2cdc-2ccf-4e8d-afe9-b25c84bf3953 | Share1         | 1    | NFS         | available    | False     | default         | manila@paris#shares    | manila-zone-1     |
+--------------------------------------+----------------+------+-------------+--------------+-----------+-----------------+------------------------+-------------------+

管理共享访问

共享文件系统服务允许授予或拒绝对指定共享的访问权限,并列出指定共享的权限。

要授予或拒绝对共享的访问权限,请指定以下支持的共享访问级别之一

  • rw。读写 (RW) 访问。这是默认值。

  • ro。只读 (RO) 访问。

您还必须指定以下受支持的身份验证方法

  • ip。通过 IP 地址验证实例。有效的格式是 XX.XX.XX.XXXX.XX.XX.XX/XX。例如 0.0.0.0/0

  • user。通过指定的用户名或组名进行身份验证。有效值是字母数字字符串,可以包含一些特殊字符,长度为 4 到 32 个字符。

  • cert。通过 TLS 证书进行身份验证。将 TLS 身份指定为 IDENTKEY。有效值是证书的通用名 (CN) 中最多 64 个字符的任何字符串。字符串的含义取决于其解释。

  • cephx。Ceph 身份验证系统。指定需要由 Ceph 后端进行身份验证和授权的 Ceph 身份验证 ID。有效值必须非空,由 ASCII 可打印字符组成,并且不包含句点。

尝试使用导出路径 10.0.0.10:/shares/share_cdc_2ccf_4e8d_afe9_b25c84bf3953_86ef2789-f1f5-4171-9e43-3afabddf8b5f 在 IP 地址为 10.0.0.13 的节点上挂载 NFS 共享

$ sudo mount -v -t nfs 10.0.0.10:/shares/share_cdc_2ccf_4e8d_afe9_b25c84bf3953_86ef2789-f1f5-4171-9e43-3afabddf8b5f /mnt/
mount.nfs: timeout set for Tue Oct  6 10:37:23 2015
mount.nfs: trying text-based options 'vers=4,addr=10.0.0.10,clientaddr=10.0.0.13'
mount.nfs: mount(2): Permission denied
mount.nfs: access denied by server while mounting 10.0.0.10:/shares/share_cdc_2ccf_4e8d_afe9_b25c84bf3953_86ef2789-f1f5-4171-9e43-3afabddf8b5f

出现错误消息“权限被拒绝”,因此您不允许在没有访问规则的情况下挂载共享。允许使用 ip 访问类型和 10.0.2.13 IP 地址访问共享

$ openstack share access create Share1 ip 10.0.2.13 --access-level rw
+--------------+--------------------------------------+
| Field        | Value                                |
+--------------+--------------------------------------+
| id           | 56d344c5-95cb-477b-bf33-39f6e9b43edf |
| share_id     | c1de2cdc-2ccf-4e8d-afe9-b25c84bf3953 |
| access_level | rw                                   |
| access_to    | 10.0.2.13                            |
| access_type  | ip                                   |
| state        | queued_to_apply                      |
| access_key   | None                                 |
| created_at   | 2025-04-05T23:44:31.165395           |
| updated_at   | None                                 |
| properties   |                                      |
+--------------+--------------------------------------+

再次尝试挂载共享。这次已成功挂载

$ sudo mount -v -t nfs 10.0.0.10:/shares/share_cdc_2ccf_4e8d_afe9_b25c84bf3953_86ef2789-f1f5-4171-9e43-3afabddf8b5f /mnt/

注意

不同的共享功能由不同的共享驱动程序支持。例如,使用块存储服务作为后端的通用驱动程序不支持 usercert 身份验证方法。有关不同驱动程序支持的功能的详细信息,请参阅 Manila 共享功能支持映射

提示

从 2023.2 (Bobcat) 版本开始,如果您希望限制敏感字段(access_toaccess_key)的可见性,或避免其他用户删除访问规则,您可以在 Manila OpenStack 命令中创建访问规则时指定 --lock-visibility--lock-deletion。 还可以提供原因(--lock-reason)。 默认 RBAC 允许放置锁定的用户、系统管理员和服务查看敏感字段或操作这些访问规则。 如果访问规则的删除被锁定,Manila 也会在共享上放置额外的锁,以确保它不会被删除并导致断开连接。

要验证共享的访问规则 (ACL) 是否配置正确,请列出共享的权限

$ openstack share access list Share1
+--------------------------------------+-------------+-----------+--------------+--------+------------+----------------------------+-------------------------+
| ID                                   | Access Type | Access To | Access Level | State  | Access Key | Created At                 | Updated At              |
+--------------------------------------+-------------+-----------+--------------+--------+------------+----------------------------+-------------------------+
| 56d344c5-95cb-477b-bf33-39f6e9b43edf | ip          | 10.0.0.13 | rw           | active | None       | 2025-04-05T23:44:31.165395 | 2025-04-05T23:45:50.780 |
+--------------------------------------+-------------+-----------+--------------+--------+------------+----------------------------+-------------------------+

拒绝访问共享并检查已删除的访问规则是否已从访问规则列表中删除

$ openstack share access delete Share1 56d344c5-95cb-477b-bf33-39f6e9b43edf

注意

从 2023.2 (Bobcat) 版本开始,可以防止删除访问规则。 如果删除被锁定,则必须在请求中撤销访问权限时使用 Manila 的 OpenStack Client 中的 --unrestrict 参数。