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

... and - to complete a trilogy - here’s my (Dummy’s) guide for Ruby with ONTAP!

1) Download Ruby

This seems like a good place to start:

I downloaded Ruby 2.3.3 (x64):

2) Install Ruby

Double-click the rubyinstaller exe file, and follow the prompts to install.
The Ruby 2.3 64-bit default install directory is C:\Ruby23-x64.
If it’s your only version of Ruby, tick the ‘Add Ruby executables to your PATH’ - in fact, tick everything, why not!

Image: Installing Ruby for Windows

3) Download the NetApp Manageability SDK (NMSDK)
If not already done so...

> NetApp Manageability SDK > All Platforms

4) NetApp Ruby Library

Unzip the NMSDK.
To keep my Ruby libraries in one place, I copy the NetApp folder from:

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

- to -

C:\Ruby23-x64\lib

5) Test

Below is a very simple Ruby 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.rb
iv) Run in the DOS command prompt as>
ruby get-version.rb


$:.unshift 'C:/Ruby23-x64/lib/NetApp'
require 'NaServer'

s = NaServer.new("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")

api = NaElement.new("system-get-version")

xo = s.invoke_elem(api)
if (xo.results_status().eql?("failed"))
  print ("Error:\n")
  print (xo.sprintf())
  exit
end
print ("Received:\n")
print (xo.sprintf())


Image: Ruby success!

THE END

Note: Interestingly, I didn’t get an SSL error with Ruby (but I did with Python.)

Comments