Software Development Kit (SDK) and API Discussions

Python API quotareport script for user quota

Gundapaneni
2,103 Views

Hi ,

 

I am new to APi's, Wrote the below one, 
My requirement is to get the quota report for a user. Couls someone kindly help me with the error below.


cat quota.py

#!/usr/bin/python3
from netapp_ontap import HostConnection
from netapp_ontap import NetAppRestError
from netapp_ontap.resources import QuotaReport

with HostConnection("xxxxxxxx", username="admin", password="XXXXXX", verify=False):
resource = QuotaReport(
index=2305843013508661248,
**{"volume.uuid": "de90a323-1349-49c9-acdf-f6822e82f6db"}
)
resource.get()
print(resource)

 

when i run this in python script, i am getting below error.

 

$ ./quota.py
Traceback (most recent call last):
File "./quota.py", line 11, in <module>
resource.get()
File "/usr/local/lib/python3.6/site-packages/netapp_ontap/resources/quota_report.py", line 1339, in get
return super()._get(**kwargs)
File "/usr/local/lib/python3.6/site-packages/netapp_ontap/utils.py", line 55, in wrapper
return on_api_fail(erro)
File "/usr/local/lib/python3.6/site-packages/netapp_ontap/utils.py", line 78, in on_api_fail
raise NetAppRestError(cause=erro) from None
netapp_ontap.error.NetAppRestError: Caused by HTTPError('404 Client Error: Not Found for url: https://10.109.24.221:443/api/storage/quota/reports/2305843013508661248',): "2305843013508661248" is an invalid value for field "volume.uuid" (<UUID>)
$

 

1 REPLY 1

a4ashu
1,808 Views

There were multiple reasons I faced this issue one was VPN connection from home , when you dont have proper ssh connection to the controller from your desktop/jumpserver to your end controller it throws this issue ,

 

sometimes when you do a .get command it cant find the values if quota report has empty variables try using getattr to set values of unset variables to zero or null

try get collection command

 

quots = quotareport.get_collection(vol.uuid)

for quotx  in quots :
quotx.get(fields='specifier,volume,space,qtree,files,index,qtree ')

 

 

Public