Skip to content

Commit 11a5264

Browse files
authored
Merge pull request #67 from huangpeng5/115
Resolve cinder driver initialization failed issue
2 parents 1aed411 + ef2efb6 commit 11a5264

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+96
-816
lines changed

Cinder/Antelope/constants.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -242,29 +242,3 @@
242242
THIN = 'Thin'
243243
HYPERMETRO_UPPER = 'HyperMetro'
244244
ID_UPPER = 'ID'
245-
246-
HUAWEI_DISK_DICT = {
247-
"-1": "",
248-
"0": "fc",
249-
"1": "sas",
250-
"2": "sata",
251-
"3": "ssd",
252-
"4": "nl_sas",
253-
"5": "slc_ssd",
254-
"6": "mlc_ssd",
255-
"7": "fc_sed",
256-
"8": "sas_sed",
257-
"9": "sata_sed",
258-
"10": "ssd_sed",
259-
"11": "nl-sas_sed",
260-
"12": "slc_ssd_sed",
261-
"13": "mlc_ssd_sed",
262-
"14": "nvme_ssd",
263-
"16": "nvme_ssd_sed",
264-
"17": "scm",
265-
"18": "scm_sed",
266-
"19": "capacity-optimized ssd",
267-
"20": "capacity-optimized ssd sed",
268-
"21": "capacity-optimized ssd",
269-
"22": "capacity-optimized ssd sed"
270-
}

Cinder/Antelope/huawei_base_driver.py

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,18 @@ def __init__(self, *args, **kwargs):
7777
@staticmethod
7878
def _get_disk_type_by_storage_pool(pool_info):
7979
"""
80-
The method for storage pool to obtain the disk type is as follows:
81-
If disk type information exists in 'TIER0CAPACITY','TIER1CAPACITY', 'TIER2CAPACITY',
82-
separate them with commas ',' and return them.
80+
Get disk type of the pool.
8381
"""
8482
pool_disks = []
8583
for i, x in enumerate(constants.TIER_DISK_TYPES):
8684
if (pool_info.get('TIER%dCAPACITY' % i) and
8785
pool_info.get('TIER%dCAPACITY' % i) != '0'):
8886
pool_disks.append(x)
8987

90-
return ','.join(pool_disks) if pool_disks else None
88+
if len(pool_disks) > 1:
89+
pool_disks = ['mix']
90+
91+
return pool_disks[0] if pool_disks else None
9192

9293
def do_setup(self, context):
9394
self.conf.update_config_value()
@@ -190,12 +191,7 @@ def _get_capacity(self, pool_info):
190191

191192
def _get_disk_type(self, pool_info):
192193
"""Get disk type of the pool."""
193-
194-
if not self.configuration.is_dorado_v6:
195-
disk_type = self._get_disk_type_by_storage_pool(pool_info)
196-
else:
197-
disk_type = self._get_disk_type_by_disk_pool(pool_info)
198-
LOG.info("The disk type is %s", disk_type)
194+
disk_type = self._get_disk_type_by_storage_pool(pool_info)
199195
return disk_type
200196

201197
def _get_smarttier(self, disk_type):
@@ -866,24 +862,3 @@ def _merge_roce_mapping(self, local_mapping, remote_mapping):
866862
local_mapping['portals'].extend(remote_mapping['portals'])
867863
local_mapping['target_luns'].extend(remote_mapping['target_luns'])
868864
return local_mapping
869-
870-
def _get_disk_type_by_disk_pool(self, pool_info):
871-
"""
872-
The method for disk pool to obtain the disk type is as follows:
873-
Check whether diskTypeList contains disk type information.
874-
If diskTypeList contains disk type information, separate disk types with commas ','.
875-
If diskTypeList does not contain disk type information,
876-
use the disk type returned by TIER0DISKTYPE.
877-
"""
878-
pool_disks = []
879-
disk_pool_info = self.local_cli.get_disk_pool_by_id(pool_info.get('PARENTID'))
880-
if disk_pool_info.get('diskTypeList'):
881-
for disk_type in json.loads(disk_pool_info.get('diskTypeList')):
882-
if constants.HUAWEI_DISK_DICT.get(disk_type):
883-
pool_disks.append(constants.HUAWEI_DISK_DICT.get(disk_type))
884-
885-
if not pool_disks:
886-
pool_disks.append(constants.HUAWEI_DISK_DICT.get(disk_pool_info.get('TIER0DISKTYPE')))
887-
return pool_disks[0]
888-
889-
return ','.join(pool_disks) if pool_disks else None

Cinder/Antelope/huawei_conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def update_config_value(self):
5252
if self.last_modify_time == file_time:
5353
return
5454

55-
self.last_modify_time = file_time
5655
tree, xml_root = self.get_xml_info()
5756
self._encode_authentication(tree, xml_root)
5857

@@ -93,6 +92,8 @@ def update_config_value(self):
9392
for f in attr_funcs:
9493
f(xml_root)
9594

95+
self.last_modify_time = file_time
96+
9697
def _encode_authentication(self, tree, xml_root):
9798
node_start_text = '!$$$'
9899
name_node = xml_root.find('Storage/UserName')

Cinder/Antelope/rest_client.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,6 @@ def get_pool_by_name(self, pool_name):
276276
return None
277277

278278

279-
class DiskPool(CommonObject):
280-
_obj_url = '/diskpool'
281-
282-
def get_disk_pool_by_id(self, disk_domain_id):
283-
url = "/%s" % disk_domain_id
284-
result = self.get(url)
285-
_assert_result(result, 'Get disk pool by id error')
286-
return result['data']
287-
288-
289279
class Snapshot(CommonObject):
290280
_obj_url = '/snapshot'
291281

Cinder/Bobcat/constants.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -242,29 +242,3 @@
242242
THIN = 'Thin'
243243
HYPERMETRO_UPPER = 'HyperMetro'
244244
ID_UPPER = 'ID'
245-
246-
HUAWEI_DISK_DICT = {
247-
"-1": "",
248-
"0": "fc",
249-
"1": "sas",
250-
"2": "sata",
251-
"3": "ssd",
252-
"4": "nl_sas",
253-
"5": "slc_ssd",
254-
"6": "mlc_ssd",
255-
"7": "fc_sed",
256-
"8": "sas_sed",
257-
"9": "sata_sed",
258-
"10": "ssd_sed",
259-
"11": "nl-sas_sed",
260-
"12": "slc_ssd_sed",
261-
"13": "mlc_ssd_sed",
262-
"14": "nvme_ssd",
263-
"16": "nvme_ssd_sed",
264-
"17": "scm",
265-
"18": "scm_sed",
266-
"19": "capacity-optimized ssd",
267-
"20": "capacity-optimized ssd sed",
268-
"21": "capacity-optimized ssd",
269-
"22": "capacity-optimized ssd sed"
270-
}

Cinder/Bobcat/huawei_base_driver.py

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,18 @@ def __init__(self, *args, **kwargs):
7777
@staticmethod
7878
def _get_disk_type_by_storage_pool(pool_info):
7979
"""
80-
The method for storage pool to obtain the disk type is as follows:
81-
If disk type information exists in 'TIER0CAPACITY','TIER1CAPACITY', 'TIER2CAPACITY',
82-
separate them with commas ',' and return them.
80+
Get disk type of the pool.
8381
"""
8482
pool_disks = []
8583
for i, x in enumerate(constants.TIER_DISK_TYPES):
8684
if (pool_info.get('TIER%dCAPACITY' % i) and
8785
pool_info.get('TIER%dCAPACITY' % i) != '0'):
8886
pool_disks.append(x)
8987

90-
return ','.join(pool_disks) if pool_disks else None
88+
if len(pool_disks) > 1:
89+
pool_disks = ['mix']
90+
91+
return pool_disks[0] if pool_disks else None
9192

9293
def do_setup(self, context):
9394
self.conf.update_config_value()
@@ -190,12 +191,7 @@ def _get_capacity(self, pool_info):
190191

191192
def _get_disk_type(self, pool_info):
192193
"""Get disk type of the pool."""
193-
194-
if not self.configuration.is_dorado_v6:
195-
disk_type = self._get_disk_type_by_storage_pool(pool_info)
196-
else:
197-
disk_type = self._get_disk_type_by_disk_pool(pool_info)
198-
LOG.info("The disk type is %s", disk_type)
194+
disk_type = self._get_disk_type_by_storage_pool(pool_info)
199195
return disk_type
200196

201197
def _get_smarttier(self, disk_type):
@@ -866,24 +862,3 @@ def _merge_roce_mapping(self, local_mapping, remote_mapping):
866862
local_mapping['portals'].extend(remote_mapping['portals'])
867863
local_mapping['target_luns'].extend(remote_mapping['target_luns'])
868864
return local_mapping
869-
870-
def _get_disk_type_by_disk_pool(self, pool_info):
871-
"""
872-
The method for disk pool to obtain the disk type is as follows:
873-
Check whether diskTypeList contains disk type information.
874-
If diskTypeList contains disk type information, separate disk types with commas ','.
875-
If diskTypeList does not contain disk type information,
876-
use the disk type returned by TIER0DISKTYPE.
877-
"""
878-
pool_disks = []
879-
disk_pool_info = self.local_cli.get_disk_pool_by_id(pool_info.get('PARENTID'))
880-
if disk_pool_info.get('diskTypeList'):
881-
for disk_type in json.loads(disk_pool_info.get('diskTypeList')):
882-
if constants.HUAWEI_DISK_DICT.get(disk_type):
883-
pool_disks.append(constants.HUAWEI_DISK_DICT.get(disk_type))
884-
885-
if not pool_disks:
886-
pool_disks.append(constants.HUAWEI_DISK_DICT.get(disk_pool_info.get('TIER0DISKTYPE')))
887-
return pool_disks[0]
888-
889-
return ','.join(pool_disks) if pool_disks else None

Cinder/Bobcat/huawei_conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def update_config_value(self):
5252
if self.last_modify_time == file_time:
5353
return
5454

55-
self.last_modify_time = file_time
5655
tree, xml_root = self.get_xml_info()
5756
self._encode_authentication(tree, xml_root)
5857

@@ -93,6 +92,8 @@ def update_config_value(self):
9392
for f in attr_funcs:
9493
f(xml_root)
9594

95+
self.last_modify_time = file_time
96+
9697
def _encode_authentication(self, tree, xml_root):
9798
node_start_text = '!$$$'
9899
name_node = xml_root.find('Storage/UserName')

Cinder/Bobcat/rest_client.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,6 @@ def get_pool_by_name(self, pool_name):
276276
return None
277277

278278

279-
class DiskPool(CommonObject):
280-
_obj_url = '/diskpool'
281-
282-
def get_disk_pool_by_id(self, disk_domain_id):
283-
url = "/%s" % disk_domain_id
284-
result = self.get(url)
285-
_assert_result(result, 'Get disk pool by id error')
286-
return result['data']
287-
288-
289279
class Snapshot(CommonObject):
290280
_obj_url = '/snapshot'
291281

Cinder/Caracal/constants.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -242,29 +242,3 @@
242242
THIN = 'Thin'
243243
HYPERMETRO_UPPER = 'HyperMetro'
244244
ID_UPPER = 'ID'
245-
246-
HUAWEI_DISK_DICT = {
247-
"-1": "",
248-
"0": "fc",
249-
"1": "sas",
250-
"2": "sata",
251-
"3": "ssd",
252-
"4": "nl_sas",
253-
"5": "slc_ssd",
254-
"6": "mlc_ssd",
255-
"7": "fc_sed",
256-
"8": "sas_sed",
257-
"9": "sata_sed",
258-
"10": "ssd_sed",
259-
"11": "nl-sas_sed",
260-
"12": "slc_ssd_sed",
261-
"13": "mlc_ssd_sed",
262-
"14": "nvme_ssd",
263-
"16": "nvme_ssd_sed",
264-
"17": "scm",
265-
"18": "scm_sed",
266-
"19": "capacity-optimized ssd",
267-
"20": "capacity-optimized ssd sed",
268-
"21": "capacity-optimized ssd",
269-
"22": "capacity-optimized ssd sed"
270-
}

Cinder/Caracal/huawei_base_driver.py

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,18 @@ def __init__(self, *args, **kwargs):
7777
@staticmethod
7878
def _get_disk_type_by_storage_pool(pool_info):
7979
"""
80-
The method for storage pool to obtain the disk type is as follows:
81-
If disk type information exists in 'TIER0CAPACITY','TIER1CAPACITY', 'TIER2CAPACITY',
82-
separate them with commas ',' and return them.
80+
Get disk type of the pool.
8381
"""
8482
pool_disks = []
8583
for i, x in enumerate(constants.TIER_DISK_TYPES):
8684
if (pool_info.get('TIER%dCAPACITY' % i) and
8785
pool_info.get('TIER%dCAPACITY' % i) != '0'):
8886
pool_disks.append(x)
8987

90-
return ','.join(pool_disks) if pool_disks else None
88+
if len(pool_disks) > 1:
89+
pool_disks = ['mix']
90+
91+
return pool_disks[0] if pool_disks else None
9192

9293
def do_setup(self, context):
9394
self.conf.update_config_value()
@@ -190,12 +191,7 @@ def _get_capacity(self, pool_info):
190191

191192
def _get_disk_type(self, pool_info):
192193
"""Get disk type of the pool."""
193-
194-
if not self.configuration.is_dorado_v6:
195-
disk_type = self._get_disk_type_by_storage_pool(pool_info)
196-
else:
197-
disk_type = self._get_disk_type_by_disk_pool(pool_info)
198-
LOG.info("The disk type is %s", disk_type)
194+
disk_type = self._get_disk_type_by_storage_pool(pool_info)
199195
return disk_type
200196

201197
def _get_smarttier(self, disk_type):
@@ -866,24 +862,3 @@ def _merge_roce_mapping(self, local_mapping, remote_mapping):
866862
local_mapping['portals'].extend(remote_mapping['portals'])
867863
local_mapping['target_luns'].extend(remote_mapping['target_luns'])
868864
return local_mapping
869-
870-
def _get_disk_type_by_disk_pool(self, pool_info):
871-
"""
872-
The method for disk pool to obtain the disk type is as follows:
873-
Check whether diskTypeList contains disk type information.
874-
If diskTypeList contains disk type information, separate disk types with commas ','.
875-
If diskTypeList does not contain disk type information,
876-
use the disk type returned by TIER0DISKTYPE.
877-
"""
878-
pool_disks = []
879-
disk_pool_info = self.local_cli.get_disk_pool_by_id(pool_info.get('PARENTID'))
880-
if disk_pool_info.get('diskTypeList'):
881-
for disk_type in json.loads(disk_pool_info.get('diskTypeList')):
882-
if constants.HUAWEI_DISK_DICT.get(disk_type):
883-
pool_disks.append(constants.HUAWEI_DISK_DICT.get(disk_type))
884-
885-
if not pool_disks:
886-
pool_disks.append(constants.HUAWEI_DISK_DICT.get(disk_pool_info.get('TIER0DISKTYPE')))
887-
return pool_disks[0]
888-
889-
return ','.join(pool_disks) if pool_disks else None

Cinder/Caracal/huawei_conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def update_config_value(self):
5252
if self.last_modify_time == file_time:
5353
return
5454

55-
self.last_modify_time = file_time
5655
tree, xml_root = self.get_xml_info()
5756
self._encode_authentication(tree, xml_root)
5857

@@ -93,6 +92,8 @@ def update_config_value(self):
9392
for f in attr_funcs:
9493
f(xml_root)
9594

95+
self.last_modify_time = file_time
96+
9697
def _encode_authentication(self, tree, xml_root):
9798
node_start_text = '!$$$'
9899
name_node = xml_root.find('Storage/UserName')

Cinder/Caracal/rest_client.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,6 @@ def get_pool_by_name(self, pool_name):
276276
return None
277277

278278

279-
class DiskPool(CommonObject):
280-
_obj_url = '/diskpool'
281-
282-
def get_disk_pool_by_id(self, disk_domain_id):
283-
url = "/%s" % disk_domain_id
284-
result = self.get(url)
285-
_assert_result(result, 'Get disk pool by id error')
286-
return result['data']
287-
288-
289279
class Snapshot(CommonObject):
290280
_obj_url = '/snapshot'
291281

0 commit comments

Comments
 (0)