Fix divide zero error when no object storage cost

Change-Id: I6018678aac7367c5fbe4d169509feff1f262d05d
This commit is contained in:
Feilong Wang 2017-09-26 16:25:27 +13:00
parent d7282f9d15
commit aa78a20f66
1 changed files with 3 additions and 1 deletions

View File

@ -155,7 +155,9 @@ def _wash_details(current_details):
# NOTE(flwang): Currently, the breakdown will accumulate all the object # NOTE(flwang): Currently, the breakdown will accumulate all the object
# storage cost, so we need to deduce the duplicated part. # storage cost, so we need to deduce the duplicated part.
object_cost = current_details["breakdown"].get(OBJECTSTORAGE_CATEGORY, 0) object_cost = current_details["breakdown"].get(OBJECTSTORAGE_CATEGORY, 0)
dup_object_cost = (region_count - 1) * (object_cost / region_count)
dup_object_cost = (0 if region_count == 0 else
(region_count - 1) * (object_cost / region_count))
current_details["total_cost"] = (current_details["total_cost"] - current_details["total_cost"] = (current_details["total_cost"] -
dup_object_cost) dup_object_cost)
return current_details return current_details