• Scalable File Service

sfs
  1. Help Center
  2. Scalable File Service
  3. API Reference
  4. API Invoking Method
  5. Example

Example

This section uses describes how to use SFS API by invoking an API to create a shared file system.

NOTE:

The token obtained from IAM is valid for only 24 hours. If you want to use one token for authentication, you can cache it to avoid frequently calling.

To use token authentication, you need to obtain a token and add X-Auth-Token to the request headers. The following APIs are involved in creating a shared file system.

Procedure

  1. Obtain the token. For details, see API Usage Guidelines.
  2. Add X-Auth-Token to the request header.
  3. Specify the following parameters in the request body:

    {
    	"share": {
    		"description": "custom share",
    		"share_type": null,
    		"share_proto": "nfs",
    		"share_network_id": null,
    		"share_group_id": null,
    		"name": "share_London",
    		"snapshot_id": null,
    		"is_public": true,
    		"size": 1,
    		"metadata": {
    			"project": "my_app",
    			"aim": "doc"
    		}
    	}
    }

  4. Send the request POST https://Endpoint of SFS/v2/{project_id}/shares.
  5. If the request is responded, share is returned.

    If the request fails, an error code and error information are returned. For details about the error codes, see the abnormal return values of the corresponding API.

    Query details about a shared file system based on the UUID of the shared file system. For details, see Querying Details About a Shared File System.

    If the returned value of status is Available, the shared file system is successfully created. For details about the return values of request exceptions, see the abnormal return values of the corresponding API.

    You can query, delete or perform other operations on a shared file system based on the value of id, that is, the ID of the shared file system.

Example

If the token has been obtained, you can run the following curl command to create a shared file system:

curl -k -i -X POST https://127.0.0.1:8786/v2/xxxbxbex5cfx41f0a08ay915fd79240d/shares -H"X-Openstack-Manila-Api-Version: 2.15" -H"X-Auth-Token:token_value" -H "Content-Type: application/json"-H "Accept: application/json" -H "User-Agent:python-manilaclient" -d '{"share": {"description": "custom share", "availability_zone": "az1.dc1", "share_network_id": null, "snapshot_id": null, "is_public": false, "size": 1, "name": "metro_replica", "share_type": "share_replication_type", "share_proto": "NFS", "share_group_id": null, "metadata": {}}}'