Snapshots

Creating Snapshots

Use the create_child()

>>> snap = volume.create_child()
>>> snap.id
1008
>>> snap_of_snap = snap.create_child()
>>> snap_of_snap.id
1009

Creating Group Snapshots

You can create a group of snapshots (not to be confused with Consistency Groups) using create_group_snapshot():

>>> v1, v2, v3 = volumes = [system.volumes.create(pool=pool) for i in range(3)]
>>> s1, s2, s3 = system.volumes.create_group_snapshot(volumes)

Querying Snapshots

The parent of a snapshot is accessed through the snap.get_parent/vol.get_parent method:

>>> snap.get_parent() == volume
True

>>> volume.get_parent() is None
True

You can inspect the snapshot’s creation time:

>>> creation_time = snap.get_creation_time()
>>> delta = current_time - creation_time
>>> delta.days
15

Note

Time is represented in InfiniSDK with Arrow objects. See the relevant documentation for more details on how to use and manipulate these values.

Example: Deleting Snapshots by Creation Time

>>> cutoff = current_time.replace(days=-10)
>>> for snapshot in system.volumes.find(system.volumes.fields.created_at < cutoff, parent_id=volume.id):
...     print("Deleting snapshot with id:", snapshot.id)
...     snapshot.delete()
Deleting snapshot with id: 1008