From: YAMADA Hideki Date: Mon, 15 Feb 2016 08:49:45 +0000 (+0000) Subject: Sheepdog: Fix malformed image url format X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=d079faa6614e0f901caf592854df19a8e2760d5a;p=openstack-build%2Fcinder-build.git Sheepdog: Fix malformed image url format 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 --- diff --git a/cinder/tests/unit/test_sheepdog.py b/cinder/tests/unit/test_sheepdog.py index 0cb33f502..81419e053 100644 --- a/cinder/tests/unit/test_sheepdog.py +++ b/cinder/tests/unit/test_sheepdog.py @@ -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'} diff --git a/cinder/volume/drivers/sheepdog.py b/cinder/volume/drivers/sheepdog.py index 2a5d23a0d..51529ca75 100644 --- a/cinder/volume/drivers/sheepdog.py +++ b/cinder/volume/drivers/sheepdog.py @@ -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)