• Scalable File Service

sfs
  1. Help Center
  2. Scalable File Service
  3. API Reference
  4. SFS APIs
  5. File Sharing
  6. Creating a Shared File System

Creating a Shared File System

Function

This interface is used to create a shared file system.

NOTE:

This interface is an asynchronous interface. If the return value is 200, the request sent by the interface is received. Later, you can query the status and path of the shared file system by referring to Querying Details About a Shared File System to identify whether the creation is complete and successful.

After a share is created successfully, the share can be used only after you add share access rules by referring to Adding Share Access Rules.

URI

  • POST /v2/{project_id}/shares
  • Parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    string

    Specifies the project ID of the operator.

Request

  • Parameter description

    Parameter

    Mandatory

    Type

    Description

    share

    Yes

    object

    Specifies the share object.

  • Description of field share

    Parameter

    Mandatory

    Type

    Description

    share_proto

    Yes

    string

    Specifies the protocol for sharing file systems. The value can be NFS.

    size

    Yes

    integer

    Specifies the size (GB) of the shared file system.

    name

    No

    string

    Specifies the name of the shared file system. The value contains 0 to 255 characters.

    description

    No

    string

    Describes the shared file system. The value contains 0 to 255 characters.

    snapshot_id

    No

    string

    Specifies the UUID (0 to 36 characters) of the source snapshot that is used to create the shared file system. This parameter is reserved, because snapshots are not supported currently.

    is_public

    No

    boolean

    (Supported since API v2.8). Specifies whether a file system can be publicly seen. If it is set to true, the file system can be seen publicly. If it is set to false, the file system can be seen privately. The default value is false.

    share_type

    No

    string

    Specifies the share type. This value determines the storage service type for the shared file system, such as high-performance storage (composed of SSDs) or large-capacity storage (composed of SATA disks). Currently, only one service type is supported and the parameter will be automatically set to the supported one. Do not manually set it, because application for the file service will fail if an unsupported type is entered.

    share_group_id

    No

    string

    (This field is supported since API v2.31) Specifies the UUID of the consistency group to which the share is to be created. SFS does not support a consistency group. Therefore, this field is invalid, and this parameter is not needed.

    availability_zone

    No

    string

    Specifies the availability zone name. If this parameter is left blank, the default availability zone will be used. If the default availability zone contains no storage resources, the creation of the shared file system fails. The value contains 0 to 255 characters.

    metadata

    No

    object

    Specifies the metadata information used to create the share. The value consists of one or more key and value pairs organized as a dictionary of strings.

    CAUTION:

    For security concerns, the API for modifying the metadata field is not enabled. Therefore, ensure that the parameters and values are correct when creating a share with data encryption using the metadata field.

    WARNING:

    Unless otherwise specified (for example, #sfs_crypt_key_id), the keys that comply with the following rules in the metadata field are for internal use of the system. Do not customize the settings to avoid internal system errors caused by conflicts with system predefined keys.

    • Key share_used
    • Keys that start with #sfs

    share_network_id

    No

    string

    Specifies the UUID (0 to 36 characters) of the share network to which the share service belongs or will be created. This parameter is reserved, because share network management is not supported currently.

  • Description of field metadata (when creating a share with the encryption function)
    When creating a share with the encryption function, obtain the key ID, domain ID, and key alias of the encryption key using the HTTPS request by referring to section Querying the List of CMKs in the Key Management Service API Reference. Then, in the metadata field, set the key-value pairs according to the following table. Ensure that the key-value pairs in the metadata field are correct.

    key

    Value Type

    Mandatory

    Description

    #sfs_crypt_key_id

    string

    Yes

    Specifies the encryption key ID.

    If this parameter, #sfs_crypt_domain_id, and #sfs_crypt_alias exist at the same time, the data encryption function is enabled.

    #sfs_crypt_domain_id

    string

    Yes

    Specifies the tenant domain ID.

    If this parameter, #sfs_crypt_key_id, and #sfs_crypt_alias exist at the same time, the data encryption function is enabled.

    #sfs_crypt_alias

    string

    Yes

    Specifies the encryption key alias.

    If this parameter, #sfs_crypt_key_id, and #sfs_crypt_domain_id exist at the same time, the data encryption function is enabled.

    NOTE:
    • You are advised to use the default primary key sfs/default to create an encrypted share. For details, see section "File System Encryption" and "Managing Encrypted File Systems" in the Scalable File Service User Guide.
  • Example request
    {
       "share": {
           "share_type": null,
           "name": "test",
           "snapshot_id": null,
           "description": "test description",
           "metadata": {
               "key1": "value1",
               "key2": "value2"
           },
           "share_proto": "NFS",
           "share_network_id": null,
           "size": 1,
           "is_public": false
       }
    }
  • Request example (creating a share with data encryption)
    {
       "share": {
           "share_type": null,
           "name": "test",
           "snapshot_id": null,
           "description": "test description",
           "metadata": {
               "#sfs_crypt_key_id": "9130c90d-73b8-4203-b790-d49f98d503df",
               "#sfs_crypt_domain_id": "3b2d9670690444c582942801ed7d457b",
               "#sfs_crypt_alias": "sfs/default"
           },
           "share_proto": "NFS",
           "share_network_id": null,
           "size": 1,
           "is_public": false
       }
    }

Response

  • Parameter description

    Parameter

    Type

    Description

    share

    object

    Specifies the share object.

  • Description of field share

    Parameter

    Type

    Description

    id

    string

    Specifies the UUID of the shared file system.

    status

    string

    Specifies the status of the shared file system.

    links

    array

    Specifies the share links.

    project_id

    string

    Specifies the UUID of the project to which the shared file system belongs.

    share_proto

    string

    Specifies the protocol for sharing file systems.

    size

    integer

    Specifies the size (GB) of the shared file system. The requested capacity of the shared file system cannot be larger than the allowed quota. To view the allowed quota, use the interface for querying a quota.

    name

    string

    Specifies the name of the shared file system.

    description

    string

    Describes the shared file system.

    share_type

    string

    Specifies the storage service type assigned for the shared file system, such as high-performance storage (composed of SSDs) and large-capacity storage (composed of SATA disks).

    is_public

    boolean

    Specifies the visibility level of the shared file system. To make the shared file system visible to all tenants, set it to true. To make the shared file system only visible to the owning tenant, set it to false.

    volume_type

    string

    Specifies the volume type.

    snapshot_id

    string

    Specifies the UUID (0 to 36 characters) of the source snapshot that is used to create the shared file system. This parameter is reserved, because snapshots are not supported currently.

    share_group_id

    string

    (This field is supported since API v2.31) Specifies the UUID of the consistency group to which the share is to be created. SFS does not support a consistency group. Therefore, this field is invalid, and this parameter is not needed.

    metadata

    object

    Sets one or more metadata key and value pairs as a dictionary of strings. It is the used capacity of the shared file system. The key is share_used and the value is a decimal number in Bytes. This key value is automatically refreshed every 30 minutes.

    share_network_id

    string

    Specifies the UUID of the share network. This parameter is reserved, because share network management is not supported currently.

    availability_zone

    string

    Specifies the availability zone.

    export_location

    string

    Specifies the address for accessing the shared file system. This field is not displayed since API v2.8.

    export_locations

    array

    Lists the paths for accessing the shared file system. This field is not displayed since API v2.8.

    host

    string

    Specifies the name of the host. This field is visible only to the administrator.

    created_at

    string

    Specifies the date and time stamp when the shared file system was created.

  • Example response
    {
        "share": {
            "status": "creating",
            "project_id": "16e1ab15c35a457e9c2b2aa189f544e1",
            "name": "share_London",
            "share_type": "25747776-08e5-494f-ab40-a64b9d20d8f7",
            "availability_zone": az1.dc1,
            "created_at": "2015-09-18T10:25:24.533287",
            "export_location": null,
            "links": [
                {
                    "href": "http://172.18.198.54:8786/v1/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264",
                    "rel": "self"
                },
                {
                    "href": "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264",
                    "rel": "bookmark"
                }
            ],
            "share_network_id": null,
            "export_locations": [],
            "share_proto": "NFS",
            "host": null,
            "volume_type": "default",
            "snapshot_id": null,
            "is_public": true,
            "metadata": {
                "project": "my_app",
                "aim": "doc"
            },
            "id": "011d21e2-fbc3-4e4a-9993-9ea223f73264",
            "size": 1,
            "description": "My custom share London"
        }
    }
    NOTE:

    When the client receives the system response, the shared file system is still being created. For this reason, the share path cannot be queried immediately. You can use the interface to query the share path after the creation is complete.

Status Code

  • Normal

    200

  • Abnormal

    Status Code

    Description

    400 Bad Request

    The server failed to process the request.

    401 Unauthorized

    You must enter a username and the password to access the requested page.

    403 Forbidden

    You are forbidden to access the requested page.

    404 Not Found

    The requested page was not found.

    405 Method Not Allowed

    You are not allowed to use the method specified in the request.

    406 Not Acceptable

    The response generated by the server could not be accepted by the client.

    407 Proxy Authentication Required

    You must use the proxy server for authentication. Then the request can be processed.

    408 Request Timeout

    The request timed out.

    409 Conflict

    The request could not be processed due to a conflict.

    500 Internal Server Error

    Failed to complete the request because of an internal service error.

    501 Not Implemented

    Failed to complete the request because the server does not support the requested function.

    502 Bad Gateway

    Failed to complete the request because the request is invalid.

    503 Service Unavailable

    Failed to complete the request because the service is unavailable.

    504 Gateway Timeout

    A gateway timeout error occurred.