Accessing NetApp Ontap Using RestAPI

What is NetApp?

NetApp specializes in data storage equipment and associated management software. The company sells storage systems products to organizations and service providers.

NetApp’s biggest selling storage systems run on the ONTAP operating system.

What is ONTAP?

ONTAP is NetApp’s proprietary operating system used in storage disk arrays such as NetApp FAS and AFF, ONTAP Select, and Cloud Volumes ONTAP. With the release of version 9.0, NetApp decided to simplify the Data ONTAP name and removed the word “Data” from it, and remove the 7-Mode image.

ONTAP has evolved from NetApp’s original operating system way back in the day when the company first started, and it’s still their most popular and widely-deployed operating system. The different platforms that it can run on now are FAS, AFF, ONTAP Select, Cloud Volumes ONTAP, and NetApp Private Storage.

How to access ONTAP API?

You can access the ONTAP API using any of several different programming languages and tools. Popular choices include Python, Java, Curl, and PowerShell. A program, script, or tool that uses the API acts as a REST web services client. Using a programming language enables a deeper understanding of the API and provides an opportunity to automate the ONTAP administration.

In this process, It will use python programming language and Basic authentication must be set with the user name and password encoded as a base64 string.

Python request basic authorization base64 code example

The API expects the authorization header. This example shows the format of the authorization headers using the basic authentication base64 encoding.

				
					 user_pass = username + " : " + password 
 encoded_u = base64 . b64encode ( user_pass . encode ( ) ) . decode ( ) 
  
 headers = { "Authorization" : "Basic %s " % encoded_u }
				
			

Retrieving cluster software version

To start using ontap API, we can start by implementing this simple program that shows the cluster software version on your machine.

Get the cluster version using python and base64 authorization

				
					import request, base64
requests .packages.urllib3. disable_warnings ( )
  
username = "admin"
password = "passwrd"
user_pass = username + " : " + password
encoded_u = base64 . b64encode ( user_pass . encode ( ) ) . decode ( )
  
headers = { "Authorization" : "Basic %s " % encoded_u }
resp = requests . get ( 'https://192.168.1.123/api/cluster?fields=version' ,
         verify = False , headers = headers ) 
  
print ( resp.text )
				
			

OUTPUT:

				
					{
   "version" :{
      "full" : "NetApp Release 9.10.1: Sat Jan 15 10:49:44 UTC 2022" ,
      "generation" : 9 ,
      "major" : 10 ,
      "minor" : 1
  } ,
   "_links" : {
     "self" : {
      "href" : "/api/cluster"
     }
    }
}
				
			

Wrapping up

I hope you got the program working and was able to connect to your netapp vm. There are many things you can do on netapp. This is just a basic program on how to connect to a netapp vm. For more programs on how to connect and other things you can do on netapp try to visit our git page.