huawei driver default create thin type share

Currently, huawei driver will use the "AllocType" configuration
or default "thick" type to create share, if "thin-provisioning"
not specified in share_type, but scheduler default uses thin
type in this situation, so huawei driver isn't consistent with
scheduler.

This patch removes the "AllocType" configuration from huawei
driver configuration file and default use "thin" type if
"thin-provisioning" not given.

Depend on change I238a7962425ea35c356c5ed2e31b8f68462b3769.

DocImpact
Change-Id: I5b7128657e089113da44bc862e9c864de2ec59b2
Closes-Bug: #1609718
This commit is contained in:
zengyingzhe 2016-08-05 11:35:33 +08:00
parent 29c05e72f5
commit d0e2380324
4 changed files with 14 additions and 89 deletions

View File

@ -83,7 +83,6 @@ storage systems, the driver configuration file is as follows:
</Storage>
<Filesystem>
<StoragePool>xxxxxxxxx</StoragePool>
<AllocType>xxxxxxxx</AllocType>
<SectorSize>64</SectorSize>
<WaitInterval>3</WaitInterval>
<Timeout>60</Timeout>
@ -109,7 +108,6 @@ storage systems, the driver configuration file is as follows:
- `UserName` is a user name of an administrator.
- `UserPassword` is a password of an administrator.
- `StoragePool` is a name of a storage pool to be used.
- `AllocType` is the file system space allocation type, optional value is "Thick" or "Thin".
- `SectorSize` is the size of the disk blocks, optional value can be "4", "8", "16", "32" or "64",
and the units is KB. If "sectorsize" is configured in both share_type and xml file, the value
of sectorsize in the share_type will be used. If "sectorsize" is configured in neither

View File

@ -124,28 +124,11 @@ class SmartX(object):
def get_smartprovisioning_opts(self, opts):
thin_provision = opts.get('thin_provisioning')
if thin_provision is None:
root = self.helper._read_xml()
fstype = root.findtext('Filesystem/AllocType')
if fstype:
fstype = fstype.strip().strip('\n')
if fstype == 'Thin':
opts['LUNType'] = constants.ALLOC_TYPE_THIN_FLAG
elif fstype == 'Thick':
opts['LUNType'] = constants.ALLOC_TYPE_THICK_FLAG
else:
err_msg = (_(
'Huawei config file is wrong. AllocType type must be '
'set to "Thin" or "Thick". AllocType:%(fetchtype)s') %
{'fetchtype': fstype})
raise exception.InvalidShare(reason=err_msg)
else:
opts['LUNType'] = constants.ALLOC_TYPE_THICK_FLAG
if (thin_provision is None or
strutils.bool_from_string(thin_provision)):
opts['LUNType'] = constants.ALLOC_TYPE_THIN_FLAG
else:
if strutils.bool_from_string(thin_provision):
opts['LUNType'] = constants.ALLOC_TYPE_THIN_FLAG
else:
opts['LUNType'] = constants.ALLOC_TYPE_THICK_FLAG
opts['LUNType'] = constants.ALLOC_TYPE_THICK_FLAG
return opts

View File

@ -1406,21 +1406,6 @@ class HuaweiShareDriverTestCase(test.TestCase):
self.assertRaises(exception.InvalidInput,
self.driver.get_backend_driver)
def test_create_share_alloctype_fail(self):
share_type = self.fake_type_not_extra['test_with_extra']
self.mock_object(db,
'share_type_get',
mock.Mock(return_value=share_type))
self.recreate_fake_conf_file(alloctype_value='alloctype_fail')
self.driver.plugin.configuration.manila_huawei_conf_file = (
self.fake_conf_file)
self.driver.plugin.helper.login()
self.assertRaises(exception.InvalidShare,
self.driver.create_share,
self._context,
self.share_nfs,
self.share_server)
def test_create_share_storagepool_not_exist(self):
self.driver.plugin.helper.login()
self.assertRaises(exception.InvalidHost,
@ -1488,54 +1473,17 @@ class HuaweiShareDriverTestCase(test.TestCase):
self.assertRaises(exception.InvalidShare,
self.driver.check_for_setup_error)
def test_create_share_alloctype_thin_success(self):
def test_create_share_no_extra(self):
share_type = self.fake_type_not_extra['test_with_extra']
self.mock_object(db,
'share_type_get',
mock.Mock(return_value=share_type))
self.driver.plugin.helper.login()
self.recreate_fake_conf_file(alloctype_value='Thin')
self.driver.plugin.configuration.manila_huawei_conf_file = (
self.fake_conf_file)
self.driver.plugin.helper.login()
location = self.driver.create_share(self._context, self.share_nfs,
self.share_server)
self.assertEqual("100.115.10.68:/share_fake_uuid", location)
self.assertEqual(constants.ALLOC_TYPE_THIN_FLAG,
self.driver.plugin.helper.alloc_type)
def test_create_share_alloctype_thick_success(self):
share_type = self.fake_type_not_extra['test_with_extra']
self.mock_object(db,
'share_type_get',
mock.Mock(return_value=share_type))
self.driver.plugin.helper.login()
self.recreate_fake_conf_file(alloctype_value='Thick')
self.driver.plugin.configuration.manila_huawei_conf_file = (
self.fake_conf_file)
self.driver.plugin.helper.login()
location = self.driver.create_share(self._context, self.share_nfs,
self.share_server)
self.assertEqual("100.115.10.68:/share_fake_uuid", location)
self.assertEqual(constants.ALLOC_TYPE_THICK_FLAG,
self.driver.plugin.helper.alloc_type)
def test_create_share_no_alloctype_no_extra(self):
share_type = self.fake_type_not_extra['test_with_extra']
self.mock_object(db,
'share_type_get',
mock.Mock(return_value=share_type))
self.driver.plugin.helper.login()
self.recreate_fake_conf_file(alloctype_value=None)
self.driver.plugin.configuration.manila_huawei_conf_file = (
self.fake_conf_file)
self.driver.plugin.helper.login()
location = self.driver.create_share(self._context, self.share_nfs,
self.share_server)
self.assertEqual("100.115.10.68:/share_fake_uuid", location)
self.assertEqual(constants.ALLOC_TYPE_THICK_FLAG,
self.driver.plugin.helper.alloc_type)
def test_create_share_with_extra_thin(self):
share_type = {
'extra_specs': {
@ -1754,10 +1702,6 @@ class HuaweiShareDriverTestCase(test.TestCase):
self.mock_object(db,
'share_type_get',
mock.Mock(return_value=share_type))
self.recreate_fake_conf_file(alloctype_value='Thin')
self.driver.plugin.configuration.manila_huawei_conf_file = (
self.fake_conf_file)
self.driver.plugin.helper.login()
location = self.driver.create_share(self._context, self.share_nfs,
self.share_server)
self.assertEqual("100.115.10.68:/share_fake_uuid", location)
@ -3905,7 +3849,6 @@ class HuaweiShareDriverTestCase(test.TestCase):
product_flag=True, username_flag=True,
pool_node_flag=True, timeout_flag=True,
wait_interval_flag=True,
alloctype_value='Thick',
sectorsize_value='4',
multi_url=False,
logical_port='100.115.10.68',
@ -4020,12 +3963,6 @@ class HuaweiShareDriverTestCase(test.TestCase):
lun.appendChild(waitinterval)
lun.appendChild(storagepool)
if alloctype_value:
alloctype = doc.createElement('AllocType')
alloctype_text = doc.createTextNode(alloctype_value)
alloctype.appendChild(alloctype_text)
lun.appendChild(alloctype)
if sectorsize_value:
sectorsize = doc.createElement('SectorSize')
sectorsize_text = doc.createTextNode(sectorsize_value)
@ -4044,7 +3981,6 @@ class HuaweiShareDriverTestCase(test.TestCase):
def recreate_fake_conf_file(self, product_flag=True, username_flag=True,
pool_node_flag=True, timeout_flag=True,
wait_interval_flag=True,
alloctype_value='Thick',
sectorsize_value='4',
multi_url=False,
logical_port='100.115.10.68',
@ -4056,7 +3992,7 @@ class HuaweiShareDriverTestCase(test.TestCase):
self.create_fake_conf_file(self.fake_conf_file, product_flag,
username_flag, pool_node_flag,
timeout_flag, wait_interval_flag,
alloctype_value, sectorsize_value,
sectorsize_value,
multi_url, logical_port,
snapshot_support, replication_support)
self.addCleanup(os.remove, self.fake_conf_file)

View File

@ -0,0 +1,8 @@
---
prelude: >
Manila scheduler checks "thin_provisioning" in extra specs of the share type
and decides whether to use the logic for thin or thick. If "thin_provisioning"
not given in extra specs, default use thin.
upgrade:
- Remove the "AllocType" configuration from huawei driver configuration file.
If "thin_provisioning" not given, default create new share by "thin" type.