Skip to content

Commit

Permalink
pylxd: Use latest snapshot name if necessary
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Jul 5, 2024
1 parent 6412320 commit 5694ecb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pylxd/models/storage_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,12 @@ def create(cls, volume, name=None, expires_at=None):

# Extract the snapshot name from the response JSON in case it was not provided
if not name:
name = operation.resources["storage_volume_snapshots"][0].split("/")[-1]
name = operation.resources.get("storage_volume_snapshots")
if name is not None:
name = name[0].split("/")[-1]
else:
# If using LXD 4.0, the snapshot name isn't provided on the request response, so grab the latest snapshot name instead.
name = volume.snapshots.all()[-1].split("/")[-1]

snapshot = volume.snapshots.get(name)
return snapshot
Expand Down

0 comments on commit 5694ecb

Please sign in to comment.