ONTAP Discussions

Cannot print Volume size (netapp ontap REST API )

technologieservices
1,151 Views

Hello

 

I'm trying to monitor our Netapp environment with the python client library.

 

When using this command:

 

 

setup_connection("hostnamex", "usernamex", "passwordx")

for volume in Volume.get_collection(fields="size"):
    print(volume)

 

 

I get the following output: 

Volume({'size': 4369924096, 'name': 'namexyz', 'uuid': 'uuidxyz', '_links': {'self': {'href': '/api/storage/volumes/uuidxyz'}}}

 

Now if I just want to print the volume name I can do the following:

 

 

for volume in Volume.get_collection(fields="size"):
    print(volume.name)

 

 

 

But when I try to do the same for the size attribute:

 

 

setup_connection("hostnamex", "usernamex", "passwordx")

for volume in Volume.get_collection(fields="size"):
    print(volume.size)

 

 

I get this error:

File "C:\python\lib\site-packages\netapp_ontap\resource.py", line 274, in __getattribute__
         raise AttributeError(
AttributeError: The 'size' field has not been set on the Volume. Try refreshing the object by calling get() or set the field 'size'.

 

Is printing the size attribute not possible, or am I doing something wrong? (I'm new to python)

 

Thanks

0 REPLIES 0
Public