瀏覽代碼

Make sure a volume was created from a snapshot before trying to retrieve the snapshot

Enis Afgan 10 年之前
父節點
當前提交
b8e20d563c
共有 2 個文件被更改,包括 8 次插入4 次删除
  1. 4 2
      cloudbridge/cloud/providers/aws/resources.py
  2. 4 2
      cloudbridge/cloud/providers/openstack/resources.py

+ 4 - 2
cloudbridge/cloud/providers/aws/resources.py

@@ -410,8 +410,10 @@ class AWSVolume(BaseVolume):
 
     @property
     def source(self):
-        return self._provider.block_store.snapshots.get(
-            self._volume.snapshot_id)
+        if self._volume.snapshot_id:
+            return self._provider.block_store.snapshots.get(
+                self._volume.snapshot_id)
+        return None
 
     @property
     def attachments(self):

+ 4 - 2
cloudbridge/cloud/providers/openstack/resources.py

@@ -463,8 +463,10 @@ class OpenStackVolume(BaseVolume):
 
     @property
     def source(self):
-        return self._provider.block_store.snapshots.get(
-            self._volume.snapshot_id)
+        if self._volume.snapshot_id:
+            return self._provider.block_store.snapshots.get(
+                self._volume.snapshot_id)
+        return None
 
     @property
     def attachments(self):