This post is more than 5 years old
20 Posts
1
6771
Help with Unisphere for VMAX REST API
Hello,
I'm trying to use the REST API to U4V. I'm fairly new to REST but I *have* done some amount of programming against other REST APIs. I took a look at the U4V REST API Programmer's Guide and I am stumped. That document doesn't seem like it has the kind of information I need to get started.
I compiled the RESTApiTest java program and ran it against my U4V instance but basically got nothing back.
I feel like I need more of a "Hello World" type of example vs. something that tries to pull back performance metrics using iterators that I don't fully understand.
Can anyone give me some simple, basic steps to pull back basic information from my VMAX? Ideally, I'd like to use a browser REST plug-in to play with the various calls vs. writing a program but either way, I need some hand-holding to get started.
Thanks,
Tom
tmhudg1
20 Posts
2
January 20th, 2014 15:00
Hi Sean,
Thanks very much for the pointer to the blog post and the information therein! That really helped me get started. I also got connected with a guy who helped me understand the XSD schema files so I can understand how to build the URLs and payloads to send to get other info. I've now got a small Python script working that does some simple GETs and POSTs.
Thanks again for the info,
Tom
PS - I figured I'd post the script I wrote here in the hopes it will help someone else get started. All the usual caveats apply of course (I don't claim that this script does anything...). You'll need to supply your own , , , and .
#!/usr/bin/python
import requests
import json
from requests.auth import HTTPBasicAuth
# Define some connection info
unimaxURI = 'https:// :8443/univmax/restapi'
username = ' '
password = ' '
symmId = ' '
# A simple class to do GETs and POSTs and return a dict with the result
class u4vRest:
# Set up some basic info when the class is instantiated
def __init__(self, unimaxURL, username, password):
self.headers = {'Content-Type' : 'application/json' }
self.URL = unimaxURL
self.username = username
self.password = password
self.symID = ""
self.payload = {}
def doGet(self,restURI):
# Form the url by combining the base with the passed in part
url = "%s/%s" % (self.URL,restURI)
# Do the GET. verify=False lets us ignore the SSL Cert error
r = requests.get(url,headers=self.headers, verify=False, auth=HTTPBasicAuth(self.username,self.password))
# Convert the JSON data into a python dict
data = r.json()
return data
def doPost(self,restURI,payload):
url = "%s/%s" % (self.URL,restURI)
r = requests.post(url,headers=self.headers, data=json.dumps(payload),verify=False, auth=HTTPBasicAuth(self.username,self.password))
data = r.json()
return data
# Instantiate the class
u4v = u4vRest(unimaxURI,username, password)
# Do some simple GETs
data = u4v.doGet('management/RuntimeUsage/read')
print json.dumps(data,indent=4)
data = u4v.doGet('common/Application/list')
print json.dumps(data,indent=4)
data = u4v.doGet('performance/Array/keys')
print json.dumps(data,indent=4)
# A POST requires a payload. We build a dict with the values corresponding to the schema
# The start and end Date are the same so we aren't going to get anything interesting...
payload = {
"arrayAlertParam":{
"startDate" : 946684800000,
"endDate" : 946684800000,
"symmetrixId" : symmId,
}
}
data = u4v.doPost('performance/Array/alerts',payload)
print json.dumps(data,indent=4)
seancummins
226 Posts
2
January 20th, 2014 05:00
Tom,
I have a blog post with some practical information and examples -- check out http://blog.scummins.com/?p=4.
Thanks,
- Sean
ScottBrightwell
9 Posts
0
February 11th, 2014 13:00
Check out Sean Cummins’ blog post on the subject:
http://blog.scummins.com/?p=4
tmhudg1
20 Posts
0
May 22nd, 2014 07:00
Just to follow up on my original post and put this info somewhere where it might benefit someone else, I ran into a problem using the REST API after switching to a new VMAX. My Storage Admin rotated a new VMAX into our environment and set everything up in U4V but when I went to use the REST API, I couldn't get any data. The REST connection worked fine but when I asked say, for a list of Storage Groups, I just got an empty response. It was a properly formatted XML response but it was as if there were simply no SGs configured on the box (which I knew was untrue).
I finally found (in U4V) under Performance, Settings, System Registrations, that the Real Time collection setting was turned off. As soon as I turned this on, my REST API calls started returning the right data (after the 5 minute polling cycle elapsed). Note that even non-performance calls (give me a list of SGs) were not being answered with this turned off.
This info is not in the REST API Programmer's Guide - it only mentions having a user with appropriate rights.
Hope this helps,
Tom