Subscribe

Simple wrapper framework around Python NMSDK

Simple announcement :

http://dev.tynsoe.org/ybizeul/netapp-scripts/tree/master

 

Feel free to comment if you are interested in the initiative.

 

Purpose

 

NetApp Manageability SDK (NMSDK) is provided by NetApp to let third party ddevelopment and scripts to interract with NetApp storage components (cDOT clusters, 7-mode controllers, OnCommand Unifued Manager, DFM).

 

The SDK provided by NetApp is essentially a wrapper around the XML protocol used to exchange informations over HTTP(s). It means you essentially have to build a structure of NaElements (in essence representing XML nodes) implementing the required elements and children documented for each call.

 

It leads to code hard to read and maintain, mostly spent in building NaElements and stick them together instead of performing straightforward API calls.

 

NetAppObject.py is a module that lets you simplify your code and develop more efficiently with NetApp APIs. For example, to get the name of a NetApp cluster, the traditional way is the following code :

 

"s" is a previously created NaServer object

 

cluster_identity_get = NaElement("cluster-identity-get")
desired_attributes = NaElement("desired-attributes")
cluster_name = NaElement("cluster-name")

cluster_identity_get.child_add(desired_attributes)
desired_attributes.child_add(cluster_name)

result = s.invoke_elem(cluster_identity_get)

cluster_name = result.child_get("attributes").child_get("cluster-identity-info").child_get_string("cluster-name")

print cluster_name

Using NetAppObject:

 

result = NetAppObject.invoke(s,{"cluster-identity-get": {"desired-attributes": {"cluster-name"}}})
cluster_name = result["results"]["attributes"]["cluster-identity-info"]["cluster-name"]
print cluster_name

 

Or even easier:

 

result = Cluster(s)
print result.cluster_name

 

Re: Simple wrapper framework around Python NMSDK

[ Edited ]

I'm interested. I was previously a Perl hacker but in more recent NetApp automation efforts I have fallen into the PowerShell and NetApp PowerShell Toolkit groove (mostly, but not always, under the control of WFA). It is on my bucket list to get better with the NMSDK and Python. I've not played with NMSDK yet (in any language) and your example shows me how complex it can be. Your framework looks like a much better way way to marry Python and NMSDK. So count me in as interested ... I just need to find the time and the right project. In the meantime I'll have a look.