Skip to content

Commit

Permalink
Merge pull request #69 from huangpeng5/suyan_723
Browse files Browse the repository at this point in the history
Suyan 723
  • Loading branch information
huangpeng5 authored Jul 23, 2024
2 parents 1b9d471 + 0e25c23 commit e5e8162
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,14 @@ def update_storage_pool(self, data, free_pool):
result = self.helper.query_pool_by_id(pool_id)
if result:
total = round(float(result['totalCapacity']) / 1024, 1)
allocated = round(float(result['allocatedCapacity']) / 1024, 1)
used = round(float(result['usedCapacity']) / 1024, 1)
free = round(float(total) - float(used), 2)
provisioned = used
pool = dict(
huawei_smartpartition=True,
huawei_smartcache=True,
pool_name=result['storagePoolName'],
qos=True,
compression=True,
provisioned_capacity_gb=provisioned,
allocated_capacity_gb=allocated,
free_capacity_gb=free,
total_capacity_gb=total,
reserved_percentage=reserved_percentage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,39 +146,18 @@ def _get_max_band_width_qos_config(self, extra_specs):
苏研单独的qos 参数设置与读取,其支持的参数如下:
“total_bytes_sec”:总吞吐量,单位Byte/s
“total_iops_sec”: 总IOPS,单位个/s
此处解析 max_band_width,从total_bytes_sec获取
此处解析 max_band_width,从total_bytes_sec获取
"""
# the total_bytes_sec is Byte/s the pacific need MB/s
tmp_max_band_width = extra_specs.get('pacific:total_bytes_sec')
if tmp_max_band_width is None:
self.qos_config['max_band_width'] = constants.MAX_BAND_WIDTH
elif (tmp_max_band_width.strip().isdigit()
and 0 <= int(int(tmp_max_band_width.strip()) / constants.BYTE_TO_MB)
<= constants.BAND_WIDTH_UPPER_LIMIT):
self.qos_config['max_band_width'] = int(math.ceil(float(
tmp_max_band_width.strip()) / constants.BYTE_TO_MB))
else:
err_msg = _("The total_bytes_sec in share type "
"must be int([0, %s]).") % constants.BAND_WIDTH_UPPER_LIMIT
raise exception.InvalidInput(reason=err_msg)

self.qos_config['max_band_width'] = 0

def _get_max_iops_qos_config(self, extra_specs):
"""
苏研单独的qos 参数设置与读取,其支持的参数如下:
“total_bytes_sec”:总吞吐量,单位Byte/s
“total_iops_sec”: 总IOPS,单位个/s
此处解析 max_iops,从total_iops_sec获取
"""
tmp_max_iops = extra_specs.get('pacific:total_iops_sec')
if tmp_max_iops is None:
self.qos_config['max_iops'] = constants.MAX_IOPS
elif tmp_max_iops.strip().isdigit() \
and 0 <= int(tmp_max_iops.strip()) <= constants.MAX_IOPS_UPPER_LIMIT:
self.qos_config['max_iops'] = int(tmp_max_iops.strip())
else:
err_msg = _("The max_iops in share type "
"must be int([0, %s]).") % constants.MAX_IOPS_UPPER_LIMIT
raise exception.InvalidInput(reason=err_msg)
self.qos_config['max_iops'] = 0

def _create_qos(self):
qos_name = self.namespace_name
Expand Down Expand Up @@ -219,21 +198,17 @@ def _get_update_qos_config(self, qos_specs):
LOG.error(err_msg)
raise exception.InvalidShare(reason=err_msg)

tmp_max_band_width = str(qos_specs.get('total_bytes_sec'))
if int(tmp_max_band_width) == 0:
self.qos_config['max_band_width'] = constants.MAX_BAND_WIDTH
elif (tmp_max_band_width.strip().isdigit()
and 0 <= int(int(tmp_max_band_width.strip()) / constants.BYTE_TO_MB)
<= constants.BAND_WIDTH_UPPER_LIMIT):
self.qos_config['max_band_width'] = int(math.ceil(float(
tmp_max_band_width.strip()) / constants.BYTE_TO_MB))

tmp_max_iops = str(qos_specs.get('total_iops_sec'))
if int(tmp_max_iops) == 0:
self.qos_config['max_iops'] = constants.MAX_IOPS
elif tmp_max_iops.strip().isdigit() \
and 0 <= int(tmp_max_iops.strip()) <= constants.MAX_IOPS_UPPER_LIMIT:
self.qos_config['max_iops'] = int(tmp_max_iops.strip())
# total_bytes_sec and total_iops_sec must be integer
tmp_max_band_width = str(qos_specs.get('total_bytes_sec')).strip()
tmp_max_iops = str(qos_specs.get('total_iops_sec')).strip()
if not (tmp_max_band_width.isdigit() and tmp_max_iops.isdigit()):
err_msg = "total_bytes_sec and total_iops_sec must be integer, " \
"the qos_specs is {0}".format(qos_specs)
LOG.error(err_msg)
raise exception.InvalidShare(reason=err_msg)

self.qos_config['max_band_width'] = int(math.ceil(float(tmp_max_band_width) / (1024 ** 2)))
self.qos_config['max_iops'] = int(tmp_max_iops)

def _create_qos_when_update_qos(self, qos_name):
try:
Expand Down

0 comments on commit e5e8162

Please sign in to comment.