Skip to content

Commit

Permalink
pylxd/models: 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 8, 2024
1 parent a568629 commit 60f89a3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pylxd/models/storage_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,11 @@ 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]
if "storage_volume_snapshots" in operation.resources:
name = operation.resources["storage_volume_snapshots"][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 60f89a3

Please sign in to comment.