Skip to content

Commit

Permalink
Merge pull request #13 from Huawei/2.1.0
Browse files Browse the repository at this point in the history
2.1.0
  • Loading branch information
doubletao318 authored Apr 10, 2020
2 parents 1be04d2 + d4811c0 commit 5b6e890
Show file tree
Hide file tree
Showing 20 changed files with 203 additions and 61 deletions.
4 changes: 2 additions & 2 deletions Cinder/Newton/huawei_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ def _get_opts_from_specs(self, opts_capability, opts_value,
"replication_type='<in> sync' or "
"'<in> async'.")
else:
LOG.error("Extra specs must be specified as "
"capabilities:%s='<is> True'.", key)
LOG.warning("Extra specs must be specified as "
"capabilities:%s='<is> True'.", key)

if ((scope in opts_capability)
and (key in opts_value)
Expand Down
14 changes: 12 additions & 2 deletions Cinder/Newton/huawei_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,19 @@ def get_lun_metadata(volume):
if not volume.provider_location:
return {}

info = json.loads(volume.provider_location)
try:
info = json.loads(volume.provider_location)
except Exception as err:
LOG.warning("get_lun_metadata get provider_location error, params: "
"%(loc)s, reason: %(err)s",
{"loc": volume.provider_location, "err": err})
return {}

if isinstance(info, dict):
return info
if "huawei" in volume.provider_location:
return info
else:
return {}

# To keep compatible with old driver version
admin_metadata = get_admin_metadata(volume)
Expand Down
22 changes: 20 additions & 2 deletions Cinder/Newton/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ def get_pool_by_name(self, pool_name):
if result.get('data'):
return result['data'][0]

@staticmethod
def _get_capacity_info(info, pool):
info['CAPACITY'] = pool.get('DATASPACE', pool['USERFREECAPACITY'])
info['TOTALCAPACITY'] = pool['USERTOTALCAPACITY']
if 'totalSizeWithoutSnap' in pool:
info['LUNCONFIGEDCAPACITY'] = pool['totalSizeWithoutSnap']
elif 'LUNCONFIGEDCAPACITY' in pool:
info['LUNCONFIGEDCAPACITY'] = pool['LUNCONFIGEDCAPACITY']
return info

def get_pool_info(self, pool_name=None, pools=None):
info = {}
if not pool_name:
Expand All @@ -356,11 +366,10 @@ def get_pool_info(self, pool_name=None, pools=None):
break

info['ID'] = pool.get('ID')
info['CAPACITY'] = pool.get('DATASPACE', pool['USERFREECAPACITY'])
info['TOTALCAPACITY'] = pool.get('USERTOTALCAPACITY')
info['TIER0CAPACITY'] = pool.get('TIER0CAPACITY')
info['TIER1CAPACITY'] = pool.get('TIER1CAPACITY')
info['TIER2CAPACITY'] = pool.get('TIER2CAPACITY')
self._get_capacity_info(info, pool)

return info

Expand Down Expand Up @@ -1200,6 +1209,12 @@ def _get_capacity(self, pool_name, result):
pool_capacity['total_capacity'] = total
pool_capacity['free_capacity'] = free

configed_capacity = pool_info.get('LUNCONFIGEDCAPACITY')
if configed_capacity:
provisioned = float(
configed_capacity) / constants.CAPACITY_UNIT
pool_capacity['provisioned_capacity'] = provisioned

return pool_capacity

def _get_disk_type(self, pool_name, result):
Expand Down Expand Up @@ -1337,6 +1352,9 @@ def update_volume_stats(self):
'max_over_subscription_ratio'),
smarttier=tier_support
))
if capacity.get('provisioned_capacity'):
pool['provisioned_capacity_gb'] = capacity[
'provisioned_capacity']
if disk_type:
pool['disk_type'] = disk_type

Expand Down
4 changes: 2 additions & 2 deletions Cinder/Ocata/huawei_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ def _get_opts_from_specs(self, opts_capability, opts_value,
"replication_type='<in> sync' or "
"'<in> async'.")
else:
LOG.error("Extra specs must be specified as "
"capabilities:%s='<is> True'.", key)
LOG.warning("Extra specs must be specified as "
"capabilities:%s='<is> True'.", key)

if ((scope in opts_capability)
and (key in opts_value)
Expand Down
14 changes: 12 additions & 2 deletions Cinder/Ocata/huawei_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,19 @@ def get_lun_metadata(volume):
if not volume.provider_location:
return {}

info = json.loads(volume.provider_location)
try:
info = json.loads(volume.provider_location)
except Exception as err:
LOG.warning("get_lun_metadata get provider_location error, params: "
"%(loc)s, reason: %(err)s",
{"loc": volume.provider_location, "err": err})
return {}

if isinstance(info, dict):
return info
if "huawei" in volume.provider_location:
return info
else:
return {}

# To keep compatible with old driver version
admin_metadata = get_admin_metadata(volume)
Expand Down
22 changes: 20 additions & 2 deletions Cinder/Ocata/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ def get_pool_by_name(self, pool_name):
if result.get('data'):
return result['data'][0]

@staticmethod
def _get_capacity_info(info, pool):
info['CAPACITY'] = pool.get('DATASPACE', pool['USERFREECAPACITY'])
info['TOTALCAPACITY'] = pool['USERTOTALCAPACITY']
if 'totalSizeWithoutSnap' in pool:
info['LUNCONFIGEDCAPACITY'] = pool['totalSizeWithoutSnap']
elif 'LUNCONFIGEDCAPACITY' in pool:
info['LUNCONFIGEDCAPACITY'] = pool['LUNCONFIGEDCAPACITY']
return info

def get_pool_info(self, pool_name=None, pools=None):
info = {}
if not pool_name:
Expand All @@ -356,11 +366,10 @@ def get_pool_info(self, pool_name=None, pools=None):
break

info['ID'] = pool.get('ID')
info['CAPACITY'] = pool.get('DATASPACE', pool['USERFREECAPACITY'])
info['TOTALCAPACITY'] = pool.get('USERTOTALCAPACITY')
info['TIER0CAPACITY'] = pool.get('TIER0CAPACITY')
info['TIER1CAPACITY'] = pool.get('TIER1CAPACITY')
info['TIER2CAPACITY'] = pool.get('TIER2CAPACITY')
self._get_capacity_info(info, pool)

return info

Expand Down Expand Up @@ -1200,6 +1209,12 @@ def _get_capacity(self, pool_name, result):
pool_capacity['total_capacity'] = total
pool_capacity['free_capacity'] = free

configed_capacity = pool_info.get('LUNCONFIGEDCAPACITY')
if configed_capacity:
provisioned = float(
configed_capacity) / constants.CAPACITY_UNIT
pool_capacity['provisioned_capacity'] = provisioned

return pool_capacity

def _get_disk_type(self, pool_name, result):
Expand Down Expand Up @@ -1337,6 +1352,9 @@ def update_volume_stats(self):
'max_over_subscription_ratio'),
smarttier=tier_support
))
if capacity.get('provisioned_capacity'):
pool['provisioned_capacity_gb'] = capacity[
'provisioned_capacity']
if disk_type:
pool['disk_type'] = disk_type

Expand Down
23 changes: 10 additions & 13 deletions Cinder/Pike/huawei_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ def _get_opts_from_specs(self, opts_capability, opts_value,
"replication_type='<in> sync' or "
"'<in> async'.")
else:
LOG.error("Extra specs must be specified as "
"capabilities:%s='<is> True'.", key)
LOG.warning("Extra specs must be specified as "
"capabilities:%s='<is> True'.", key)

if ((scope in opts_capability)
and (key in opts_value)
Expand Down Expand Up @@ -816,24 +816,21 @@ def delete_volume(self, volume):
if not lun_id:
return

if self.support_func.get('QoS_support'):
qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)

qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)
self._delete_volume(volume, lun_id)

def _delete_lun_with_check(self, lun_id, lun_wwn=None):
if not lun_id:
return

if self.client.check_lun_exist(lun_id, lun_wwn):
if self.support_func.get('QoS_support'):
qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)
qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)

self.client.delete_lun(lun_id)

Expand Down
14 changes: 12 additions & 2 deletions Cinder/Pike/huawei_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,19 @@ def get_lun_metadata(volume):
if not volume.provider_location:
return {}

info = json.loads(volume.provider_location)
try:
info = json.loads(volume.provider_location)
except Exception as err:
LOG.warning("get_lun_metadata get provider_location error, params: "
"%(loc)s, reason: %(err)s",
{"loc": volume.provider_location, "err": err})
return {}

if isinstance(info, dict):
return info
if "huawei" in volume.provider_location:
return info
else:
return {}

# To keep compatible with old driver version
admin_metadata = get_admin_metadata(volume)
Expand Down
22 changes: 20 additions & 2 deletions Cinder/Pike/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ def get_pool_by_name(self, pool_name):
if result.get('data'):
return result['data'][0]

@staticmethod
def _get_capacity_info(info, pool):
info['CAPACITY'] = pool.get('DATASPACE', pool['USERFREECAPACITY'])
info['TOTALCAPACITY'] = pool['USERTOTALCAPACITY']
if 'totalSizeWithoutSnap' in pool:
info['LUNCONFIGEDCAPACITY'] = pool['totalSizeWithoutSnap']
elif 'LUNCONFIGEDCAPACITY' in pool:
info['LUNCONFIGEDCAPACITY'] = pool['LUNCONFIGEDCAPACITY']
return info

def get_pool_info(self, pool_name=None, pools=None):
info = {}
if not pool_name:
Expand All @@ -351,11 +361,10 @@ def get_pool_info(self, pool_name=None, pools=None):
break

info['ID'] = pool.get('ID')
info['CAPACITY'] = pool.get('DATASPACE', pool['USERFREECAPACITY'])
info['TOTALCAPACITY'] = pool.get('USERTOTALCAPACITY')
info['TIER0CAPACITY'] = pool.get('TIER0CAPACITY')
info['TIER1CAPACITY'] = pool.get('TIER1CAPACITY')
info['TIER2CAPACITY'] = pool.get('TIER2CAPACITY')
self._get_capacity_info(info, pool)

return info

Expand Down Expand Up @@ -1195,6 +1204,12 @@ def _get_capacity(self, pool_name, result):
pool_capacity['total_capacity'] = total
pool_capacity['free_capacity'] = free

configed_capacity = pool_info.get('LUNCONFIGEDCAPACITY')
if configed_capacity:
provisioned = float(
configed_capacity) / constants.CAPACITY_UNIT
pool_capacity['provisioned_capacity'] = provisioned

return pool_capacity

def _get_disk_type(self, pool_name, result):
Expand Down Expand Up @@ -1332,6 +1347,9 @@ def update_volume_stats(self):
'max_over_subscription_ratio'),
smarttier=tier_support
))
if capacity.get('provisioned_capacity'):
pool['provisioned_capacity_gb'] = capacity[
'provisioned_capacity']
if disk_type:
pool['disk_type'] = disk_type

Expand Down
23 changes: 10 additions & 13 deletions Cinder/Queens/huawei_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ def _get_opts_from_specs(self, opts_capability, opts_value,
"replication_type='<in> sync' or "
"'<in> async'.")
else:
LOG.error("Extra specs must be specified as "
"capabilities:%s='<is> True'.", key)
LOG.warning("Extra specs must be specified as "
"capabilities:%s='<is> True'.", key)

if ((scope in opts_capability)
and (key in opts_value)
Expand Down Expand Up @@ -816,24 +816,21 @@ def delete_volume(self, volume):
if not lun_id:
return

if self.support_func.get('QoS_support'):
qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)

qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)
self._delete_volume(volume, lun_id)

def _delete_lun_with_check(self, lun_id, lun_wwn=None):
if not lun_id:
return

if self.client.check_lun_exist(lun_id, lun_wwn):
if self.support_func.get('QoS_support'):
qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)
qos_id = self.client.get_qosid_by_lunid(lun_id)
if qos_id:
smart_qos = smartx.SmartQos(self.client)
smart_qos.remove(qos_id, lun_id)

self.client.delete_lun(lun_id)

Expand Down
14 changes: 12 additions & 2 deletions Cinder/Queens/huawei_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,19 @@ def get_lun_metadata(volume):
if not volume.provider_location:
return {}

info = json.loads(volume.provider_location)
try:
info = json.loads(volume.provider_location)
except Exception as err:
LOG.warning("get_lun_metadata get provider_location error, params: "
"%(loc)s, reason: %(err)s",
{"loc": volume.provider_location, "err": err})
return {}

if isinstance(info, dict):
return info
if "huawei" in volume.provider_location:
return info
else:
return {}

# To keep compatible with old driver version
admin_metadata = get_admin_metadata(volume)
Expand Down
Loading

0 comments on commit 5b6e890

Please sign in to comment.