Software Development Kit (SDK) and API Discussions

ONTAP 9.7 Rest API QuotaRule Python Libraries

kramar
1,381 Views

Trying to add a new user rule and getting the following error, what am I missing?

 

File "/usr/local/lib/python3.8/dist-packages/netapp_ontap/resource.py", line 191, in __getattribute__
raise AttributeError(
AttributeError: The 'svm' field has not been set on the QuotaRule. Try refreshing the object by calling get().

 

Here is the sample code

from netapp_ontap import config
from netapp_ontap import HostConnection
from netapp_ontap.resources import QuotaRule

 

with HostConnection("192.168.112.80", username="admin", password="****", verify=False):
resource = QuotaRule()
resource.svm.name = "svm0"
resource.volume.name = "NFS2"
resource.type = "user"
resource.users = [{"name": "fred2"}]
resource.qtree.name = "qt1"
resource.user_mapping = "off"
resource.space.hard_limit = 8192
resource.space.soft_limit = 1024
resource.files.hard_limit = 20
resource.files.soft_limit = 10
resource.post(hydrate=True)
print(resource)

0 REPLIES 0
Public