Skip to content

Commit 6279e27

Browse files
committed
Unity: Add thick volumes support
Although the change is same as https://review.openstack.org/#/c/580087, it is not easy to cherry pick directly. The above review is for Rocky and based on the change of thinclone. While the Mitaka version doesn't contain the change of thinclone. There are lots of conflicts to resolve if using cherry-pick. So I manually patch the change from above link. Change-Id: I12d426a6ac2f87e14609d297e834a0111c940cca
1 parent 860f227 commit 6279e27

5 files changed

Lines changed: 67 additions & 19 deletions

File tree

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ distributed Python package
2222
Version
2323
-------
2424

25-
0.4.5
25+
0.4.6
2626

2727
Prerequisites
2828
-------------
2929

30-
| Software | Version |
31-
|-----------|----------------|
32-
| Unity OE | 4.1.X or newer |
33-
| OpenStack | Mitaka |
34-
| storops | 0.5.5 or newer |
30+
| Software | Version |
31+
|-----------|-----------------|
32+
| Unity OE | 4.1.X or newer |
33+
| OpenStack | Mitaka |
34+
| storops | 0.5.10 or newer |
3535

3636
Supported operations
3737
--------------------
@@ -45,6 +45,7 @@ Supported operations
4545
- Migrate a volume.
4646
- Get volume statistics.
4747
- Efficient non-disruptive volume backup.
48+
- Create thick volumes.
4849

4950
Driver configuration
5051
--------------------
@@ -261,7 +262,14 @@ To enable multipath in live migration:
261262
Thin and thick provisioning
262263
---------------------------
263264
264-
Only thin volume provisioning is supported in Unity volume driver.
265+
By default, the volume created by Unity driver is thin provisioned. Run the
266+
following commands to create a thick volume.
267+
268+
```bash
269+
# openstack volume type create --property provisioning:type=thick \
270+
--property thick_provisioning_support='<is> True' thick_volume_type
271+
# openstack volume create --type thick_volume_type thick_volume
272+
```
265273

266274
QoS support
267275
-----------

cinder/tests/unit/volume/drivers/dell_emc/unity/test_adapter.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@ def get_pools():
7474
return test_client.MockResourceList(['pool0', 'pool1'])
7575

7676
@staticmethod
77-
def create_lun(name, size, pool, description=None, io_limit_policy=None):
78-
return test_client.MockResource(_id='lun_3')
77+
def create_lun(name, size, pool, description=None, io_limit_policy=None,
78+
is_thin=None):
79+
lun_id = name
80+
if is_thin is not None and not is_thin:
81+
lun_id += '_thick'
82+
return test_client.MockResource(_id=lun_id)
7983

8084
@staticmethod
8185
def get_lun(name=None, lun_id=None):
@@ -225,8 +229,17 @@ def get_connection_info(adapter, hlu, host, connector):
225229
return {}
226230

227231

232+
def get_volume_type_extra_specs(type_id):
233+
if type_id == 'thick':
234+
return {'provisioning:type': 'thick',
235+
'thick_provisioning_support': '<is> True'}
236+
return {}
237+
238+
228239
def patch_for_unity_adapter(func):
229240
@functools.wraps(func)
241+
@mock.patch('cinder.volume.volume_types.get_volume_type_extra_specs',
242+
new=get_volume_type_extra_specs)
230243
@mock.patch('cinder.volume.drivers.dell_emc.unity.utils.'
231244
'get_backend_qos_specs',
232245
new=get_backend_qos_specs)
@@ -283,6 +296,15 @@ def test_create_volume(self):
283296
expected = get_lun_pl('lun_3')
284297
self.assertEqual(expected, ret['provider_location'])
285298

299+
@patch_for_unity_adapter
300+
def test_create_volume_thick(self):
301+
volume = mock.Mock(name='lun_3', size=5, host='unity#pool1',
302+
volume_type_id='thick')
303+
ret = self.adapter.create_volume(volume)
304+
305+
expected = get_lun_pl('lun_3_thick')
306+
self.assertEqual(expected, ret['provider_location'])
307+
286308
def test_create_snapshot(self):
287309
volume = mock.Mock(provider_location='id^lun_43')
288310
snap = mock.Mock(volume=volume)
@@ -324,15 +346,15 @@ def test_get_pool_stats(self):
324346
self.assertEqual(2, stats['free_capacity_gb'])
325347
self.assertEqual(300, stats['max_over_subscription_ratio'])
326348
self.assertEqual(5, stats['reserved_percentage'])
327-
self.assertFalse(stats['thick_provisioning_support'])
349+
self.assertTrue(stats['thick_provisioning_support'])
328350
self.assertTrue(stats['thin_provisioning_support'])
329351

330352
def test_update_volume_stats(self):
331353
stats = self.adapter.update_volume_stats()
332354
self.assertEqual('backend', stats['volume_backend_name'])
333355
self.assertEqual('unknown', stats['storage_protocol'])
334356
self.assertTrue(stats['thin_provisioning_support'])
335-
self.assertFalse(stats['thick_provisioning_support'])
357+
self.assertTrue(stats['thick_provisioning_support'])
336358
self.assertEqual(1, len(stats['pools']))
337359

338360
def test_serial_number(self):

cinder/tests/unit/volume/drivers/dell_emc/unity/test_client.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __init__(self, name=None, _id=None):
4747
self.max_kbps = None
4848
self.pool_name = 'Pool0'
4949
self.host_cache = []
50+
self.is_thin = None
5051

5152
@property
5253
def id(self):
@@ -103,13 +104,16 @@ def get_hlu(self, lun):
103104
return self.alu_hlu_map.get(lun.get_id(), None)
104105

105106
@staticmethod
106-
def create_lun(lun_name, size_gb, description=None, io_limit_policy=None):
107+
def create_lun(lun_name, size_gb, description=None, io_limit_policy=None,
108+
is_thin=None):
107109
if lun_name == 'in_use':
108110
raise ex.UnityLunNameInUseError()
109111
ret = MockResource(lun_name, 'lun_2')
110112
if io_limit_policy is not None:
111113
ret.max_iops = io_limit_policy.max_iops
112114
ret.max_kbps = io_limit_policy.max_kbps
115+
if is_thin is not None:
116+
ret.is_thin = is_thin
113117
return ret
114118

115119
@staticmethod
@@ -303,6 +307,13 @@ def test_create_lun_with_io_limit(self):
303307
lun = self.client.create_lun('LUN 4', 6, pool, io_limit_policy=limit)
304308
self.assertEqual(100, lun.max_kbps)
305309

310+
def test_create_lun_thick(self):
311+
name = 'thick_lun'
312+
pool = MockResource('Pool 0')
313+
lun = self.client.create_lun(name, 6, pool, is_thin=False)
314+
self.assertIsNotNone(lun.is_thin)
315+
self.assertFalse(lun.is_thin)
316+
306317
def test_delete_lun_normal(self):
307318
self.assertIsNone(self.client.delete_lun('lun3'))
308319

cinder/volume/drivers/dell_emc/unity/adapter.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,21 @@ def create_volume(self, volume):
176176
qos_specs = utils.get_backend_qos_specs(volume)
177177
limit_policy = self.client.get_io_limit_policy(qos_specs)
178178

179+
provision = utils.get_extra_spec(volume, 'provisioning:type')
180+
support = utils.get_extra_spec(volume, 'thick_provisioning_support')
181+
is_thick = (provision == 'thick' and support == '<is> True')
182+
179183
LOG.info(_LI('Create Volume: %(volume)s Size: %(size)s '
180-
'Pool: %(pool)s Qos: %(qos)s.'),
184+
'Pool: %(pool)s Qos: %(qos)s Thick: %(is_thick)s.'),
181185
{'volume': volume_name,
182186
'size': volume_size,
183187
'pool': pool.name,
184-
'qos': qos_specs})
188+
'qos': qos_specs,
189+
'is_thick': is_thick})
185190

186191
lun = self.client.create_lun(
187192
volume_name, volume_size, pool, description=volume_description,
188-
io_limit_policy=limit_policy)
193+
io_limit_policy=limit_policy, is_thin=False if is_thick else None)
189194
location = self._build_provider_location(
190195
lun_type='lun',
191196
lun_id=lun.get_id())
@@ -263,7 +268,7 @@ def update_volume_stats(self):
263268
'volume_backend_name': self.volume_backend_name,
264269
'storage_protocol': self.protocol,
265270
'thin_provisioning_support': True,
266-
'thick_provisioning_support': False,
271+
'thick_provisioning_support': True,
267272
'pools': self.get_pools_stats(),
268273
}
269274

@@ -287,7 +292,7 @@ def _get_pool_stats(self, pool):
287292
{'pool_name': pool.name,
288293
'array_serial': self.serial_number}),
289294
'thin_provisioning_support': True,
290-
'thick_provisioning_support': False,
295+
'thick_provisioning_support': True,
291296
'max_over_subscription_ratio': (
292297
self.max_over_subscription_ratio)}
293298

cinder/volume/drivers/dell_emc/unity/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,22 @@ def get_serial(self):
5757
return self.system.serial_number
5858

5959
def create_lun(self, name, size, pool, description=None,
60-
io_limit_policy=None):
60+
io_limit_policy=None, is_thin=None):
6161
"""Creates LUN on the Unity system.
6262
6363
:param name: lun name
6464
:param size: lun size in GiB
6565
:param pool: UnityPool object represent to pool to place the lun
6666
:param description: lun description
6767
:param io_limit_policy: io limit on the LUN
68+
:param is_thin: if False, a thick LUN will be created
6869
:return: UnityLun object
6970
"""
7071
try:
7172
lun = pool.create_lun(lun_name=name, size_gb=size,
7273
description=description,
73-
io_limit_policy=io_limit_policy)
74+
io_limit_policy=io_limit_policy,
75+
is_thin=is_thin)
7476
except storops_ex.UnityLunNameInUseError:
7577
LOG.debug("LUN %s already exists. Return the existing one.",
7678
name)

0 commit comments

Comments
 (0)