I have been programming in Perl for about 15 years now so anytime I have to write something I usually resort to Perl. Such was the case when I heard about Isilon and its REST API. However I soon learned that there is very limited information on Perl and Isilon.
Combing the web I found EMC has a two great manuals that talk about their REST API, the Platform and Namespace manuals (not the official name but provides hints on what to look for). However these manuals had limited examples and virtually nothing for Perl. The internet proved to be weak on the subject as well. I did manage to find some examples with Curl, Python and some read-only type PowerShell scripts. However I new that whatever I was going to build would at some point need the ability to GET data and PUT/POST data with the REST API.
In the process of my search I did come across a Perl module for Rest::Client. Seeking out examples of how that module was used with other REST API's and in combination with the EMC manuals for Isilon's REST, I managed to put together my first Perl script.
The following Perl script will list out the files in a directory path on the Isilon cluster:
use REST::Client; use JSON; use Data::Dumper; use MIME::Base64; use IO::Socket::SSL qw( SSL_VERIFY_NONE ); $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0; my $username = 'admin'; my $password = 'secret'; my $headers = {Accept => 'application/json', Authorization => 'Basic ' . encode_base64($username . ':' . $password), Content-type => 'application/json'}; my $client = REST::Client->new(); $client->getUseragent()->ssl_opts( SSL_verify_mode => 0 ); $client->setHost('https://10.88.82.106:8080'); $client->GET('/namespace/ifs/data/benz',$headers); print $client->responseContent(). "\n"; ; exit;
Here is the output when run from a Windows host:
C:\TEMP>perl isi-file-list.pl {"children":[{ "name" : "schmaus3" } ,{ "name" : "schmaus1" } ,{ "name" : "schmaus2" } ]}
Basic script that we could then add argument parameters to to fill in the host, username, password and path details. We could then also write something to parse the JSON response and make it look nice and neat. Future version, but the core of the example shows you how to do the request in Perl.
Next post will be how you can create a directory on the Isilon cluster.