Merge "Huawei driver supports specifying copy speed"
This commit is contained in:
commit
47346facdd
@ -2203,6 +2203,7 @@ class FakeFCStorage(huawei_driver.HuaweiFCDriver):
|
|||||||
self.configuration)
|
self.configuration)
|
||||||
|
|
||||||
|
|
||||||
|
@ddt.ddt
|
||||||
class HuaweiTestBase(test.TestCase):
|
class HuaweiTestBase(test.TestCase):
|
||||||
"""Base class for Huawei test cases.
|
"""Base class for Huawei test cases.
|
||||||
|
|
||||||
@ -2264,6 +2265,55 @@ class HuaweiTestBase(test.TestCase):
|
|||||||
lun_info = self.driver.create_snapshot(self.snapshot)
|
lun_info = self.driver.create_snapshot(self.snapshot)
|
||||||
self.assertEqual(11, lun_info['provider_location'])
|
self.assertEqual(11, lun_info['provider_location'])
|
||||||
|
|
||||||
|
@ddt.data('1', '', '0')
|
||||||
|
def test_copy_volume(self, input_speed):
|
||||||
|
self.driver.configuration.lun_copy_wait_interval = 0
|
||||||
|
self.volume.metadata = {'copyspeed': input_speed}
|
||||||
|
|
||||||
|
mocker = self.mock_object(
|
||||||
|
self.driver.client, 'create_luncopy',
|
||||||
|
mock.Mock(wraps=self.driver.client.create_luncopy))
|
||||||
|
|
||||||
|
self.driver._copy_volume(self.volume,
|
||||||
|
'fake_copy_name',
|
||||||
|
'fake_src_lun',
|
||||||
|
'fake_tgt_lun')
|
||||||
|
|
||||||
|
mocker.assert_called_once_with('fake_copy_name',
|
||||||
|
'fake_src_lun',
|
||||||
|
'fake_tgt_lun',
|
||||||
|
input_speed)
|
||||||
|
|
||||||
|
@ddt.data({'input_speed': '1',
|
||||||
|
'actual_speed': '1'},
|
||||||
|
{'input_speed': '',
|
||||||
|
'actual_speed': '2'},
|
||||||
|
{'input_speed': None,
|
||||||
|
'actual_speed': '2'},
|
||||||
|
{'input_speed': '5',
|
||||||
|
'actual_speed': '2'})
|
||||||
|
@ddt.unpack
|
||||||
|
def test_client_create_luncopy(self, input_speed, actual_speed):
|
||||||
|
mocker = self.mock_object(
|
||||||
|
self.driver.client, 'call',
|
||||||
|
mock.Mock(wraps=self.driver.client.call))
|
||||||
|
|
||||||
|
self.driver.client.create_luncopy('fake_copy_name',
|
||||||
|
'fake_src_lun',
|
||||||
|
'fake_tgt_lun',
|
||||||
|
input_speed)
|
||||||
|
|
||||||
|
mocker.assert_called_once_with(
|
||||||
|
mock.ANY,
|
||||||
|
{"TYPE": 219,
|
||||||
|
"NAME": 'fake_copy_name',
|
||||||
|
"DESCRIPTION": 'fake_copy_name',
|
||||||
|
"COPYSPEED": actual_speed,
|
||||||
|
"LUNCOPYTYPE": "1",
|
||||||
|
"SOURCELUN": "INVALID;fake_src_lun;INVALID;INVALID;INVALID",
|
||||||
|
"TARGETLUN": "INVALID;fake_tgt_lun;INVALID;INVALID;INVALID"}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@ddt.ddt
|
@ddt.ddt
|
||||||
class HuaweiISCSIDriverTestCase(HuaweiTestBase):
|
class HuaweiISCSIDriverTestCase(HuaweiTestBase):
|
||||||
|
@ -114,3 +114,10 @@ REPLICA_DATA_STATUS_INCOMPLETE = '3'
|
|||||||
|
|
||||||
VOLUME_NOT_EXISTS_WARN = 'warning'
|
VOLUME_NOT_EXISTS_WARN = 'warning'
|
||||||
VOLUME_NOT_EXISTS_RAISE = 'raise'
|
VOLUME_NOT_EXISTS_RAISE = 'raise'
|
||||||
|
|
||||||
|
LUN_COPY_SPEED_TYPES = (
|
||||||
|
LUN_COPY_SPEED_LOW,
|
||||||
|
LUN_COPY_SPEED_MEDIUM,
|
||||||
|
LUN_COPY_SPEED_HIGH,
|
||||||
|
LUN_COPY_SPEED_HIGHEST
|
||||||
|
) = ('1', '2', '3', '4')
|
||||||
|
@ -1263,9 +1263,12 @@ class HuaweiBaseDriver(driver.VolumeDriver):
|
|||||||
return self.configuration.safe_get("backup_use_temp_snapshot")
|
return self.configuration.safe_get("backup_use_temp_snapshot")
|
||||||
|
|
||||||
def _copy_volume(self, volume, copy_name, src_lun, tgt_lun):
|
def _copy_volume(self, volume, copy_name, src_lun, tgt_lun):
|
||||||
|
metadata = huawei_utils.get_volume_metadata(volume)
|
||||||
|
copyspeed = metadata.get('copyspeed')
|
||||||
luncopy_id = self.client.create_luncopy(copy_name,
|
luncopy_id = self.client.create_luncopy(copy_name,
|
||||||
src_lun,
|
src_lun,
|
||||||
tgt_lun)
|
tgt_lun,
|
||||||
|
copyspeed)
|
||||||
wait_interval = self.configuration.lun_copy_wait_interval
|
wait_interval = self.configuration.lun_copy_wait_interval
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -370,13 +370,20 @@ class RestClient(object):
|
|||||||
|
|
||||||
return self._get_id_from_result(result, name, 'NAME')
|
return self._get_id_from_result(result, name, 'NAME')
|
||||||
|
|
||||||
def create_luncopy(self, luncopyname, srclunid, tgtlunid):
|
def create_luncopy(self, luncopyname, srclunid, tgtlunid, copyspeed):
|
||||||
"""Create a luncopy."""
|
"""Create a luncopy."""
|
||||||
url = "/luncopy"
|
url = "/luncopy"
|
||||||
|
if copyspeed not in constants.LUN_COPY_SPEED_TYPES:
|
||||||
|
LOG.warning(_LW('The copy speed %(copyspeed)s is not valid, '
|
||||||
|
'using default value %(default)s instead.'),
|
||||||
|
{'copyspeed': copyspeed,
|
||||||
|
'default': constants.LUN_COPY_SPEED_MEDIUM})
|
||||||
|
copyspeed = constants.LUN_COPY_SPEED_MEDIUM
|
||||||
|
|
||||||
data = {"TYPE": 219,
|
data = {"TYPE": 219,
|
||||||
"NAME": luncopyname,
|
"NAME": luncopyname,
|
||||||
"DESCRIPTION": luncopyname,
|
"DESCRIPTION": luncopyname,
|
||||||
"COPYSPEED": 2,
|
"COPYSPEED": copyspeed,
|
||||||
"LUNCOPYTYPE": "1",
|
"LUNCOPYTYPE": "1",
|
||||||
"SOURCELUN": ("INVALID;%s;INVALID;INVALID;INVALID"
|
"SOURCELUN": ("INVALID;%s;INVALID;INVALID;INVALID"
|
||||||
% srclunid),
|
% srclunid),
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Allow users to specify the copy speed while using Huawei
|
||||||
|
driver to create volume from snapshot or clone volume, by
|
||||||
|
the new added metadata 'copyspeed'.
|
||||||
|
For example, user can add --metadata copyspeed=1 when
|
||||||
|
creating volume from source volume/snapshot.
|
||||||
|
The valid optional range of copyspeed is [1, 2, 3, 4],
|
||||||
|
respectively representing LOW, MEDIUM, HIGH and HIGHEST.
|
Loading…
Reference in New Issue
Block a user