Getting Started with the Pure Storage Python Toolkit

What?!? The Python Toolkit on the PowerShell Guy’s blog? Hell yeah I say, a cook is only as good as the number of spices and how to use those spices. I wanted to just put together 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.

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.
    Babun
  3. Run the following command to download to use setuptools bootstrap installer:
    wget https://bootstrap.pypa.io/ez_setup.py -O - | python
     
    Step3
  4. Run
    clear
  5. Run the following command to install:
    easy_install pip
    
    Step5
  6. Run the following command to download the Pure Storage Python Toolkit:
    wget https://pypi.python.org/packages/source/p/purestorage/purestorage-1.4.0.tar.gz
    Step6
  7. Run the following command to install the Python Requests module which provides HTTP capabilities:
    pip install requests
    
    Step8

    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:
    pip install purestorage-1.4.0.tar.gz
    
    Step7

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. vim New-PfaVolume.py

    Part2_Step1

    Note: This is going to create a Python file named New-PfaVolume… dang that file name looks awfully similar.

  2. i

    Note: Just type “I” (no quotes) to enter INSERT mode.

    Part2_Step2

  3. 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”)

    Part2_Step3

  4. The next few lines with exit out of insert mode, write the file (:w) and quit VIM (:q)
    ESC
    :w
    :q
    
    Part2_Step4

     

  5. Now time to run the New-PfaVolume.py script:
    python New-PfaVolume.py
    
    Part2_Step5
    
    
  6. Last check your Pure Storage FlashArray and you will see the 500GB TEST-VOLUME1.

    TEST-VOLUME1

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.

I’m just starting on some other examples using the Python Toolkit so there will be others coming in between my PowerShell SDK/Toolkit work. What’s next…C# is what I’m thinking about.

Thanks,
barkz

One comment
  1. Managed to install the python toolkit with help from Tom Kircoff (Purestorage). First impression is quite good. python is one of the scripting language of choice for my team so we are more interested in it than powershell.

Leave a Reply to Thong Ly Cancel Reply

Required fields are marked *. Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.