Add retype method to xiv/ds8k driver interface.
Change-Id: I1389a3391a17c80e47aad1ed3e7209ec47333e41
This commit is contained in:
parent
9bddf33f9f
commit
7eefc6ea2e
cinder
@ -24,11 +24,13 @@ import copy
|
||||
import mox
|
||||
from oslo.config import cfg
|
||||
|
||||
from cinder import context
|
||||
from cinder import exception
|
||||
from cinder.i18n import _
|
||||
from cinder import test
|
||||
from cinder.volume import configuration as conf
|
||||
from cinder.volume.drivers.ibm import xiv_ds8k
|
||||
from cinder.volume import volume_types
|
||||
|
||||
|
||||
FAKE = "fake"
|
||||
@ -166,6 +168,10 @@ class XIVDS8KFakeProxyDriver(object):
|
||||
reason="Target and source volumes have different size.")
|
||||
return
|
||||
|
||||
def retype(self, ctxt, volume, new_type, diff, host):
|
||||
volume['easytier'] = new_type['extra_specs']['easytier']
|
||||
return True, volume
|
||||
|
||||
|
||||
class XIVDS8KVolumeDriverTest(test.TestCase):
|
||||
"""Test IBM XIV and DS8K volume driver."""
|
||||
@ -480,3 +486,80 @@ class XIVDS8KVolumeDriverTest(test.TestCase):
|
||||
tgt_volume,
|
||||
src_volume
|
||||
)
|
||||
|
||||
def test_retype(self):
|
||||
"""Test that retype returns successfully."""
|
||||
|
||||
self.driver.do_setup(None)
|
||||
|
||||
# prepare parameters
|
||||
ctxt = context.get_admin_context()
|
||||
|
||||
host = {
|
||||
'host': 'foo',
|
||||
'capabilities': {
|
||||
'location_info': 'xiv_ds8k_fake_1',
|
||||
'extent_size': '1024'
|
||||
}
|
||||
}
|
||||
|
||||
key_specs_old = {'easytier': False, 'warning': 2, 'autoexpand': True}
|
||||
key_specs_new = {'easytier': True, 'warning': 5, 'autoexpand': False}
|
||||
old_type_ref = volume_types.create(ctxt, 'old', key_specs_old)
|
||||
new_type_ref = volume_types.create(ctxt, 'new', key_specs_new)
|
||||
|
||||
diff, equal = volume_types.volume_types_diff(
|
||||
ctxt,
|
||||
old_type_ref['id'],
|
||||
new_type_ref['id'],
|
||||
)
|
||||
|
||||
volume = copy.deepcopy(VOLUME)
|
||||
old_type = volume_types.get_volume_type(ctxt, old_type_ref['id'])
|
||||
volume['volume_type'] = old_type
|
||||
volume['host'] = host
|
||||
new_type = volume_types.get_volume_type(ctxt, new_type_ref['id'])
|
||||
|
||||
self.driver.create_volume(volume)
|
||||
ret = self.driver.retype(ctxt, volume, new_type, diff, host)
|
||||
self.assertTrue(ret)
|
||||
self.assertTrue(volume['easytier'])
|
||||
|
||||
def test_retype_fail_on_exception(self):
|
||||
"""Test that retype fails on exception."""
|
||||
|
||||
self.driver.do_setup(None)
|
||||
|
||||
# prepare parameters
|
||||
ctxt = context.get_admin_context()
|
||||
|
||||
host = {
|
||||
'host': 'foo',
|
||||
'capabilities': {
|
||||
'location_info': 'xiv_ds8k_fake_1',
|
||||
'extent_size': '1024'
|
||||
}
|
||||
}
|
||||
|
||||
key_specs_old = {'easytier': False, 'warning': 2, 'autoexpand': True}
|
||||
old_type_ref = volume_types.create(ctxt, 'old', key_specs_old)
|
||||
new_type_ref = volume_types.create(ctxt, 'new')
|
||||
|
||||
diff, equal = volume_types.volume_types_diff(
|
||||
ctxt,
|
||||
old_type_ref['id'],
|
||||
new_type_ref['id'],
|
||||
)
|
||||
|
||||
volume = copy.deepcopy(VOLUME)
|
||||
old_type = volume_types.get_volume_type(ctxt, old_type_ref['id'])
|
||||
volume['volume_type'] = old_type
|
||||
volume['host'] = host
|
||||
new_type = volume_types.get_volume_type(ctxt, new_type_ref['id'])
|
||||
|
||||
self.driver.create_volume(volume)
|
||||
self.assertRaises(
|
||||
KeyError,
|
||||
self.driver.retype,
|
||||
ctxt, volume, new_type, diff, host
|
||||
)
|
||||
|
@ -221,3 +221,8 @@ class XIVDS8KDriver(san.SanDriver):
|
||||
"""Creates a test replica clone of the specified replicated volume."""
|
||||
|
||||
return self.xiv_ds8k_proxy.create_replica_test_volume(volume, src_vref)
|
||||
|
||||
def retype(self, ctxt, volume, new_type, diff, host):
|
||||
"""Convert the volume to be of the new type."""
|
||||
|
||||
return self.xiv_ds8k_proxy.retype(ctxt, volume, new_type, diff, host)
|
||||
|
Loading…
x
Reference in New Issue
Block a user