HPE Storage Tech Insiders
cancel
Showing results for 
Search instead for 
Did you mean: 

NimbleOS 4 Use Case: Setting QOS on a Volume using the Nimble API

rfenton4

Earlier in the blog series, both Julian Cates and I have blogged on the Enhanced REST API in Nimble OS 4 in NOS4 and Quality of Service (QoS-Limits).

I therefore thought it would serve as a useful example to join the two subjects together, and share a simple script that will allow you to set a QOS limit using the API.  Of course this can be done via the GUI and the Command Line (as demonstrated in my earlier blog), however I see many use cases where the setting/lifting of QOS may wish to be automated, as part of batch operation or a predefined workflow.   I also thought this would serve as a good introduction to the API, as many of the interactions with other objects in NimbleOS using the API is very similar to what is demonstrated in this blog.

Throughout my career I’ve meddled with Perl scripting, so that is the programming language (interpreter to be precise) I have chosen to write my script in.   The script is attached below and with best practice in mind, I have annotated it with lots of comments, however I thought I would step through it in this blog post.

The script itself is made up of some initial definitions, a main body and then three sub-procedures:

  - The first sub-procedure logs into the array using the REST API.

  - The second sub-procedure looks for the Volume that we are interested in setting QOS on (I need to look for the volume in order to obtain the Volumes unique identifier).

  - the final sub-procedure, sets the defined QOS on the volume in question and then prints the result.

So let’s break this down into a little more detail:

Initial Definitions


The library use definitions are third-party libraries extensions, that have been loaded to extend the standard Perl functionality.  These include functions like logging into the array using certificates, decoding/encoding JSON responses and communicating using REST and SSL.   These libraries need to be downloaded and compiled to your Perl interpreter in order for the script to successfully work.


QOSBLOG1.png


Next, we have the Variable definitions, these define the array IP address/hostname that hosts the volume we wish to set QOS on, the username/password to login to the array and the certificate file and location in order to create the SSL connection.   We can then see the individual QOS parameters that we are going to pass, which dictates the Volume we are working with, the QOS limit that we intend setting and the limit that we will restrict the volume too.

Note: LimitType can be limit_iops or limit_mbps in order to set the appropriate QOS.  The limit value expresses the QOS limit, in IOPS or Megabytes per Second.  If -1 is supplied then the limit is removed.

The Main Code

The main code is the main functions that call the three sub-procedures:

&LoginArray - logs into the defined array

$VolID = &GetVolID($VolName) - grabs the unique volume ID for the given Volume

&BuildQOSRequest - uses the Volume ID from the previous step to set the QOS Limit and prints out the result.

QOSBLOG2.png


Let’s look at each sub-procedure:

LoginArray Sub-procedure

This is a generic procedure that will be common when logging into any array when you want to work with the API.  It takes the parameters that are defined in the initial definitions section (IP Address/Hostname, Login Name, Password and Certificate File location), it then builds the REST/API call to supply those parameters, and POST’s them to the array in order to receive a client connection ($client) in return.


QOSBLOG3.png

The client connection is then used in our subsequent communication with the array.

GetVolID Sub-procedure

This procedure is provided with a parameter Volume Name (the volume in this instance that we wish to set QOS on), it queries the API for all the volumes and there associated volume ID’s and returns the volume ID for the volume in question.

This is an important step because most of the API’s that Edit or Read volume details, utilise the VolumeID rather than the Volume Name.

From below you can see the API call to GET, all the information about all the volumes.

QOSBLOG4.png

Hint: if you uncomment the print line under the first GET call, you will see the output of this request, which is a list of all of the volumes and their volumeID’s in an XML/JSON format.

Next we recurse the list of all the volumes that were supplied and look for the volume we are interested in.  Once we find it we query the VolumeID and return it to the next procedure.

BuildQOSRequest sub-procedure

The final procedure is to take the Volume ID from the previous step and then set the QOS on the volume based on the parameters at the top of the script.

This is achieved by building the JSON/API call and the PUTting the API call to specific volumes/$volID.

Hint: Once again if you uncomment the line at the bottom of this section you will see all the parameters that are associated to the Volume and can be manipulated using the API.   There is a lot of good information in there!


QOSBLOG5.png

The script is attached here.

Note: there is no formal support for any script that you download from a community website, so always take care to not be like this poor fellow when testing your scripts, "with great power comes great responsibility" - Spidey.

Web hosting company accidentally deletes part of the internet while trying to clean up its servers | The Independent


There is also a short video demoing the script below (note: the video has no sound!):


Video Link : 1300

Setting QOS on a Volume using the Nimble API - YouTube


Hopefully you have found this blog useful and informative, please post comments or queries below.  However I am not a developer by profession so please don’t be to critical on my limited scripting ability :-)


Thanks

0 Kudos
About the Author

rfenton4

Events
See posts for
dates/locations
HPE at 2018 Technology Events
Learn about the technology events where Hewlett Packard Enterprise will have a presence in 2018.
Read more
See posts for dates/locations
Reimagine 2018
Join us at one of the Reimagine 2018 stops and see how we Simplify Hybrid IT, innovate at the Intelligent Edge and bring it all together with HPE Poin...
Read more
View all