INFINIDAT: support for volume compression

InfiniBox v3.0 introduced volume compression
on the storage array side. This change provides
a new configuration option to control whether
to create new volumes with compression enabled
or not.

Change-Id: Ia214fc45d960dada8e863ed2ca06be533048f410
Implements: blueprint infinidat-compression
This commit is contained in:
Arnon Yaari 2017-05-22 17:30:09 +03:00
parent 400f827e75
commit ec55bc239c
3 changed files with 54 additions and 5 deletions

View File

@ -59,6 +59,7 @@ class InfiniboxDriverTestCaseBase(test.TestCase):
self.configuration.san_is_local = False
self.configuration.chap_username = None
self.configuration.chap_password = None
self.configuration.infinidat_use_compression = None
self.driver = infinidat.InfiniboxVolumeDriver(
configuration=self.configuration)
@ -208,6 +209,31 @@ class InfiniboxDriverTestCase(InfiniboxDriverTestCaseBase):
self.driver.create_volume(test_volume)
self._mock_volume.set_metadata_from_dict.assert_called_once()
@mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs")
def test_create_volume_compression_enabled(self, *mocks):
self.configuration.infinidat_use_compression = True
self.driver.create_volume(test_volume)
self.assertTrue(
self._system.volumes.create.call_args[1]["compression_enabled"]
)
@mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs")
def test_create_volume_compression_not_enabled(self, *mocks):
self.configuration.infinidat_use_compression = False
self.driver.create_volume(test_volume)
self.assertFalse(
self._system.volumes.create.call_args[1]["compression_enabled"]
)
@mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs")
def test_create_volume_compression_not_available(self, *mocks):
self._system.compat.has_compression.return_value = False
self.driver.create_volume(test_volume)
self.assertNotIn(
"compression_enabled",
self._system.volumes.create.call_args[1]
)
def test_delete_volume(self):
self.driver.delete_volume(test_volume)

View File

@ -76,6 +76,10 @@ infinidat_opts = [
default=[],
help='List of names of network spaces to use for iSCSI '
'connectivity'),
cfg.BoolOpt('infinidat_use_compression',
default=False,
help='Specifies whether to turn on compression for newly '
'created volumes.'),
]
CONF = cfg.CONF
@ -97,7 +101,7 @@ def infinisdk_to_cinder_exceptions(func):
@interface.volumedriver
class InfiniboxVolumeDriver(san.SanISCSIDriver):
VERSION = '1.4'
VERSION = '1.5'
# ThirdPartySystems wiki page
CI_WIKI_NAME = "INFINIDAT_Cinder_CI"
@ -128,6 +132,15 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver):
raise exception.VolumeDriverException(message=msg)
else:
self._protocol = 'FC'
if (self.configuration.infinidat_use_compression and
not self._system.compat.has_compression()):
# InfiniBox systems support compression only from v3.0 and up
msg = _('InfiniBox system does not support volume compression.\n'
'Compression is available on InfiniBox 3.0 onward.\n'
'Please disable volume compression by setting '
'infinidat_use_compression to False in the Cinder '
'configuration file.')
raise exception.VolumeDriverException(message=msg)
LOG.debug('setup complete')
def _make_volume_name(self, cinder_volume):
@ -429,10 +442,14 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver):
volume_name = self._make_volume_name(volume)
provtype = "THIN" if self.configuration.san_thin_provision else "THICK"
size = volume.size * capacity.GiB
infinidat_volume = self._system.volumes.create(name=volume_name,
pool=pool,
provtype=provtype,
size=size)
create_kwargs = dict(name=volume_name,
pool=pool,
provtype=provtype,
size=size)
if self._system.compat.has_compression():
create_kwargs["compression_enabled"] = (
self.configuration.infinidat_use_compression)
infinidat_volume = self._system.volumes.create(**create_kwargs)
self._set_qos(volume, infinidat_volume)
self._set_cinder_object_metadata(infinidat_volume, volume)
return infinidat_volume

View File

@ -0,0 +1,6 @@
---
features:
- Added support for volume compression in INFINIDAT driver.
Compression is available on InfiniBox 3.0 onward.
To enable volume compression, set ``infinidat_use_compression`` to
True in the backend section in the Cinder configuration file.