• Scalable File Service

sfs
  1. Help Center
  2. Scalable File Service
  3. API Reference(cli)
  4. API Usage

API Usage

This chapter describes how to use manila commands provided by python-manilaclient, and how to invoke the APIs provided by SFS using manila commands.

Prerequisites

  • python-manilaclient has been installed in the execution environment. For details, see Software Compatibility.
  • You can access the APIs provided by SFS in the execution environment.

Configuring Environment Variables

To run manila commands correctly, you need to configure environment variables, including an IAM authentication account and API command configuration information.

  1. Log in to the execution environment.
  2. Import environment variables.

    Run the following command on a Linux host to import the environment variables required for invoking the OpenStack Manila APIs provided by SFS. Note that you should replace <os-user-domain-name> and <os-username> with the actual values before running the command. For detailed description of the parameters, see Table 1.
    export OS_USER_DOMAIN_NAME=<os-user-domain-name>
    export OS_USERNAME=<os-username>
    export OS_PASSWORD=<os-password>
    export OS_PROJECT_NAME=<os-project_name>
    export OS_AUTH_URL=<os-auth-url>
    export OS_ENDPOINT_TYPE=<os-endpoint-type>
    export PYTHONWARNINGS=ignore
    export MANILACLIENT_INSECURE=True
    Table 1 Parameter description

    Parameter

    Mandatory

    Description

    Example Value

    OS_USER_DOMAIN_NAME

    Yes

    Domain name of an IAM account

    -

    OS_USERNAME

    Yes

    User name of an IAM account

    -

    OS_PASSWORD

    Yes

    Password of an IAM account

    -

    OS_PROJECT_NAME

    Yes

    Project name. Set this parameter based on the project to which the account belongs, for example, eu-de or singapore.

    eu-de

    OS_AUTH_URL

    Yes

    URL for IAM authentication, which is used to authenticate the IAM account. Set this parameter based on the actual authentication URL.

    https://iam.eu-de.otc.t-systems.com/v3

    OS_ENDPOINT_TYPE

    Yes

    Endpoint type. The value is fixed to publicURL.

    publicURL

    PYTHONWARNINGS

    No

    Whether to ignore the warning. If the value is ignore, the python warning information is ignored.

    ignore

    MANILACLIENT_INSECURE

    Yes

    Whether to enable the insecure mode to communicate with the server. The default value is False. If the value is False, the security mode is enabled. If the value is True, the insecure mode is enabled and certificate authentication is ignored. Currently, SFS supports only the insecure mode and the value is fixed to True.

    NOTE:

    Currently, IAM does not open the interface for downloading and obtaining the CA certificate. Python 2.7.9 and later versions do not allow the client to use a self-signed certificate. Therefore, the current SFS provides only the insecure mode for communicating with IAM, ignoring certificate authentication.

    NOTICE:

    When the insecure mode is used to communicate with the IAM, ensure that the IAM authentication URL is correct.

    True

    Example command:

    export OS_USER_DOMAIN_NAME=sample-iam-dommain-name
    export OS_USERNAME=sample-iam-username
    export OS_PASSWORD=sample-iam-user-password
    export OS_PROJECT_NAME=eu-de
    export OS_AUTH_URL=https://iam.eu-de.otc.t-systems.com/v3
    export OS_ENDPOINT_TYPE=publicURL
    export PYTHONWARNINGS=ignore
    export MANILACLIENT_INSECURE=True
    NOTE:

    To save the environment variable information in the local environment, you can write the preceding command to a file, and then run the source file name command to import the environment variable. For example, to save the environment variables to the manilarc file, perform the following operations:

    1. Run the vi manilarc command to create and edit the manilarc file. Press i to enter the editing mode and write the following command:
      export OS_USER_DOMAIN_NAME=sample-iam-dommain-name
      export OS_USERNAME=sample-iam-username
      export OS_PASSWORD=sample-iam-user-password
      export OS_PROJECT_NAME=eu-de
      export OS_AUTH_URL=https://iam.eu-de.otc.t-systems.com/v3
      export OS_ENDPOINT_TYPE=publicURL
      export PYTHONWARNINGS=ignore
      export MANILACLIENT_INSECURE=True
    2. Run the source manilarc command to import environment variables.

  3. Run the manila list command to check whether the environment variables are successfully imported.

    root@n-version-client:~/ca# manila list
    +--------------------------------------+---------+------+-------------+-----------+-----------+-----------------+-------------------------------------------------------------------------------+-------------------+
    | ID                                   | Name    | Size | Share Proto | Status    | Is Public | Share Type Name | Host                                                                          | Availability Zone |
    +--------------------------------------+---------+------+-------------+-----------+-----------+-----------------+-------------------------------------------------------------------------------+-------------------+
    | 416112b6-e5c9-4a46-8dd1-80749fc09336 | sample1 | 1    | NFS         | available | False     | default         | DJ1@28281404-884d-4eda-8240-c54903a178fe#28281404-884d-4eda-8240-c54903a178fe | eu-de-01          |
    | 52820f82-1419-4f4c-a032-e97e310f5505 | sample  | 10   | NFS         | available | False     | default         | DJ1@28281404-884d-4eda-8240-c54903a178fe#28281404-884d-4eda-8240-c54903a178fe | eu-de-01          |
    +--------------------------------------+---------+------+-------------+-----------+-----------+-----------------+-------------------------------------------------------------------------------+-------------------+
    NOTE:

    If the command fails to be executed, check whether the environment variables configured in Step 2 are correct.

Invoking APIs

After environment variables are successfully configured, you can run manila commands to invoke the APIs provided by SFS. The command format is as follows:

manila <command> [arguments...]

You can run the manila help command to view all manila commands, and the manila help <Command> command to obtain help details of a specific command. The following uses the manila show command as an example.

root@n-version-client:~/ca# manila help show
usage: manila show <share>

Show details about a NAS share.

Positional arguments:
  <share>  Name or ID of the NAS share.

Return Value

When running the manila <command> command, if the correct command output is returned, or no exception appears during running the command, the execution of the command is normal. Take manila show as an example:

root@n-version-client:~/ca# manila show 416112b6-e5c9-4a46-8dd1-80749fc09336
+-----------------------------+-------------------------------------------------------------------------------+
| Property                    | Value                                                                         |
+-----------------------------+-------------------------------------------------------------------------------+
| status                      | available                                                                     |
| share_type_name             | default                                                                       |
| description                 | None                                                                          |
| availability_zone           | eu-de-01                                                                      |
| share_network_id            | None                                                                          |
| export_locations            |                                                                               |
|                             | path = sfs-nas1.eu-de.otc.t-systems.com:/share-cff11cb8                       |
|                             | id = 6014f802-7b74-4fb2-8436-a58c94f86e84                                     |
|                             | preferred = False                                                             |
| host                        | DJ1@28281404-884d-4eda-8240-c54903a178fe#28281404-884d-4eda-8240-c54903a178fe |
| access_rules_status         | active                                                                        |
| snapshot_id                 | None                                                                          |
| is_public                   | False                                                                         |
| task_state                  | None                                                                          |
| snapshot_support            | True                                                                          |
| id                          | 416112b6-e5c9-4a46-8dd1-80749fc09336                                          |
| size                        | 1                                                                             |
| name                        | sample1                                                                       |
| share_type                  | 500fcfac-357b-4f0f-beeb-240d09da4dab                                          |
| has_replicas                | False                                                                         |
| replication_type            | None                                                                          |
| created_at                  | 2017-10-24T13:27:55.936861                                                    |
| share_proto                 | NFS                                                                           |
| consistency_group_id        | None                                                                          |
| source_cgsnapshot_member_id | None                                                                          |
| project_id                  | 703fdd5a62c84cbfb1385c212881f695                                              |
| metadata                    | {u'share_used': u'0'}                                                         |
+-----------------------------+-------------------------------------------------------------------------------+