Merge "Huawei: Support reporting disk type of pool"
This commit is contained in:
commit
56c0d2eb19
@ -157,6 +157,11 @@ extra-spec. This ensures that the share will be created on a backend that
|
||||
supports the requested driver_handles_share_servers (share networks) capability.
|
||||
For the Huawei driver, this must be set to False.
|
||||
|
||||
To create a share on a backend with a specific type of disks, include the
|
||||
`huawei_disk_type` extra-spec in the share type. Valid values for this
|
||||
extra-spec are 'ssd', 'sas', 'nl_sas' or 'mix'. This share will be created
|
||||
on a backend with a matching disk type.
|
||||
|
||||
Another common manila extra-spec used to determine where a share is created
|
||||
is `share_backend_name`. When this extra-spec is defined in the share type,
|
||||
the share will be created on a backend with a matching share_backend_name.
|
||||
@ -215,6 +220,8 @@ type uses one or more of the following extra-specs:
|
||||
|
||||
* huawei_sectorsize:sectorsize=4
|
||||
|
||||
- huawei_disk_type='ssd' or 'sas' or 'nl_sas' or 'mix'
|
||||
|
||||
`thin_provisioning` will be reported as [True, False] for Huawei backends.
|
||||
|
||||
`dedupe` will be reported as [True, False] for Huawei backends.
|
||||
@ -235,6 +242,9 @@ specification.
|
||||
|
||||
`huawei_sectorsize` will be reported as [True, False] for Huawei backends.
|
||||
|
||||
`huawei_disk_type` will be reported as "ssd", "sas", "nl_sas" or "mix" for
|
||||
Huawei backends.
|
||||
|
||||
Restrictions
|
||||
------------
|
||||
|
||||
|
@ -57,6 +57,7 @@ class HuaweiNasDriver(driver.ShareDriver):
|
||||
Add QoS support.
|
||||
Add create share from snapshot.
|
||||
1.3 - Add manage snapshot.
|
||||
Support reporting disk type of pool.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -282,6 +282,7 @@ class V3StorageConnection(driver.HuaweiBase):
|
||||
for pool_name in pool_name_list:
|
||||
pool_name = pool_name.strip().strip('\n')
|
||||
capacity = self._get_capacity(pool_name, all_pool_info)
|
||||
disk_type = self._get_disk_type(pool_name, all_pool_info)
|
||||
if capacity:
|
||||
pool = dict(
|
||||
pool_name=pool_name,
|
||||
@ -302,6 +303,9 @@ class V3StorageConnection(driver.HuaweiBase):
|
||||
huawei_smartpartition=[True, False],
|
||||
huawei_sectorsize=[True, False],
|
||||
)
|
||||
if disk_type:
|
||||
pool['huawei_disk_type'] = disk_type
|
||||
|
||||
stats_dict["pools"].append(pool)
|
||||
|
||||
if not stats_dict["pools"]:
|
||||
@ -605,6 +609,22 @@ class V3StorageConnection(driver.HuaweiBase):
|
||||
|
||||
return poolinfo
|
||||
|
||||
def _get_disk_type(self, pool_name, result):
|
||||
"""Get disk type of the pool."""
|
||||
pool_info = self.helper._find_pool_info(pool_name, result)
|
||||
if not pool_info:
|
||||
return None
|
||||
|
||||
pool_disk = []
|
||||
for i, x in enumerate(['ssd', 'sas', 'nl_sas']):
|
||||
if pool_info['TIER%dCAPACITY' % i] != '0':
|
||||
pool_disk.append(x)
|
||||
|
||||
if len(pool_disk) > 1:
|
||||
pool_disk = ['mix']
|
||||
|
||||
return pool_disk[0] if pool_disk else None
|
||||
|
||||
def _init_filesys_para(self, share, poolinfo, extra_specs):
|
||||
"""Init basic filesystem parameters."""
|
||||
name = share['name']
|
||||
|
@ -345,6 +345,9 @@ class RestHelper(object):
|
||||
poolinfo['CAPACITY'] = item['USERFREECAPACITY']
|
||||
poolinfo['TOTALCAPACITY'] = item['USERTOTALCAPACITY']
|
||||
poolinfo['CONSUMEDCAPACITY'] = item['USERCONSUMEDCAPACITY']
|
||||
poolinfo['TIER0CAPACITY'] = item['TIER0CAPACITY']
|
||||
poolinfo['TIER1CAPACITY'] = item['TIER1CAPACITY']
|
||||
poolinfo['TIER2CAPACITY'] = item['TIER2CAPACITY']
|
||||
break
|
||||
|
||||
return poolinfo
|
||||
|
@ -361,13 +361,19 @@ class FakeHuaweiNasHelper(helper.RestHelper):
|
||||
"NAME":"OpenStack_Pool",
|
||||
"USERTOTALCAPACITY":"4194304",
|
||||
"USAGETYPE":"2",
|
||||
"USERCONSUMEDCAPACITY":"2097152"},
|
||||
"USERCONSUMEDCAPACITY":"2097152",
|
||||
"TIER0CAPACITY":"100",
|
||||
"TIER1CAPACITY":"0",
|
||||
"TIER2CAPACITY":"0"},
|
||||
{"USERFREECAPACITY":"2097152",
|
||||
"ID":"2",
|
||||
"NAME":"OpenStack_Pool_Thick",
|
||||
"USERTOTALCAPACITY":"4194304",
|
||||
"USAGETYPE":"2",
|
||||
"USERCONSUMEDCAPACITY":"2097152"}]}"""
|
||||
"USERCONSUMEDCAPACITY":"2097152",
|
||||
"TIER0CAPACITY":"100",
|
||||
"TIER1CAPACITY":"0",
|
||||
"TIER2CAPACITY":"0"}]}"""
|
||||
|
||||
if url == "/filesystem":
|
||||
request_data = jsonutils.loads(data)
|
||||
@ -2307,10 +2313,65 @@ class HuaweiShareDriverTestCase(test.TestCase):
|
||||
huawei_smartcache=[True, False],
|
||||
huawei_smartpartition=[True, False],
|
||||
huawei_sectorsize=[True, False],
|
||||
huawei_disk_type='ssd'
|
||||
)
|
||||
expected["pools"].append(pool)
|
||||
self.assertEqual(expected, self.driver._stats)
|
||||
|
||||
@ddt.data({'TIER0CAPACITY': '100',
|
||||
'TIER1CAPACITY': '0',
|
||||
'TIER2CAPACITY': '0',
|
||||
'disktype': 'ssd'},
|
||||
{'TIER0CAPACITY': '0',
|
||||
'TIER1CAPACITY': '100',
|
||||
'TIER2CAPACITY': '0',
|
||||
'disktype': 'sas'},
|
||||
{'TIER0CAPACITY': '0',
|
||||
'TIER1CAPACITY': '0',
|
||||
'TIER2CAPACITY': '100',
|
||||
'disktype': 'nl_sas'},
|
||||
{'TIER0CAPACITY': '100',
|
||||
'TIER1CAPACITY': '100',
|
||||
'TIER2CAPACITY': '100',
|
||||
'disktype': 'mix'},
|
||||
{'TIER0CAPACITY': '0',
|
||||
'TIER1CAPACITY': '0',
|
||||
'TIER2CAPACITY': '0',
|
||||
'disktype': ''})
|
||||
def test_get_share_stats_disk_type(self, disk_type_value):
|
||||
self.driver.plugin.helper.login()
|
||||
storage_pool_info = {"error": {"code": 0},
|
||||
"data": [{"USERFREECAPACITY": "2097152",
|
||||
"ID": "1",
|
||||
"NAME": "OpenStack_Pool",
|
||||
"USERTOTALCAPACITY": "4194304",
|
||||
"USAGETYPE": "2",
|
||||
"USERCONSUMEDCAPACITY": "2097152"}]}
|
||||
storage_pool_info['data'][0]['TIER0CAPACITY'] = (
|
||||
disk_type_value['TIER0CAPACITY'])
|
||||
storage_pool_info['data'][0]['TIER1CAPACITY'] = (
|
||||
disk_type_value['TIER1CAPACITY'])
|
||||
storage_pool_info['data'][0]['TIER2CAPACITY'] = (
|
||||
disk_type_value['TIER2CAPACITY'])
|
||||
self.mock_object(self.driver.plugin.helper, '_find_all_pool_info',
|
||||
mock.Mock(return_value=storage_pool_info))
|
||||
self.driver._update_share_stats()
|
||||
|
||||
if disk_type_value['disktype']:
|
||||
self.assertEqual(
|
||||
disk_type_value['disktype'],
|
||||
self.driver._stats['pools'][0]['huawei_disk_type'])
|
||||
else:
|
||||
self.assertIsNone(
|
||||
self.driver._stats['pools'][0].get('huawei_disk_type'))
|
||||
|
||||
def test_get_disk_type_pool_info_none(self):
|
||||
self.driver.plugin.helper.login()
|
||||
self.mock_object(self.driver.plugin.helper, '_find_pool_info',
|
||||
mock.Mock(return_value=None))
|
||||
self.assertRaises(exception.InvalidInput,
|
||||
self.driver._update_share_stats)
|
||||
|
||||
def test_allow_access_proto_fail(self):
|
||||
self.driver.plugin.helper.login()
|
||||
self.assertRaises(exception.InvalidInput,
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- Add support for reporting pool disk type in Huawei driver.
|
||||
`huawei_disk_type` extra-spec in the share type. Valid values
|
||||
for this extra-spec are 'ssd', 'sas', 'nl_sas' or 'mix'.
|
Loading…
Reference in New Issue
Block a user