]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Sheepdog: Fix malformed image url format
authorYAMADA Hideki <yamada.hideki@lab.ntt.co.jp>
Mon, 15 Feb 2016 08:49:45 +0000 (08:49 +0000)
committerYAMADA Hideki <yamada.hideki@lab.ntt.co.jp>
Mon, 15 Feb 2016 09:04:49 +0000 (09:04 +0000)
The image url format is defined in glance_store as
"sheepdog://addr:port:image".

Change-Id: I71f3e4bf75dd6fdfd77ab8bf2afcd43e0eba2d44
Closes-Bug: 1545603
Signed-off-by: YAMADA Hideki <yamada.hideki@lab.ntt.co.jp>
cinder/tests/unit/test_sheepdog.py
cinder/volume/drivers/sheepdog.py

index 0cb33f502cdce94a8d3517b410da7859ee9af82b..81419e05340b532291dae23f646e60d9b9fa5c84 100644 (file)
@@ -1248,8 +1248,8 @@ class SheepdogDriverTestCase(test.TestCase):
 
     def test_clone_image_success(self):
         context = {}
-        image_location = ('sheepdog:192.168.1.111:7000:Alice', None)
         image_id = "caa4ffd0-fake-fake-fake-f8631a807f5a"
+        image_location = ('sheepdog://192.168.1.111:7000:%s' % image_id, None)
         image_meta = {'id': image_id, 'size': 1, 'disk_format': 'raw'}
         image_service = ''
 
@@ -1283,7 +1283,7 @@ class SheepdogDriverTestCase(test.TestCase):
 
     def test_is_cloneable(self):
         uuid = '87f1b01c-f46c-4537-bd5d-23962f5f4316'
-        location = 'sheepdog:ip:port:%s' % uuid
+        location = 'sheepdog://ip:port:%s' % uuid
         image_meta = {'id': uuid, 'size': 1, 'disk_format': 'raw'}
         invalid_image_meta = {'id': uuid, 'size': 1, 'disk_format': 'iso'}
 
index 2a5d23a0d8cd3ec0755c22a1987160b12448ad14..51529ca750474b2aa22d81f506bade1640387ea9 100644 (file)
@@ -427,7 +427,8 @@ class SheepdogDriver(driver.VolumeDriver):
         if image_location is None:
             return False
 
-        if not image_location.startswith("sheepdog:"):
+        prefix = 'sheepdog://'
+        if not image_location.startswith(prefix):
             LOG.debug("Image is not stored in sheepdog.")
             return False
 
@@ -443,8 +444,8 @@ class SheepdogDriver(driver.VolumeDriver):
         # check whether volume is stored in sheepdog
         try:
             # The image location would be like
-            # "sheepdog:192.168.10.2:7000:Alice"
-            (label, ip, port, name) = image_location.split(":", 3)
+            # "sheepdog://192.168.10.2:7000:Alice"
+            (ip, port, name) = image_location[len(prefix):].split(":", 2)
 
             self._try_execute('collie', 'vdi', 'list', '--address', ip,
                               '--port', port, name)
@@ -463,10 +464,7 @@ class SheepdogDriver(driver.VolumeDriver):
         if not self._is_cloneable(image_location, image_meta):
             return {}, False
 
-        # The image location would be like
-        # "sheepdog:192.168.10.2:7000:Alice"
-        (label, ip, port, name) = image_location.split(":", 3)
-        volume_ref = {'name': name, 'size': image_meta['size']}
+        volume_ref = {'name': image_meta['id'], 'size': image_meta['size']}
         self.create_cloned_volume(volume, volume_ref)
         self.client.resize(volume.name, volume.size)