How do I use FSx for ONTAP REST APIs?

3 minute read
0

I want to use the NetApp ONTAP REST API to manage my Amazon FSx for NetApp ONTAP resources. How do I do this?

Resolution

Prerequisites

The API requestor must be able to make HTTPS connections to the FSx for ONTAP file system and to the storage virtual machine (SVM) endpoints. For more information, see Using the NetApp ONTAP REST API.

Run Hello World on the FSx for ONTAP file system with curl

At the command line interface of a Linux instance on your Amazon Virtual Private Cloud (Amazon VPC) running the FSx for ONTAP file system, do the following:

1.    Enter your fsxadmin password and the endpoint DNS name. In the following example command, replace Password and fs-XXXXXXXX.fsx.region.amazonaws.com with the correct values for your use case:

$ CRED=fsxadmin:Password
$ ONTAP=management.fs-XXXXXXXX.fsx.region.amazonaws.com

2.    Run the following command to retrieve the ONTAP software version:

$ curl -X GET -u ${CRED} -k "https://${ONTAP}/api/cluster?fields=version"
{
  "version": {
    "full": "NetApp Release 9.10.1RC1P1: Sat Nov 27 18:08:32 UTC 2021",
    "generation": 9,
    "major": 10,
    "minor": 1
  },
  "_links": {
    "self": {
      "href": "/api/cluster"
    }
  }
}

Example REST API: Get volumes

The following is an example of the GET command used to retrieve volumes:

$ curl -X GET -u ${CRED} -k "https://${ONTAP}/api/storage/volumes"
{
  "records": [
    {
      "uuid": "504c8162-a435-11ec-bb13-130f21c56a08",
      "name": "svm1_root",
      "_links": {
        "self": {
          "href": "/api/storage/volumes/504c8162-a435-11ec-bb13-130f21c56a08"
        }
      }
    },
    {
      "uuid": "956f5ce9-a435-11ec-bb13-130f21c56a08",
      "name": "vol1",
      "_links": {
        "self": {
          "href": "/api/storage/volumes/956f5ce9-a435-11ec-bb13-130f21c56a08"
        }
      }
    }
  ],
  "num_records": 2,
  "_links": {
    "self": {
      "href": "/api/storage/volumes"
    }
  }
}

Note: Some APIs don't run on FSx for ONTAP.

Use the NetApp BlueXP API Swagger interface

You can access some NetApp ONTAP APIs using the BlueXP r Connector Swagger interface. For more information, see Learn about BlueXP and How to log in to BlueXP (formerly Cloud Manager) API Swagger interface on the NetApp website.

The following steps are an example of accessing the Swagger interface using BlueXP and posting credentials.

1.    In the BlueXP Connector, select the Help menu, represented by a question mark, then select API.

Or, go to the Swagger interface directly (example URL: http://connectorip/occm/api-doc/).

2.    Select User Management Operations.

3.    Select auth : Authentication operations.

4.    Select POST /auth/login, Expand Operations.

5.    Select Model Schema.

6.    Select Click to set as parameter value under the model schema that displays the following:

{
"email": "string",
"password": "string"
}

7.    In the Value field where model schema is populated, edit the string to provide your correct email and password:

{
"email": "user@example.com",
"password": "xxxxxxxxxx"
}

Note: The email id isn'tfsxadmin. The email is the Cloud Central Auth0 email id used to log in to the BlueXP Connector. The password is set in plain text.

8.    Select Try it out!

9.    Verify that the login is successful from the Response Code.

Example: Get volumes API using the BlueXP Swagger interface

1.    In the Swagger interface, select FSx (Data ONTAP cluster) working environment operations.

2.    Select fsx/volumes.

3.    Select GET /fsx/volumes, Expand Operations.

4.    In the Value field, enter the file system ID that you want to retrieve the volumes list from.

5.    Select Try it out!

6.    Verify that the login is successful from the Response Code and the Response Body.


Related information

ONTAP REST API Python sample scripts now available on GitHub

AWS OFFICIAL
AWS OFFICIALUpdated a year ago