Application Integration
cancel
Showing results for 
Search instead for 
Did you mean: 

Announcing the release of HPE Nimble Storage PowerShell Toolkit version 2.1.0 & Default Formatters

Highlighted
Chris_Lionetti
Occasional Advisor

Announcing the release of HPE Nimble Storage PowerShell Toolkit version 2.1.0 & Default Formatters

Our latest update to the HPE Nimble Storage PowerShell Toolkit was just posted today to Infosight. The release offers a number of enhancements focused on improving customer satisfaction while also fixing a number of outstanding bugs.

You can download the new module here;

Over the next few days I will be posting a number of articles exploring each of these enhancements.

I will ensure that each of these articles is hotlinked to this master announcement as they are written.

We might as well cover the once of these enhancements now, in this case; Default Formatters.


What is a Default Formatter

When powershell commands are run, what is returned to the screen is not raw text, but instead the textual representation of an object (or collection of objects). As you may suspect, the Nimble Objects that are returned are quick complex and contain a large number of data points. For instance if you run the 'Get-NSVolume -name Test' command using the older toolkit you will see so much information that it rolls off the screen and that is only for a SINGLE object. If you run that command against ALL volumes, you can get hundreds of pages of information posted to the screen. See following screenshot;OldObject.png

To fix this, and make it much more readble, we need to be able to give a hint to the engine that converts objects to screen text representations. Note that we are not changing the object that is returned, but ONLY changing the representation of the object to the screen.

To acomplish this we modified the return object so that it is no longer of type "PSCustomObject', and we now return an object type which matches the API used to make the API call.

As an exampe, for the Volume Command, our TypeName is no longer 'PSCustom' but instead is 'NimbleStorage.Volume.TypeName'. This can be verified by using the command 'Get-NSVolume | get-member' and looking at the first returned line.

Once we have a typename, PowerShell will attempt to find the default formatter file that contains that type name. In this case, we have included a file in the PowerShell Module named 'HPENimblePowerShellToolkit.format.ps1xml'.

Suffice to say that once this automation all connects, the new output will by default display in table format instead of list format, and only the fields identified in the formatter file are displayed by default. An example of the difference can be seen below in a properly formatted output;PropForm.png

But remember that only the screen representation of the object has been modified, not the actual object itself, just because a less importaint field is not displayed doesnt mean it isnt still there. In fact, you can override the default formatter and go back to the old model by using the following addition to your command;

Get-NsVolume | format-list *

This command can also be useful to discover what the list of valid fields are that can be used to create your own custom tables.

It may be tempting to open the formatter file, and modify the XML contents so that you can change the default behavior, assuming that you can read or edit an XML file fluently. This approach while possible however will invalidate the module signature, and depending on your systems security settings may prevent you from loading the module in the future. It is far simpler to simply override the default formatters. To override the default formatter and show the table, but only show the columns that you wish. For example, if you want to only show the Name, Size, Application Category, and the ID of the volumes, you would use the following command;customtable.png

 

The command shown in the graphic is "Get-NSVolume | Format-Table name,size,app_category,id' but you will notice that I use the shorthand abbreviation for format-table which is 'ft'.

Of course the real advantage here is more than just Volumes but that formatter have been created for the return of all Nimble Storage API types to make all returned objects more easily human readable.