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

Following on from the previous post, my (Dummy’s) guide for Python with ONTAP!

1) Download Python

This seems like a good place to start: The Hitchhiker's Guide to Python

2) Install Python

Double-click the python-2.7.12.msi and follow the prompts to install.
- Default installation directory is C:\Python27\
- On the Customize Python 2.7.12 screen, I select ‘Add python.exe to Path’ (since I have no other version of Python).

Image: Installing Python for Windows

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

> NetApp Manageability SDK > All Platforms

4) NetApp Python Library

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

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

- to -

C:\Python27\Lib

5) Test

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


import sys
sys.path.append("C:/Python27/Lib/NetApp")
from NaServer import *

s = 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")

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

xo = s.invoke_elem(api)
if (xo.results_status() == "failed") :
  print ("Error:\n")
  print (xo.sprintf())
  sys.exit (1)

print ("Received:\n")
print (xo.sprintf())


Note: I was getting the error -
status="failed" reason="[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)" errno="13001"
- and had to change transport_type to HTTP, and port to 80, to get this to work.

Image: Python success!

THE END

Random tip: To change the DOS command prompt to "CMD> ", type in the command prompt>
prompt CMD$g$s

Comments

  1. THANK YOU!

    Now, to figure out how to get https to work...

    ReplyDelete

Post a Comment