ONTAP Discussions
ONTAP Discussions
Hello, im am receiving the following error while trying to pull quota policy rules.
------------------------------
Traceback (most recent call last):
File "qrule.py", line 21, in <module>
quota.get(fields='*')
File "/opt/netapp/py/.venv/lib/python3.8/site-packages/netapp_ontap/resources/quota_rule.py", line 921, in get
return super()._get(**kwargs)
File "/opt/netapp/py/.venv/lib/python3.8/site-packages/netapp_ontap/utils.py", line 51, in wrapper
return func(*args, **kwargs)
File "/opt/netapp/py/.venv/lib/python3.8/site-packages/netapp_ontap/resource.py", line 1308, in _get
self._parse_json_response(response)
File "/opt/netapp/py/.venv/lib/python3.8/site-packages/netapp_ontap/resource.py", line 1675, in _parse_json_response
self._clone_from_dict(response_dict)
File "/opt/netapp/py/.venv/lib/python3.8/site-packages/netapp_ontap/resource.py", line 1732, in _clone_from_dict
self.__dict__ = self.from_dict( # pylint: disable=attribute-defined-outside-init
File "/opt/netapp/py/.venv/lib/python3.8/site-packages/netapp_ontap/resource.py", line 568, in from_dict
raise NetAppRestError(cause=exc) from None
netapp_ontap.error.NetAppRestError: Caused by ValidationError({'space': {'soft_limit': ['"-" could not be interpreted as an integer or a valid size. Valid size values are of the form \\d+[KB|MB|GB|TB|PB].You must pass either a valid size string or an integer for soft_limit.']}, 'files': {'soft_limit': ['"-" could not be interpreted as an integer or a valid size. Valid size values are of the form \\d+[KB|MB|GB|TB|PB].You must pass either a valid size string or an integer for soft_limit.'], 'hard_limit': ['"-" could not be interpreted as an integer or a valid size. Valid size values are of the form \\d+[KB|MB|GB|TB|PB].You must pass either a valid size string or an integer for hard_limit.']}})
i assume it is because of this:
"space": {
"hard_limit": 130996502528,
"soft_limit": "-"
},
"files": {
"hard_limit": "-",
"soft_limit": "-"
but the thing is that we are never setting those limits, just hard_limit and the "-" is there by default . this is causing failures during our reports and automation process . any idea how to skip those parameters from being retrieved ? i have found a way with try and except but that is causing for qtree's to be skipped and being left out of the report/automation process .
Hi Christian, this is a bug in ONTAP. If you want to skip getting these fields in the response, you can skip those fields that are causing issues by doing something like quota.get(fields="!space.soft_limit"). This will give you all fields for that quota rule except space.soft_limit. If you want to skip multiple fields, you can provide a comma separated list as a string for fields. That could look like quota.get(fields="!space, !files").
So you would do something like:
for quota in QuotaRule.get_collection():
quota.get(fields="!space.soft_limit,!files.soft_limit,!files.hard_limit")
Just make sure you don't have a space in the fields string as that can cause issues with encoding the query. Let me know if this works for you.
Hi Twesha,
thanks for your reply. i have tried escaping the fields or calling only the space.hard_limit field before opening here the thread and even that does not work and throws errors . that is because even space.hard_limit has "-" in quota rules for example on root volumes (since a volume cannot have a quota rule so by default it has a "-") as seen in the example below:
Soft Soft
User Disk Disk Files Files
Type Target Qtree Mapping Limit Limit Limit Limit Threshold
----- -------- ------- ------- -------- ------- ------ ------- ---------
tree "" "" - - - - - -
tree test_qtree "" - 20 - - - -