HPE LeftHand: extend volume if larger than snapshot
Extend volume if during create_volume_from_snapshot() the new volume is larger than the snapshot it was created from. Added new test case. Bump driver version to 2.0.11 and updated changelog entry. Closes-Bug: #1560654 The volume has not been created with OVO and a seperate patch will be created to switch the dictionary to OVO implementation regarding volume / snapshot to follow up the OVO comments. Co-Authored-By: Xinli Guan <xinli@us.ibm.com> Change-Id: Iaeb2596ecd75b86a7a0d3da7fad0bf91b2a02fa0 Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
This commit is contained in:
parent
d1b5a11325
commit
f463c395d8
|
@ -66,6 +66,15 @@ class HPELeftHandBaseDriver(object):
|
|||
'provider_auth': None,
|
||||
'size': 1}
|
||||
|
||||
volume_extend = {
|
||||
'name': volume_name,
|
||||
'display_name': 'Foo Volume',
|
||||
'provider_location': ('10.0.1.6 iqn.2003-10.com.lefthandnetworks:'
|
||||
'group01:25366:fakev 0'),
|
||||
'id': volume_id,
|
||||
'provider_auth': None,
|
||||
'size': 5}
|
||||
|
||||
volume_replicated = {
|
||||
'name': volume_name_repl,
|
||||
'display_name': 'Foo Volume',
|
||||
|
@ -115,7 +124,8 @@ class HPELeftHandBaseDriver(object):
|
|||
'name': snapshot_name,
|
||||
'display_name': 'fakesnap',
|
||||
'volume_name': volume_name,
|
||||
'volume': volume}
|
||||
'volume': volume,
|
||||
'volume_size': 1}
|
||||
|
||||
cloned_volume_name = "clone_volume"
|
||||
cloned_volume = {'name': cloned_volume_name,
|
||||
|
@ -955,6 +965,54 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
|
|||
# validate call chain
|
||||
mock_client.assert_has_calls(expected)
|
||||
|
||||
def test_create_volume_from_snapshot_extend(self):
|
||||
|
||||
# setup drive with default configuration
|
||||
# and return the mock HTTP LeftHand client
|
||||
mock_client = self.setup_driver()
|
||||
|
||||
mock_client.getSnapshotByName.return_value = {'id': self.snapshot_id}
|
||||
mock_client.getVolumeByName.return_value = {'id': self.volume_id}
|
||||
mock_client.cloneSnapshot.return_value = {
|
||||
'iscsiIqn': self.connector['initiator']}
|
||||
mock_client.getVolumes.return_value = {'total': 1, 'members': []}
|
||||
|
||||
with mock.patch.object(hpe_lefthand_iscsi.HPELeftHandISCSIDriver,
|
||||
'_create_client') as mock_do_setup:
|
||||
mock_do_setup.return_value = mock_client
|
||||
|
||||
# execute create_volume_from_snapshot
|
||||
model_update = self.driver.create_volume_from_snapshot(
|
||||
self.volume_extend, self.snapshot)
|
||||
|
||||
expected_iqn = 'iqn.1993-08.org.debian:01:222 0'
|
||||
expected_location = "10.0.1.6:3260,1 %s" % expected_iqn
|
||||
self.assertEqual(expected_location,
|
||||
model_update['provider_location'])
|
||||
|
||||
expected = self.driver_startup_call_stack + [
|
||||
mock.call.getSnapshotByName('fakeshapshot'),
|
||||
mock.call.cloneSnapshot('fakevolume', 3),
|
||||
mock.call.login('foo1', 'bar2'),
|
||||
mock.call.getClusterByName('CloudCluster1'),
|
||||
mock.call.setSSHOptions(
|
||||
HPELEFTHAND_SSH_IP,
|
||||
HPELEFTHAND_USERNAME,
|
||||
HPELEFTHAND_PASSWORD,
|
||||
missing_key_policy='AutoAddPolicy',
|
||||
privatekey=HPELEFTHAND_SAN_SSH_PRIVATE,
|
||||
known_hosts_file=mock.ANY,
|
||||
port=HPELEFTHAND_SSH_PORT,
|
||||
conn_timeout=HPELEFTHAND_SAN_SSH_CON_TIMEOUT),
|
||||
mock.call.getVolumeByName('fakevolume'),
|
||||
mock.call.modifyVolume(self.volume_id, {
|
||||
'size': self.volume_extend['size'] * units.Gi}),
|
||||
mock.call.logout(),
|
||||
mock.call.logout()]
|
||||
|
||||
# validate call chain
|
||||
mock_client.assert_has_calls(expected)
|
||||
|
||||
@mock.patch.object(volume_types, 'get_volume_type')
|
||||
def test_create_volume_from_snapshot_with_replication(
|
||||
self,
|
||||
|
|
|
@ -160,9 +160,10 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver):
|
|||
2.0.8 - Add defaults for creating a replication client, bug #1556331
|
||||
2.0.9 - Fix terminate connection on failover
|
||||
2.0.10 - Add entry point tracing
|
||||
2.0.11 - Fix extend volume if larger than snapshot bug #1560654
|
||||
"""
|
||||
|
||||
VERSION = "2.0.10"
|
||||
VERSION = "2.0.11"
|
||||
|
||||
CI_WIKI_NAME = "HPE_Storage_CI"
|
||||
|
||||
|
@ -807,6 +808,11 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver):
|
|||
volume['name'],
|
||||
snap_info['id'])
|
||||
|
||||
# Extend volume
|
||||
if volume['size'] > snapshot['volume_size']:
|
||||
LOG.debug("Resize the new volume to %s.", volume['size'])
|
||||
self.extend_volume(volume, volume['size'])
|
||||
|
||||
model_update = self._update_provider(volume_info)
|
||||
|
||||
# v2 replication check
|
||||
|
|
Loading…
Reference in New Issue