Răsfoiți Sursa

Fix volume creation from a snapshot; add a test for it

Enis Afgan 10 ani în urmă
părinte
comite
a5e4becbd0

+ 1 - 1
cloudbridge/cloud/providers/aws/services.py

@@ -270,7 +270,7 @@ class AWSVolumeService(BaseVolumeService):
         """
         zone_id = zone.id if isinstance(zone, PlacementZone) else zone
         snapshot_id = snapshot.id if isinstance(
-            zone, AWSSnapshot) and snapshot else snapshot
+            snapshot, AWSSnapshot) and snapshot else snapshot
 
         ec2_vol = self.provider.ec2_conn.create_volume(
             size,

+ 11 - 0
test/test_block_store_service.py

@@ -192,6 +192,17 @@ class CloudBlockStoreServiceTestCase(ProviderTestBase):
                     " expected: {2}" .format(list_snaps[0].name,
                                              get_snap.name,
                                              test_snap.name))
+
+                # Create volume creation based on this snapshot
+                sv_name = "CBUnitTestSnapVol-{0}".format(uuid.uuid4())
+                snap_vol = self.provider.block_store.volumes.create(
+                    sv_name,
+                    1,
+                    helpers.get_provider_test_data(self.provider, "placement"),
+                    snapshot=test_snap)
+                with helpers.cleanup_action(lambda: snap_vol.delete()):
+                    snap_vol.wait_till_ready()
+
             snaps = self.provider.block_store.snapshots.list()
             found_snaps = [snap for snap in snaps
                            if snap.name == snap_name]