Huawei: Support reporting disk type of pool
Adding support for reporting disk type of pool in huawei cinder driver. When creating volume we can specify the disk type of the pool we want to use ssd/sas/nl_sas/mix, cinder driver will report the disk type of the pools. DocImpact Implements: blueprint huawei-pool-disktype-support Change-Id: I10bbcf18ba04bdbb61a88e23cf4ec88c05b2c38d
This commit is contained in:
parent
e23ba3673f
commit
3767c6bf74
@ -307,7 +307,10 @@ FAKE_STORAGE_POOL_RESPONSE = """
|
||||
"USERFREECAPACITY": "985661440",
|
||||
"ID": "0",
|
||||
"NAME": "OpenStack_Pool",
|
||||
"USERTOTALCAPACITY": "985661440"
|
||||
"USERTOTALCAPACITY": "985661440",
|
||||
"TIER0CAPACITY": "100",
|
||||
"TIER1CAPACITY": "0",
|
||||
"TIER2CAPACITY": "0"
|
||||
}]
|
||||
}
|
||||
"""
|
||||
@ -2433,7 +2436,7 @@ class HuaweiISCSIDriverTestCase(HuaweiTestBase):
|
||||
|
||||
def test_get_volume_status(self):
|
||||
data = self.driver.get_volume_stats()
|
||||
self.assertEqual('2.0.8', data['driver_version'])
|
||||
self.assertEqual(self.driver.VERSION, data['driver_version'])
|
||||
|
||||
@mock.patch.object(rest_client.RestClient, 'get_lun_info',
|
||||
return_value={"CAPACITY": 6291456})
|
||||
@ -2556,20 +2559,31 @@ class HuaweiISCSIDriverTestCase(HuaweiTestBase):
|
||||
"ID": "0",
|
||||
"USERFREECAPACITY": "36",
|
||||
"USERTOTALCAPACITY": "48",
|
||||
"USAGETYPE": constants.BLOCK_STORAGE_POOL_TYPE},
|
||||
"USAGETYPE": constants.BLOCK_STORAGE_POOL_TYPE,
|
||||
"TIER0CAPACITY": "48",
|
||||
"TIER1CAPACITY": "0",
|
||||
"TIER2CAPACITY": "0"},
|
||||
{"NAME": "test002",
|
||||
"ID": "1",
|
||||
"USERFREECAPACITY": "37",
|
||||
"USERTOTALCAPACITY": "49",
|
||||
"USAGETYPE": constants.FILE_SYSTEM_POOL_TYPE},
|
||||
"USAGETYPE": constants.FILE_SYSTEM_POOL_TYPE,
|
||||
"TIER0CAPACITY": "0",
|
||||
"TIER1CAPACITY": "49",
|
||||
"TIER2CAPACITY": "0"},
|
||||
{"NAME": "test003",
|
||||
"ID": "0",
|
||||
"USERFREECAPACITY": "36",
|
||||
"DATASPACE": "35",
|
||||
"USERTOTALCAPACITY": "48",
|
||||
"USAGETYPE": constants.BLOCK_STORAGE_POOL_TYPE}]
|
||||
"USAGETYPE": constants.BLOCK_STORAGE_POOL_TYPE,
|
||||
"TIER0CAPACITY": "0",
|
||||
"TIER1CAPACITY": "0",
|
||||
"TIER2CAPACITY": "48"}]
|
||||
pool_name = 'test001'
|
||||
test_info = {'CAPACITY': '36', 'ID': '0', 'TOTALCAPACITY': '48'}
|
||||
test_info = {'CAPACITY': '36', 'ID': '0', 'TOTALCAPACITY': '48',
|
||||
'TIER0CAPACITY': '48', 'TIER1CAPACITY': '0',
|
||||
'TIER2CAPACITY': '0'}
|
||||
pool_info = self.driver.client.get_pool_info(pool_name, pools)
|
||||
self.assertEqual(test_info, pool_info)
|
||||
|
||||
@ -2584,7 +2598,9 @@ class HuaweiISCSIDriverTestCase(HuaweiTestBase):
|
||||
self.assertEqual(test_info, pool_info)
|
||||
|
||||
pool_name = 'test003'
|
||||
test_info = {'CAPACITY': '35', 'ID': '0', 'TOTALCAPACITY': '48'}
|
||||
test_info = {'CAPACITY': '35', 'ID': '0', 'TOTALCAPACITY': '48',
|
||||
'TIER0CAPACITY': '0', 'TIER1CAPACITY': '0',
|
||||
'TIER2CAPACITY': '48'}
|
||||
pool_info = self.driver.client.get_pool_info(pool_name, pools)
|
||||
self.assertEqual(test_info, pool_info)
|
||||
|
||||
@ -3806,7 +3822,7 @@ class HuaweiFCDriverTestCase(HuaweiTestBase):
|
||||
'get_remote_device_by_wwn',
|
||||
mock.Mock(return_value=remote_device_info))
|
||||
data = self.driver.get_volume_stats()
|
||||
self.assertEqual('2.0.8', data['driver_version'])
|
||||
self.assertEqual(self.driver.VERSION, data['driver_version'])
|
||||
self.assertTrue(data['pools'][0]['replication_enabled'])
|
||||
self.assertListEqual(['sync', 'async'],
|
||||
data['pools'][0]['replication_type'])
|
||||
@ -3823,9 +3839,60 @@ class HuaweiFCDriverTestCase(HuaweiTestBase):
|
||||
'try_get_remote_wwn',
|
||||
mock.Mock(return_value={}))
|
||||
data = self.driver.get_volume_stats()
|
||||
self.assertEqual('2.0.8', data['driver_version'])
|
||||
self.assertEqual(self.driver.VERSION, data['driver_version'])
|
||||
self.assertNotIn('replication_enabled', data['pools'][0])
|
||||
|
||||
@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_volume_disk_type(self, disk_type_value):
|
||||
response_dict = json.loads(FAKE_STORAGE_POOL_RESPONSE)
|
||||
storage_pool_sas = copy.deepcopy(response_dict)
|
||||
storage_pool_sas['data'][0]['TIER0CAPACITY'] = (
|
||||
disk_type_value['TIER0CAPACITY'])
|
||||
storage_pool_sas['data'][0]['TIER1CAPACITY'] = (
|
||||
disk_type_value['TIER1CAPACITY'])
|
||||
storage_pool_sas['data'][0]['TIER2CAPACITY'] = (
|
||||
disk_type_value['TIER2CAPACITY'])
|
||||
driver = FakeISCSIStorage(configuration=self.configuration)
|
||||
driver.do_setup()
|
||||
driver.replica = None
|
||||
|
||||
self.mock_object(rest_client.RestClient, 'get_all_pools',
|
||||
mock.Mock(return_value=storage_pool_sas['data']))
|
||||
data = driver.get_volume_stats()
|
||||
if disk_type_value['disktype']:
|
||||
self.assertEqual(disk_type_value['disktype'],
|
||||
data['pools'][0]['disk_type'])
|
||||
else:
|
||||
self.assertIsNone(data['pools'][0].get('disk_type'))
|
||||
|
||||
def test_get_disk_type_pool_info_none(self):
|
||||
driver = FakeISCSIStorage(configuration=self.configuration)
|
||||
driver.do_setup()
|
||||
driver.replica = None
|
||||
self.mock_object(rest_client.RestClient, 'get_pool_info',
|
||||
mock.Mock(return_value=None))
|
||||
data = driver.get_volume_stats()
|
||||
self.assertIsNone(data['pools'][0].get('disk_type'))
|
||||
|
||||
def test_extend_volume(self):
|
||||
self.driver.extend_volume(self.volume, 3)
|
||||
|
||||
|
@ -1830,9 +1830,10 @@ class HuaweiISCSIDriver(HuaweiBaseDriver, driver.ISCSIDriver):
|
||||
Consistency group support
|
||||
Cgsnapshot support
|
||||
2.0.8 - Backup snapshot optimal path support
|
||||
2.0.9 - Support reporting disk type of pool
|
||||
"""
|
||||
|
||||
VERSION = "2.0.8"
|
||||
VERSION = "2.0.9"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(HuaweiISCSIDriver, self).__init__(*args, **kwargs)
|
||||
@ -2029,9 +2030,10 @@ class HuaweiFCDriver(HuaweiBaseDriver, driver.FibreChannelDriver):
|
||||
Consistency group support
|
||||
Cgsnapshot support
|
||||
2.0.8 - Backup snapshot optimal path support
|
||||
2.0.9 - Support reporting disk type of pool
|
||||
"""
|
||||
|
||||
VERSION = "2.0.8"
|
||||
VERSION = "2.0.9"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(HuaweiFCDriver, self).__init__(*args, **kwargs)
|
||||
|
@ -250,6 +250,9 @@ class RestClient(object):
|
||||
info['ID'] = pool['ID']
|
||||
info['CAPACITY'] = pool.get('DATASPACE', pool['USERFREECAPACITY'])
|
||||
info['TOTALCAPACITY'] = pool['USERTOTALCAPACITY']
|
||||
info['TIER0CAPACITY'] = pool['TIER0CAPACITY']
|
||||
info['TIER1CAPACITY'] = pool['TIER1CAPACITY']
|
||||
info['TIER2CAPACITY'] = pool['TIER2CAPACITY']
|
||||
|
||||
return info
|
||||
|
||||
@ -1021,6 +1024,22 @@ class RestClient(object):
|
||||
|
||||
return pool_capacity
|
||||
|
||||
def _get_disk_type(self, pool_name, result):
|
||||
"""Get disk type of the pool."""
|
||||
pool_info = self.get_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 get_luncopy_info(self, luncopy_id):
|
||||
"""Get LUNcopy information."""
|
||||
url = "/LUNCOPY?range=[0-1023]"
|
||||
@ -1158,6 +1177,7 @@ class RestClient(object):
|
||||
result = self.get_all_pools()
|
||||
for pool_name in self.storage_pools:
|
||||
capacity = self._get_capacity(pool_name, result)
|
||||
disk_type = self._get_disk_type(pool_name, result)
|
||||
pool = {}
|
||||
pool.update(dict(
|
||||
location_info=self.device_id,
|
||||
@ -1177,6 +1197,9 @@ class RestClient(object):
|
||||
hypermetro=True,
|
||||
consistencygroup_support=True,
|
||||
))
|
||||
if disk_type:
|
||||
pool['disk_type'] = disk_type
|
||||
|
||||
data['pools'].append(pool)
|
||||
return data
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- Add support for reporting pool disk type in Huawei
|
||||
driver.
|
Loading…
Reference in New Issue
Block a user