Getting Started with the Pure Storage Python Toolkit

Here’s a quick blog post explaining how fast and easy it is to get started with the Pure Storage Python Toolkit using a cool Windows Shell on Windows 8.1.

Getting Started with the Pure Storage Python Toolkit

Summary

Here is an introduction to the Pure Storage Python Toolkit, now updated with the latest Unified Python SDK (py-pure-client), simplified installation steps, and enhanced scripting examples for managing FlashArray and FlashBlade systems.

image_pdfimage_print

Let’s get started with the Python toolkit. There are a few options to get going with Windows:

  1. Use physical or virtual Windows 8.1 (this is what I will be using on a Surface Pro 3 no-less)
  2. Use physical or virtual Windows Server

Quick Steps

  1. Download and install Babun (pronounced Baboon) – This is one of the slicker and easier to setup Windows Shells.
  2. After Babun installs it will automatically start, you should see the below screenshot.
  3. Run the following command to download to use setuptools bootstrap installer:
  4. Run
  5. Run the following command to install:

  6. Run the following command to download the Pure Storage Python Toolkit:
  7. Run the following command to install the Python Requests module which provides HTTP capabilities:

    Note: I had already installed this so you’ll see the requirement has already been satisfied.

  8. Now let’s install the Pure Storage Python Toolkit 1.4.0:

Now we are done installing and setting up the environment. On to creating the first simple script to create a connection and a volume. Most of of the steps below are about commands to use in VIM (Vi Improved).



  1. The next few lines are the core of the script for connecting to the FlashArray and creating a volume. The following lines will create a FlashArray using the purestorage library. Then we will assign the array object by using the FlashArray with the various properties, then finally create a TEST-VOLUME1 that is 500GB in size.from purestorage import FlashArray
    array = FlashArray(target=”<IP>”, username=”pureuser”, password””=”pureuser”)
    array.create_volume(“TEST-VOLUME1”, “500G”)
  2. The next few lines with exit out of insert mode, write the file (:w) and quit VIM (:q)
  3. Now time to run the New-PfaVolume.py script:

Super simple and demonstrates using our Python Toolkit from a Windows machine. Next part we’ll create a host, connect volumes, and take snapshots. But in the meantime if you are interested take a look at the Programming Interfaces on the Pure1 Community or visit the Online Quick Start Guide to do some more work on your own.

To align with current best practices and tools, users are encouraged to adopt the latest Unified Python SDK. Below are updated instructions for getting started:

1. Prerequisites:

Python Version: Ensure that Python 3.5 or higher is installed on your system. You can download the latest version from the official Python website.

Package Installer: Use pip, which comes bundled with modern Python installations, to manage packages.

2. Installation Steps:

Install the Unified Python SDK:Open your command prompt or terminal and execute:


bash





pip install py-pure-client

This command installs the latest version of the Pure Storage Unified Python SDK from the Python Package Index (PyPI).

3. Basic Usage Example:

Connecting to a FlashArray:Here’s a simple script to connect to a Pure Storage FlashArray and list all volumes:


python





from purity_fb import PurityFb

# Initialize the FlashBlade client
fb = PurityFb("your_flashblade_management_ip")

# Login to the array
fb.login("your_api_token")

# List all file systems
file_systems = fb.file_systems.list_file_systems()
for fs in file_systems.items:
print(f"Name: {fs.name}, Size: {fs.provisioned}")

Replace "your_flashblade_management_ip" with the management IP address of your FlashBlade and "your_api_token" with your API token.

4. Additional Resources:

Documentation: For comprehensive guidance, refer to the Unified Python SDK documentation.

Source Code: Access the SDK’s source code and contribute to its development on GitHub.

By following these updated steps, users can leverage the latest tools and practices to effectively manage Pure Storage systems using Python.

How the Right Storage Plays a Role in Optimizing Database Environments