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.
Let’s get started with the Python toolkit. There are a few options to get going with Windows:
- Use physical or virtual Windows 8.1 (this is what I will be using on a Surface Pro 3 no-less)
- Use physical or virtual Windows Server
Quick Steps
- Download and install Babun (pronounced Baboon) – This is one of the slicker and easier to setup Windows Shells.
- After Babun installs it will automatically start, you should see the below screenshot.
- Run the following command to download to use setuptools bootstrap installer:
1wget <a href=“https://bootstrap.pypa.io/ez_setup.py”>https://bootstrap.pypa.io/ez_setup.py</a> -O – | python<br> <br><figure><a href=”https://www.purepowershellguy.com/wp-content/uploads/2015/07/Step3.png”><img title=”Step3″ width=”563″ height=”337″ border=”0″ src=”https://www.purepowershellguy.com/wp-content/uploads/2015/07/Step3_thumb.png” alt=”Step3″></a></figure> - Run
1clear - Run the following command to install:
1easy_install pip<br><br><figure><a href=“https://www.purepowershellguy.com/wp-content/uploads/2015/07/Step5.png”><img title=“Step5” width=“566” height=“339” border=“0” src=“https://www.purepowershellguy.com/wp-content/uploads/2015/07/Step5_thumb.png” alt=“Step5”></a></figure> - Run the following command to download the Pure Storage Python Toolkit:
1wget <a href=“https://pypi.python.org/packages/source/p/purestorage/purestorage-1.4.0.tar.gz”>https://pypi.python.org/packages/source/p/purestorage/purestorage-1.4.0.tar.gz<br></a><figure><a href=”https://www.purepowershellguy.com/wp-content/uploads/2015/07/Step6.png”><img title=”Step6″ width=”571″ height=”342″ border=”0″ src=”https://www.purepowershellguy.com/wp-content/uploads/2015/07/Step6_thumb.png” alt=”Step6″></a></figure> - Run the following command to install the Python Requests module which provides HTTP capabilities:
1pip install requests<br><br><figure><a href=“https://www.purepowershellguy.com/wp-content/uploads/2015/07/Step8.png”><img title=“Step8” width=“579” height=“347” border=“0” src=“https://www.purepowershellguy.com/wp-content/uploads/2015/07/Step8_thumb.png” alt=“Step8”></a></figure>Note: I had already installed this so you’ll see the requirement has already been satisfied.
- Now let’s install the Pure Storage Python Toolkit 1.4.0:
1pip install purestorage–1.4.0.tar.gz<br><br><figure><a href=“https://www.purepowershellguy.com/wp-content/uploads/2015/07/Step7.png”><img title=“Step7” width=“576” height=“345” border=“0” src=“https://www.purepowershellguy.com/wp-content/uploads/2015/07/Step7_thumb.png” alt=“Step7”></a></figure>
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).
1vim New–PfaVolume.py<strong>Note</strong>: This is going to create a Python file named New–PfaVolume… dang that file name looks awfully similar.
1i<strong>Note</strong>: Just type “I” (no quotes) to enter INSERT mode.- 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”) - The next few lines with exit out of insert mode, write the file (:w) and quit VIM (:q)
1ESC<br>:w<br>:q<br><br><figure><a href=“https://www.purepowershellguy.com/wp-content/uploads/2015/07/Part2_Step4.png”><img title=“Part2_Step4” width=“606” height=“220” src=“https://www.purepowershellguy.com/wp-content/uploads/2015/07/Part2_Step4_thumb.png” alt=“Part2_Step4”></a></figure> - Now time to run the New-PfaVolume.py script:
1python New–PfaVolume.py<br><br><figure><a href=“https://www.purepowershellguy.com/wp-content/uploads/2015/07/Part2_Step5.png”><img title=“Part2_Step5” width=“617” height=“90” src=“https://www.purepowershellguy.com/wp-content/uploads/2015/07/Part2_Step5_thumb.png” alt=“Part2_Step5”></a></figure>
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:
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:
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.
