Improve logic for volume snapshots tab
This makes the logic around retrieving volume data in the volume
snapshot page slightly safer. Previously, if the snapshots loaded but
volume didn't a NameError could occur, and the error message would have
been incorrect. This patch fixes both of those issues.
Related-Bug:
@@ -42,13 +42,21 @@ class SnapshotTab(tabs.TableTab):
try:
snapshots = cinder.volume_snapshot_list(
self.request, search_opts={'volume_id': volume_id})
- volume = cinder.volume_get(self.request, volume_id)
except Exception:
snapshots = []
exceptions.handle(self.request,
_("Unable to retrieve volume snapshots for "
"volume %s.") % volume_id)
+ try:
+ volume = cinder.volume_get(self.request, volume_id)
+ except Exception:
+ volume = None
+ exceptions.handle(self.request,
+ _("Unable to retrieve volume details for "
+ "volume %s.") % volume_id)
+
+ if volume is not None:
for snapshot in snapshots:
snapshot._volume = volume
