Software Development Kit (SDK) and API Discussions

NetApp API using call quota list

haha
3,912 Views

Can not have more than 1000 quota list calls using NetApp API?

 

[2016-12-30 18:19:40] [INFO] [UserServiceImpl.java.checkQuotaAndCreateQtree():504] checkQuotaAndCreateQtree Start
[2016-12-30 18:19:40] [INFO] [NetAppServiceImpl.java.getNetAppQuotaList():194] getNetAppQuotaList Start
[2016-12-30 18:19:40] [INFO] [NetAppUtil.java.getQuotaList():909] getQuotaList Start
[2016-12-30 18:19:45] [INFO] [NetAppServiceImpl.java.getNetAppQuotaList():213]  - arrNetAppQuotaList size : 1000
[2016-12-30 18:19:45] [INFO] [UserServiceImpl.java.checkQuotaAndCreateQtree():509]  - quotaList Size : 1000
[2016-12-30 18:19:45] [INFO] [UserServiceImpl.java.checkQuotaAndCreateQtree():520]  - isQuota :
false
[2016-12-30 18:19:45] [INFO] [NetAppUtil.java.addQuota():305] addQuota Start
[2016-12-30 18:19:50] [ERROR] [NetAppUtil.java.addQuota():353] addQuota NaAPIFailedException

 

 

3 REPLIES 3

asulliva
3,876 Views

I'm not terribly familiar with the Java side of things, but do you know which ZAPI it's using?  If it's using "quota-list-entries" then I think it does have some maximum...it's a single API call that will return all results, up to the maximum, at once.  Using the iteration set of APIs should have no maximum however.  You'll need to use quota-list-entries-iter-start followed by quota-list-entries-iter-next until it returns that there are no futher entries and, to be polite, end with quota-list-entries-iter-end.

 

Hope that helps.

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

sharathbabu
2,853 Views

Hi Andrew,

 

Even I am facing the same issue.

 

Could you please help me with the syntax for using "quota-list-entries-iter-start", "quota-list-entries-iter-next" and "quota-list-entries-iter-end".

 

Thanks in advance

Sharath 

 

 

FelipeMafra
3,792 Views

Hello,

 

Yes you can get more then a thousand quotas returned by API but not in a single API call. You should use the next-tag to keep calling for the next until there are none.

 

I am not a Java guy so I'll give you a sample of my Python code where I get a lot of quotas from quota report. In one filer it returns more than 60k quotas, so it works.

 

def _get_quota_report_cluster(filer):
quota_report = []

# simulate a do while
tag = None
while True:
if tag:
api = filer.call_api('quota-report-iter', ('max-records', '200'), ('tag', tag))
else:
api = filer.call_api('quota-report-iter', ('max-records', '200'))
# check if filer connection have any error
if api == "error":
return []
tag = api.child_get_string('next-tag')

attribute_list = api.child_get('attributes-list')

if attribute_list and attribute_list.has_children():
for q in attribute_list.children_get():
quota = Quota()
quota.filer_name = q.child_get_string('vserver')
quota.volume = q.child_get_string('volume')
quota.tree = q.child_get_string('tree')
quota.target = q.child_get_string('quota-target')
quota.type = q.child_get_string('quota-type')

if quota.type == 'user' or quota.type == 'sid':
if q.child_get('quota-users') is None:
continue
for user in q.child_get('quota-users').children_get():
quota.user = user.child_get_string('quota-user-name')
try:
quota.disk_used_gb = q.child_get_int('disk-used')
quota.disk_limit_gb = q.child_get_int('disk-limit')
except ValueError:
quota.disk_used_gb = 0
quota.disk_limit_gb = 0
quota_report.append(quota)
if not tag:
return quota_report

 

Pay attention that Filer and Quota are classes that I created, so it's not in the NMSDK. The main point here is the concept.

 

In this example the function returns a list of quotas object.

Public