Merge "Sheepdog: Fix malformed image url format"
This commit is contained in:
commit
4856d5acbc
@ -1248,8 +1248,8 @@ class SheepdogDriverTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_clone_image_success(self):
|
def test_clone_image_success(self):
|
||||||
context = {}
|
context = {}
|
||||||
image_location = ('sheepdog:192.168.1.111:7000:Alice', None)
|
|
||||||
image_id = "caa4ffd0-fake-fake-fake-f8631a807f5a"
|
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_meta = {'id': image_id, 'size': 1, 'disk_format': 'raw'}
|
||||||
image_service = ''
|
image_service = ''
|
||||||
|
|
||||||
@ -1283,7 +1283,7 @@ class SheepdogDriverTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_is_cloneable(self):
|
def test_is_cloneable(self):
|
||||||
uuid = '87f1b01c-f46c-4537-bd5d-23962f5f4316'
|
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'}
|
image_meta = {'id': uuid, 'size': 1, 'disk_format': 'raw'}
|
||||||
invalid_image_meta = {'id': uuid, 'size': 1, 'disk_format': 'iso'}
|
invalid_image_meta = {'id': uuid, 'size': 1, 'disk_format': 'iso'}
|
||||||
|
|
||||||
|
@ -427,7 +427,8 @@ class SheepdogDriver(driver.VolumeDriver):
|
|||||||
if image_location is None:
|
if image_location is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not image_location.startswith("sheepdog:"):
|
prefix = 'sheepdog://'
|
||||||
|
if not image_location.startswith(prefix):
|
||||||
LOG.debug("Image is not stored in sheepdog.")
|
LOG.debug("Image is not stored in sheepdog.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -443,8 +444,8 @@ class SheepdogDriver(driver.VolumeDriver):
|
|||||||
# check whether volume is stored in sheepdog
|
# check whether volume is stored in sheepdog
|
||||||
try:
|
try:
|
||||||
# The image location would be like
|
# The image location would be like
|
||||||
# "sheepdog:192.168.10.2:7000:Alice"
|
# "sheepdog://192.168.10.2:7000:Alice"
|
||||||
(label, ip, port, name) = image_location.split(":", 3)
|
(ip, port, name) = image_location[len(prefix):].split(":", 2)
|
||||||
|
|
||||||
self._try_execute('collie', 'vdi', 'list', '--address', ip,
|
self._try_execute('collie', 'vdi', 'list', '--address', ip,
|
||||||
'--port', port, name)
|
'--port', port, name)
|
||||||
@ -463,10 +464,7 @@ class SheepdogDriver(driver.VolumeDriver):
|
|||||||
if not self._is_cloneable(image_location, image_meta):
|
if not self._is_cloneable(image_location, image_meta):
|
||||||
return {}, False
|
return {}, False
|
||||||
|
|
||||||
# The image location would be like
|
volume_ref = {'name': image_meta['id'], 'size': image_meta['size']}
|
||||||
# "sheepdog:192.168.10.2:7000:Alice"
|
|
||||||
(label, ip, port, name) = image_location.split(":", 3)
|
|
||||||
volume_ref = {'name': name, 'size': image_meta['size']}
|
|
||||||
self.create_cloned_volume(volume, volume_ref)
|
self.create_cloned_volume(volume, volume_ref)
|
||||||
self.client.resize(volume.name, volume.size)
|
self.client.resize(volume.name, volume.size)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user