Browse Source

NetApp: Add use-exact-size parameter when creating a LUN on ONTAP iSCSI

When a cinder volume is created the ontap backend fits the LUN to the
best geometry. It makes the image uploaded from a volume larger than
expected and a volume of larger size must be created from that image.
Using the use-exact-size parameter the backend does not fit to best
geometry, the image uploaded from that volume has the same size and a
volume of the same size may be created from that image.

Nevertheless this parameter is available only in Data ONTAP 9.1 (ontapi
version 1.110) and later.

Closes-Bug: #1731474
Change-Id: I0e21cbcb6effa1e72999580564099976511ca4a9
changes/61/550261/2
Luiz Gavioli 4 years ago
parent
commit
67391f1f0f
  1. 22
      cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_base.py
  2. 10
      cinder/volume/drivers/netapp/dataontap/client/client_base.py
  3. 6
      releasenotes/notes/netapp-ontap-use_exact_size-d03c90efbb8a30ac.yaml

22
cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_base.py

@ -46,6 +46,7 @@ class NetAppBaseClientTestCase(test.TestCase):
self.mock_object(client_base.Client, '_init_ssh_client')
self.client = client_base.Client(**CONNECTION_INFO)
self.client.connection = mock.MagicMock()
self.client.connection.get_api_version.return_value = (1, 100)
self.client.ssh_client = mock.MagicMock()
self.connection = self.client.connection
self.fake_volume = six.text_type(uuid.uuid4())
@ -86,7 +87,27 @@ class NetAppBaseClientTestCase(test.TestCase):
def test_create_lun(self):
expected_path = '/vol/%s/%s' % (self.fake_volume, self.fake_lun)
with mock.patch.object(netapp_api.NaElement,
'create_node_with_children',
) as mock_create_node:
self.client.create_lun(self.fake_volume,
self.fake_lun,
self.fake_size,
self.fake_metadata)
mock_create_node.assert_called_once_with(
'lun-create-by-size',
**{'path': expected_path,
'size': self.fake_size,
'ostype': self.fake_metadata['OsType'],
'space-reservation-enabled':
self.fake_metadata['SpaceReserved']})
self.connection.invoke_successfully.assert_called_once_with(
mock.ANY, True)
def test_create_lun_exact_size(self):
expected_path = '/vol/%s/%s' % (self.fake_volume, self.fake_lun)
self.connection.get_api_version.return_value = (1, 110)
with mock.patch.object(netapp_api.NaElement,
'create_node_with_children',
) as mock_create_node:
@ -100,6 +121,7 @@ class NetAppBaseClientTestCase(test.TestCase):
**{'path': expected_path,
'size': self.fake_size,
'ostype': self.fake_metadata['OsType'],
'use-exact-size': 'true',
'space-reservation-enabled':
self.fake_metadata['SpaceReserved']})
self.connection.invoke_successfully.assert_called_once_with(

10
cinder/volume/drivers/netapp/dataontap/client/client_base.py

@ -94,11 +94,15 @@ class Client(object):
"""Issues API request for creating LUN on volume."""
path = '/vol/%s/%s' % (volume_name, lun_name)
params = {'path': path, 'size': six.text_type(size),
'ostype': metadata['OsType'],
'space-reservation-enabled': metadata['SpaceReserved']}
version = self.get_ontapi_version()
if version >= (1, 110):
params['use-exact-size'] = 'true'
lun_create = netapp_api.NaElement.create_node_with_children(
'lun-create-by-size',
**{'path': path, 'size': six.text_type(size),
'ostype': metadata['OsType'],
'space-reservation-enabled': metadata['SpaceReserved']})
**params)
if qos_policy_group_name:
lun_create.add_new_child('qos-policy-group', qos_policy_group_name)

6
releasenotes/notes/netapp-ontap-use_exact_size-d03c90efbb8a30ac.yaml

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed bug #1731474 on NetApp Data ONTAP driver that was causing LUNs to be created
with larger size than requested. This fix requires version 9.1 of ONTAP
or later.
Loading…
Cancel
Save