Connect Isilon REST API Using Python Requests Library

Isilon is a renowned scale-out network-attached storage (NAS) solution, that provides robust capabilities for storing and managing large amounts of data. You can manage it via GUI and perform various automation using Isilon REST API. Isilon REST API, allows developers to programmatically access and manipulate cluster resources.

Read NetApp REST API Using Python Request Library

In this blog post, we will explore how to connect to an Isilon cluster using the Python Requests library, providing a step-by-step guide to help you get started.

Isilon REST API Using Python

Setting Up the Environment

Before we dive into the coding process, let’s ensure we have the necessary tools in place. Firstly, make sure you have Python installed on your machine. You can download and install Python from the official Python website.

Additionally, we will need the Python Requests library, which can be installed using the pip package manager by running the command.

pip install requests

Understanding the Isilon REST API

To connect to an Isilon cluster, we need to familiarize ourselves with its Isilon REST API. The REST API provides a set of endpoints that allow us to perform various operations on the cluster. For Example, retrieving information about the cluster, managing nodes, accessing file systems, and more. You can find detailed documentation on the Isilon REST API in the official documentation.

Connect Isilon Using REST API

To access the REST API endpoints, we first need to authenticate ourselves with the Isilon cluster. Once logged in, you can access the API page to see all the available endpoints for the Isilon.

Now let’s start coding. Begin by importing the Requests library into your Python script:

import requests

Next, define a function called connect_isilon that will handle the connection to the Isilon cluster:

def connect_isilon():
    url = "https://<cluster-ip>/platform"
    headers = {
        "Authorization": "Basic <base64-encoded-credentials>"
    }

    response = requests.get(url, headers=headers, verify=False)
    data_json = response.json()

    # Process the JSON response as needed
    print(data_json)

Replace <cluster-ip> with the IP address or hostname of your Isilon cluster. Also, replace <base64-encoded-credentials> it with the Base64-encoded version of your Isilon username and password. The username and password format is as below.

root:password123

Visit the base64 encoder and decoder website, which can give you the Base64-encoded version of your Isilon username and password.

Base64 Encoder For Isilon REST API

The verify=False parameter is used to ignore SSL certificate validation, but please note that this is not recommended for production environments.

Making the Connection Using Isilon REST API

Within the connect_isilon function, we use the requests.get method to make a GET request to the Isilon cluster, passing the URL and headers as arguments.

The response from the REST API is stored in the response variable. We can then extract the JSON data using response.json() the method and store it in the data_json variable.

Processing the JSON Response

Once we have the JSON data, we can get more information. In the provided example, the JSON data is simply printed to the console. However, you can access specific values by navigating through the JSON structure. The Isilon API documentation will help you understand the structure and available data.

Running the Code and Exploring the Output

To execute the code, call the connect_isilon function at the end of your script:

connect_isilon()

Running the script will initiate the connection to the Isilon cluster using the provided endpoint URL and credentials. The response from the Isilon cluster is in JSON format. This will allow you to see the data returned by the API call and verify that the connection is successful.

To extract specific information from the JSON response, you can utilize the dictionary-like structure of the JSON data. For example, if you want to access a particular value, such as the bay number of a drive, you can navigate through the JSON structure and retrieve the desired information.

In the provided example, the code loops through the node_list and retrieves the drive information, followed by retrieving the bay number within each drive.

Expanding Functionality

The code example provided is a starting point for connecting to an Isilon cluster’s REST API using the Python Requests library. However, depending on your specific requirements, you may need to expand the functionality of the code.

You can explore other REST API endpoints, and perform different types of HTTP requests (e.g., POST, PUT, DELETE). The Isilon API documentation will provide details on available endpoints and the data they provide.

Conclusion

In this blog post, we have explored how to connect to an Isilon REST API using the Python Requests library. By leveraging the Isilon REST API, we can programmatically interact with the cluster and automate repetitive tasks.

Armed with this knowledge, you can further enhance the code to suit your specific needs. With practice, you can write much more complex code.