Software Development Kit (SDK) and API Discussions

Simple wrapper framework around Python NMSDK

yannb
3,961 Views

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

 

3 REPLIES 3

dkorns
3,938 Views

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.

Manikandanganesan
2,892 Views

I am very much interest to learn automation using python but not where I need to start 

chibata
2,553 Views

Very interested in it! How it comes?

Public