Software Development Kit (SDK) and API Discussions

quota-report-iter no query filter accepted

Michael_Lang
views-count 1868 Views

Hi,

I'm using OnTAP 8.3.1 to retrieve quota reports for infrastructure integration. Unfortunately the query element seems to be not working as expected. When specifying

 

api1.set_vserver('test')
report = NaElement('quota-report-iter')
report.child_add(NaElement('max-records', 5))
query = NaElement('query')
query.child_add(NaElement('quota-target', 'xxxx'))
report.child_add(query)
res = api1.invoke_elem(report)

 the query element is ignored completley where with ither iters (like storage-disk-get-iter) the build construct is working. I've been in contact with NetAPP support as I think, this is a Bug due to the result status/reason indicate a positive response but return a not correct result. In the example above the result would contain everything up to the first 5 records no matter what you specify in quota-target.

 

does anyone has an idea how to query a quota-report for a specific quota-target instead of fetching all records and parsing them manually ? In our example this means 13 seconds waiting for retrieval of all entries ...

 

thanks in advanced

kind regards

Michael Lang

3 REPLIES 3

Re: quota-report-iter no query filter accepted

francoisbnc
views-count 1869 Views

hi,

 

let's try this

api = NaElement("quota-report-iter")
api.child_add_string("max-records","5")

xi = NaElement("query")
api.child_add(xi)


xi1 = NaElement("quota")
xi.child_add(xi1)

xi1.child_add_string("quota-target","*")
xi1.child_add_string("volume","test")

xo = s.invoke_elem(api)
if (xo.results_status() == "failed") :
print ("Error:\n")
print (xo.sprintf())
sys.exit (1)

print ("Received:\n")
print (xo.sprintf())

 

François 

Re: quota-report-iter no query filter accepted

Michael_Lang
views-count 1869 Views

Hi François,

 

thanks for your feedback, it seems that the additional element "quota" does the trick, with that it's not even necessary to specify the volume entity.

 

api1.set_vserver('test')
report = NaElement('quota-report-iter')
report.child_add(NaElement('max-records', maxrecords))
query = NaElement('query')
quota = NaElement('quota')
query.child_add(quota)
quota.child_add(NaElement('quota-target', 'test'))
report.child_add(query)
res = api1.invoke_elem(report)

for e in map(lambda x: (x.child_get_string('quota-target'), x.child_get_int('disk-limit')), res.child_get('attributes-list').children_get()):
      print e

 

(u'test', 2048000)
(u'test', 3072000)
(u'test', 1024000)

 

Re: quota-report-iter no query filter accepted

Michael_Lang
views-count 1869 Views

small additional information here to be added,

 

for people using quota reporting on none enforced volumes for easier accumulation of space used by a specific user, quota-report-iter using a filter will not show such entries.

Meaning Volume1 has quota turned on but no limits and target equals "*" ... for that case you'll still need to fetch the complete report iter and filter manually

 

 
api1.set_vserver('')
report = NaElement('quota-report-iter')
report.child_add(NaElement('max-records', maxrecords))
query = NaElement('query')
quota = NaElement('quota')
query.child_add(quota)
quota.child_add(NaElement('quota-target', 'lang'))
report.child_add(query)
res = api1.invoke_elem(report)
print res.sprintf()

 

<results status="passed">
	<num-records>0</num-records>
</results>

 

where retrieving all items without filter will provide expected entries

 

api1.set_vserver('')
QReports = QuotaReportCollector(from_api=api1.invoke(*['quota-report-iter', 'max-records', maxrecords]).child_get('attributes-list'))
map(str, QReports.get_report(target='lang'))
['<quota disk_limit="-" disk_used="1" file_limit="-" files_used="136" type="user" uid="lang" volume="vol1"/>',
 '<quota disk_limit="-" disk_used="76" file_limit="-" files_used="2485" type="user" uid="lang" volume="vol2"/>',
 '<quota disk_limit="-" disk_used="10909" file_limit="-" files_used="106679" type="user" uid="lang" volume="vol3"/>',
 '<quota disk_limit="-" disk_used="21" file_limit="-" files_used="2" type="user" uid="lang" volume="vol4"/>',
 '<quota disk_limit="-" disk_used="279" file_limit="-" files_used="336" type="user" uid="lang" volume="vol5"/>',
 '<quota disk_limit="-" disk_used="10" file_limit="-" files_used="10" type="user" uid="lang" volume="vol6"/>']

 

 

G2 Review Banner
All Community Forums
Public