NetApp cDOT: Add check if copyoffload tool is available

The copyoffload tool is optional and not always in place. This fixes a
misleading error message during image clone creation when the tool is
not in place.

Change-Id: I66f28faaac629fbfa7ec57fa5238451eb7c6820a
Closes-bug: #1660927
This commit is contained in:
Marc Koderer 2017-02-01 10:49:35 +01:00
parent eb55e70a89
commit 5043f56cb6
3 changed files with 23 additions and 1 deletions

View File

@ -1262,6 +1262,22 @@ class NetAppCmodeNfsDriverTestCase(test.TestCase):
fake.VOLUME, fake.IMAGE_FILE_ID, cache_result[0])
self.driver._post_clone_image.assert_called_once_with(fake.VOLUME)
def test_copy_from_cache_workflow_remote_location_no_copyoffload(self):
cache_result = [('ip1:/openstack', fake.IMAGE_FILE_ID),
('ip2:/openstack', fake.IMAGE_FILE_ID),
('ip3:/openstack', fake.IMAGE_FILE_ID)]
self.driver._find_image_location = mock.Mock(return_value=[
cache_result[0], False])
self.driver._copy_from_remote_cache = mock.Mock()
self.driver._post_clone_image = mock.Mock()
self.driver.configuration.netapp_copyoffload_tool_path = None
copied = self.driver._copy_from_cache(
fake.VOLUME, fake.IMAGE_FILE_ID, cache_result)
self.assertFalse(copied)
self.driver._copy_from_remote_cache.assert_not_called()
def test_copy_from_cache_workflow_local_location(self):
local_share = '/share'
cache_result = [

View File

@ -522,7 +522,8 @@ class NetAppCmodeNfsDriver(nfs_base.NetAppNfsDriver,
LOG.debug("Copied image from cache to volume %s using "
"cloning.", volume['id'])
copied = True
elif cache_copy:
elif (cache_copy and
self.configuration.netapp_copyoffload_tool_path):
self._copy_from_remote_cache(volume, image_id, cache_copy)
copied = True

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixed misleading error message when NetApp copyoffload tool is not in place
during image cloning.