Deeper detail on using parameters with the FlashArray Python toolkit

Last week I posted about getting started with the Python toolkit, now I wanted to go a little deeper today on using the toolkit beyond connecting/creating a volume. A question I have seen more than once is:

“okay, I understand connecting and getting basic information, but what if I want to pull statistics or more advanced information from the array besides what the default commands? The API glossary for the toolkit doesn’t say explicitly how I can get the information I want”

In short, just because the Python glossary doesn’t explicitly say how to do something or even if you can, it does not mean you can’t. It really depends on what the REST API can do.

Let me explain.

If you go to our API glossary you can see the list of commands supported in our Python toolkit. As you might notice, it is a bit different than our PowerShell SDK for instance. While they both use our REST API to communicate with the array, the Python toolkit has less abstraction of the specific REST calls, meaning the syntax looks and follows exactly how our REST needs it. For the most part, there is one Python command for each specific GET, PUT, POST etc REST high-level command. PowerShell has switches etc to change it’s command structure. If we run the get_volume command with just the volume name will get you the basic information:

Python Command:
JSON Response:
{'source': None, 'serial': '5BF1C41FE35945C400011094', 'size': 10995116277760L, 'name':'myvolume', 'created': '2016-06-28T01:09:15Z'

But that is not the only option for that command. If you look at the REST API guide you can see what else the GET volume REST call supports. The guide is built into your FlashArray GUI (click on the help button in the upper-right).resthelp

So if you go to the volume call you can see what it supports. Additional options like snapshots, space information, performance, etc.restvolumesinfo

So how do they get passed? The default call does not include any parameters. How can I add them? Well if you look at the Python guide, you will see a second parameter entry for putting in additional parameters:

get_volume(volume, **kwargs)[source]

Return a dictionary describing a volume or snapshot.

  • volume (str) – Name of the volume to get information about.
  • **kwargs (optional) – See the REST API Guide on your array for the documentation on the request: GET volume/:volume

A list describing snapshots of the volume if the paramater snap is passed as True, else a dictionary describing the volume.

Return type:

dict or list

You will also notice the API glossary also tells you which API call to look at in the REST guide. So figure out which parameter you want to add and put it in the call. So if I want additional space detail, I would add space=true. Though, I cannot type it exactly like that, you need to enter the value in quotes like: space=”true. My volume name is just “myvolume”.

Python Command:


JSON Response:

{'name': myvolume', 'system': None, 'snapshots': 0, 'total_reduction': 26.32162155418513, 'volumes': 411738871808L, 'data_reduction':
 1.077714314109616, 'total': 411738871808L, 'shared_space': None, 'thin_provisioning': 0.9590559300500899, 'size': 10995116277760L}

What if you want more than one parameter? Well just add them comma separated. So if I want historical space/capacity information from the last hour, I would run this:

Python Command:


JSON Response (excerpt):

[{'name': 'myvolume', 'system': 0, 'snapshots': 0, 'total_reduction': None, 'volumes': 411737860096L, 'time': '2016-07-06T17:15:05Z',
 'data_reduction': 1.077696047285853, 'total': 411737860096L, 'shared_space': 0, 'thin_provisioning': None, 'size': 10995116277760L}, etc...

So just because the API glossary doesn’t explicitly list a feature of the command, it does not mean you cannot do it. This architecture of the toolkit allows you to leverage new REST features that might be introduced after the toolkit.


Leave a Reply

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

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