diff --git a/pylxd/models/storage_pool.py b/pylxd/models/storage_pool.py index 0f0e3900..b12f427c 100644 --- a/pylxd/models/storage_pool.py +++ b/pylxd/models/storage_pool.py @@ -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