Sunday, 19 February 2017

Using Perl (on Windows) with NetApp ONTAP - Dummy’s Guide

If you’re a regular reader of this blog, you’ll know I love a bit of PowerShell - I’ve tagged 128 posts with PowerShell. Perl - on the other hand - has yet to be tagged on one post. Well, this changes today! The titular “dummy” is me (I’m a Perl noob), and - since I work predominantly from Windows laptop/workstation - this is going to be Perl on Windows...

1) Install Perl

Firstly, we need to install Perl. The following link - http://learn.perl.org/installing/ - contains links to Installing Perl on Windows, OSX, and Unix/Linux.


Image: Padre on Strawberry Perl installed!

Image: Command Prompt/PowerShell and ‘perl -v’ to verify installation.

Image: App-cpanminus installed too.

2) Download the NetApp Manageability SDK (NMSDK)

> NetApp Manageability SDK > All Platforms

3) NetApp Perl Modules

Unzip the NMSDK.
To put all my Perl libraries in one place, I copy the NetApp folder from:

netapp-manageability-sdk-5.6 > lib > perl > NetApp

- to -

C:/Strawberry/perl/lib

4) Test

Below is a very simple Perl script example taken from the NMSDK and ZExplore.

i) Copy and paste into a text editor
ii) Edit CLUSTER_NAME, USER_NAME, and PASSWORD as required.
iii) Save as get-version.pl
iv) Run in the DOS command prompt as>
perl get-version.pl


require 5.6.1;
use lib 'C:/Strawberry/perl/lib/NetApp';
use strict;
use warnings;
use NaServer;
use NaElement;

my $s = new NaServer('CLUSTER_NAME', 1 , 31);
$s->set_server_type('FILER');
$s->set_transport_type('HTTPS');
$s->set_port(443);
$s->set_style('LOGIN');
$s->set_admin_user('USER_NAME', 'PASSWORD');

my $api = new NaElement('system-get-version');

my $xo = $s->invoke_elem($api);
if ($xo->results_status() eq 'failed') {
  print 'Error:\n';
  print $xo->sprintf();
  exit 1;
}

print 'Received:\n';
print $xo->sprintf();


Note: I received an error - errno="13001" - using Cluster Management IP address, so added the name of the cluster to my hosts file and this worked.

Image: Perl success!

THE END

No comments:

Post a Comment