Fixes create rbd volume from image v1 glance api
The RBD driver supports two methods of image cloning; thin copy i.e. copy-on-write (requires v2 Glance API) and full copy (default if v2 Glance API is not available). clone_image() was failing in the Glance V1 API case because it was not returning a tuple, as expected by the volume manager. Glance V2 support works fine. Fixes: bug #1208617 Change-Id: I2e8605eaacfe8b65bdf47cb6ea40ef62d6f6b895
This commit is contained in:
parent
18e4ea29ed
commit
0f11f016c5
@ -515,24 +515,40 @@ class ManagedRBDTestCase(DriverTestCase):
|
|||||||
# cleanup
|
# cleanup
|
||||||
db.volume_destroy(self.context, volume_id)
|
db.volume_destroy(self.context, volume_id)
|
||||||
|
|
||||||
def test_clone_image_status_available(self):
|
def test_create_vol_from_image_status_available(self):
|
||||||
"""Verify that before cloning, an image is in the available state."""
|
"""Verify that before cloning, an image is in the available state."""
|
||||||
self._clone_volume_from_image('available', True)
|
self._clone_volume_from_image('available', True)
|
||||||
|
|
||||||
def test_clone_image_status_error(self):
|
def test_create_vol_from_image_status_error(self):
|
||||||
"""Verify that before cloning, an image is in the available state."""
|
"""Verify that before cloning, an image is in the available state."""
|
||||||
self._clone_volume_from_image('error', False)
|
self._clone_volume_from_image('error', False)
|
||||||
|
|
||||||
|
def test_clone_image(self):
|
||||||
|
# Test Failure Case(s)
|
||||||
|
expected = ({}, False)
|
||||||
|
|
||||||
|
self.stubs.Set(self.volume.driver, '_is_cloneable', lambda x: False)
|
||||||
|
self.assertEquals(expected,
|
||||||
|
self.volume.driver.clone_image(object(), object()))
|
||||||
|
|
||||||
|
self.stubs.Set(self.volume.driver, '_is_cloneable', lambda x: True)
|
||||||
|
self.assertEquals(expected,
|
||||||
|
self.volume.driver.clone_image(object(), None))
|
||||||
|
|
||||||
|
# Test Success Case(s)
|
||||||
|
expected = ({'provider_location': None}, True)
|
||||||
|
|
||||||
|
self.stubs.Set(self.volume.driver, '_parse_location',
|
||||||
|
lambda x: ('a', 'b', 'c', 'd'))
|
||||||
|
|
||||||
|
self.stubs.Set(self.volume.driver, '_clone', lambda *args: None)
|
||||||
|
self.stubs.Set(self.volume.driver, '_resize', lambda *args: None)
|
||||||
|
|
||||||
|
self.assertEquals(expected,
|
||||||
|
self.volume.driver.clone_image(object(), object()))
|
||||||
|
|
||||||
def test_clone_success(self):
|
def test_clone_success(self):
|
||||||
self.stubs.Set(self.volume.driver, '_is_cloneable', lambda x: True)
|
self.stubs.Set(self.volume.driver, '_is_cloneable', lambda x: True)
|
||||||
self.stubs.Set(self.volume.driver, 'clone_image', lambda a, b: True)
|
self.stubs.Set(self.volume.driver, 'clone_image', lambda a, b: True)
|
||||||
image_id = 'c905cedb-7281-47e4-8a62-f26bc5fc4c77'
|
image_id = 'c905cedb-7281-47e4-8a62-f26bc5fc4c77'
|
||||||
self.assertTrue(self.volume.driver.clone_image({}, image_id))
|
self.assertTrue(self.volume.driver.clone_image({}, image_id))
|
||||||
|
|
||||||
def test_clone_bad_image_id(self):
|
|
||||||
self.stubs.Set(self.volume.driver, '_is_cloneable', lambda x: True)
|
|
||||||
self.assertFalse(self.volume.driver.clone_image({}, None))
|
|
||||||
|
|
||||||
def test_clone_uncloneable(self):
|
|
||||||
self.stubs.Set(self.volume.driver, '_is_cloneable', lambda x: False)
|
|
||||||
self.assertFalse(self.volume.driver.clone_image({}, 'dne'))
|
|
||||||
|
@ -521,8 +521,8 @@ class RBDDriver(driver.VolumeDriver):
|
|||||||
|
|
||||||
def clone_image(self, volume, image_location):
|
def clone_image(self, volume, image_location):
|
||||||
if image_location is None or not self._is_cloneable(image_location):
|
if image_location is None or not self._is_cloneable(image_location):
|
||||||
return False
|
return ({}, False)
|
||||||
_, pool, image, snapshot = self._parse_location(image_location)
|
prefix, pool, image, snapshot = self._parse_location(image_location)
|
||||||
self._clone(volume, pool, image, snapshot)
|
self._clone(volume, pool, image, snapshot)
|
||||||
self._resize(volume)
|
self._resize(volume)
|
||||||
return {'provider_location': None}, True
|
return {'provider_location': None}, True
|
||||||
|
Loading…
Reference in New Issue
Block a user