Python Discussions

How to pull the snapshot size using PYTHON

SuneelT
2,780 Views

Team,

 

I need to pull the size of the snapshot of a specific volume.

============ code ==========================================

##S1 and V1 are Snapshot and Volume objects  which are already initialized before the below code. 

S11=Snapshot.from_dict({'uuid':S1.uuid,'volume.uuid': V1.uuid})
S11.get()
print ("final snap==================")
print (S11)
print ("final snap==================")

==========================================================

 

Returns the below:

**********************************************************************************************************

final snap==================
Snapshot({'volume': {'uuid': '0207959e-b04b-11ea-b611-d039ea073d7a', '_links': {'self': {'href': '/api/storage/volumes/0207959e-b04b-11ea-b611-d039ea073d7a'}}, 'name': 'XXXXXX'}, 'name': 'weekly.2021-02-07_0015', 'create_time': '2021-02-07T00:15:01+00:00', '_links': {'self': {'href': '/api/storage/volumes/0207959e-b04b-11ea-b611-d039ea073d7a/snapshots/15891d63-214a-4e7b-86da-942612280b39'}}, 'svm': {'uuid': '01a0b7f6-b04b-11ea-b611-d039ea073d7a', '_links': {'self': {'href': '/api/svm/svms/01a0b7f6-b04b-11ea-b611-d039ea073d7a'}}, 'name': 'XXXXX'}, 'uuid': '15891d63-214a-4e7b-86da-942612280b39'})
final snap==================

 

I am not able to get the size of the snapshot but getting all other details [ like name, creation_time etc].

Appreciate your help.

 

Thanks

Suneel

 

Appreciate if you 

 

1 ACCEPTED SOLUTION

RobertBlackhart
2,719 Views

The size property is not present in the 9.8 or prior versions of the API. It may come in a later release.

 

One thing you can do as a workaround is to use the CLI passthrough to get the information. Here's an example:

 

from netapp_ontap.resources import CLI

response = CLI().execute("snapshot show", snapshot=S1.name, volume=V1.name)
snapshot_size = response.http_response.json()["records"][0]["size"]

View solution in original post

3 REPLIES 3

RobertBlackhart
2,720 Views

The size property is not present in the 9.8 or prior versions of the API. It may come in a later release.

 

One thing you can do as a workaround is to use the CLI passthrough to get the information. Here's an example:

 

from netapp_ontap.resources import CLI

response = CLI().execute("snapshot show", snapshot=S1.name, volume=V1.name)
snapshot_size = response.http_response.json()["records"][0]["size"]

SuneelT
2,715 Views

Thank you for the workaround, I will test it.

Atleast I now know that this is not available in current python modules, I have been trying different options 🙂 

ABisht
168 Views

hey is this feature available now? I am lookng to get snapshot size via API. Please advice

Public