Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify Used Capacity Unit Conversion #985

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions delfin/drivers/dell_emc/vplex/vplex_stor.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,39 @@ def get_cluster_used_capacity(self, cluster_name):
get_virtual_volume_summary_resp(cluster_name)
try:
custom_data = resposne_summary.get("custom-data")
find_capacity = re.findall(
r"capacity\s+is\s+(([0-9]*(\.[0-9]{1,3}))|([0-9]+))",
custom_data)
find_capacity = re.findall(r"capacity\s+is\s+(("
r"[0-9]*(\.[0-9]{1,3})"
r"[a-zA-Z])|([0-9]+)[a-zA-Z])",
custom_data)
find_capacity_str = find_capacity[-1][0]
find_capacity_float = float(find_capacity_str)
capacity = int(find_capacity_float * units.Ti)
capacity = self.get_capacity_by_unit(find_capacity_str)
except Exception as e:
LOG.error("Storage used capacity, cluster %s analyse error %s" %
cluster_name, six.text_type(e))
raise e
return capacity

def get_capacity_by_unit(self, find_capacity_str):
if 'G' in find_capacity_str:
find_capacity_float = float(
find_capacity_str[:find_capacity_str.index('G')])
capacity = int(find_capacity_float * units.Gi)
elif 'T' in find_capacity_str:
find_capacity_float = float(
find_capacity_str[:find_capacity_str.index('T')])
capacity = int(find_capacity_float * units.Ti)
elif 'M' in find_capacity_str:
find_capacity_float = float(
find_capacity_str[:find_capacity_str.index('M')])
capacity = int(find_capacity_float * units.Mi)
elif 'K' in find_capacity_str:
find_capacity_float = float(
find_capacity_str[:find_capacity_str.index('K')])
capacity = int(find_capacity_float * units.Ki)
else:
capacity = int(find_capacity_str)
return capacity

def list_controllers(self, context):
"""List all storage controllers from storage system."""
ct_list = []
Expand Down Expand Up @@ -711,16 +732,3 @@ def get_attributes_from_response(response):
child_map[name] = value
attributes_list.append(child_map)
return attributes_list


@staticmethod
def handle_detail_list(detail_info, detail_map, split):
detail_arr = detail_info.split('\n')
for detail in detail_arr:
if detail is not None and detail != '':
strinfo = detail.split(split, 1)
key = strinfo[0]
value = ''
if len(strinfo) > 1:
value = strinfo[1]
detail_map[key] = value