Просмотр исходного кода

Fix AzureVolume.source to read source_resource_id for snapshot copies

The integration suite showed AzureVolume.source returning None for a
volume created from a snapshot: an Azure disk copied from a snapshot
records the source in ``creation_data.source_resource_id``, not
``source_uri`` (which is only set for blob imports). Read source_resource_id
first (falling back to source_uri), so the snapshot source resolves.
Nuwan Goonasekera 1 месяц назад
Родитель
Сommit
fd82f8bd37
1 измененных файлов с 9 добавлено и 6 удалено
  1. 9 6
      cloudbridge/providers/azure/resources.py

+ 9 - 6
cloudbridge/providers/azure/resources.py

@@ -455,12 +455,15 @@ class AzureVolume(BaseVolume):
 
     @property
     def source(self) -> Snapshot | MachineImage | None:
-        # ``source_uri`` is the resource URI of the disk's source (e.g. the
-        # snapshot it was copied from); resolve it to the Snapshot object the
-        # interface promises, mirroring the AWS/OpenStack implementations.
-        source_uri = self._volume.creation_data.source_uri
-        if source_uri:
-            return self._provider.storage.snapshots.get(source_uri)
+        # A disk copied from a snapshot records the snapshot's resource id in
+        # ``source_resource_id`` (``source_uri`` is only populated for blob
+        # imports). Resolve it to the Snapshot object the interface promises,
+        # mirroring the AWS/OpenStack implementations.
+        creation_data = self._volume.creation_data
+        source_id = (creation_data.source_resource_id or
+                     creation_data.source_uri)
+        if source_id:
+            return self._provider.storage.snapshots.get(source_id)
         return None
 
     @property