]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commit
Fix capacity report error in Huawei driver
authorWilson Liu <liuxinguo@huawei.com>
Tue, 22 Sep 2015 12:52:36 +0000 (20:52 +0800)
committerWilson Liu <liuxinguo@huawei.com>
Mon, 5 Oct 2015 09:44:17 +0000 (17:44 +0800)
commit3a12a256a1d95a86939afb63d7fafa717becdb86
tree4be93b0c9a88729584854f78bbb780672cc2cee1
parenta9aab612c0546afd2fb2e22dc0eff2b8c75bb2ed
Fix capacity report error in Huawei driver

Currently the capacity report is incorrect due
to wrong way code clear.

The previously right way is:
result = var / 1024.0 / 1024.0 / 2

But currently we use a constant CAPACITY_UNIT to make the code cleaner
like this:
CAPACITY_UNIT = 1024.0 / 1024.0 / 2
result = var / CAPACITY_UNIT
We want the CAPACITY_UNIT work like a *real* constant like C
language, but in python, it is not a *real* constant, it's
just a variable. It will calculate the CAPACITY_UNIT first,
so the finally result is:
result = var / 0.5
And this is wrong.

This patch will fix this.

Closes-Bug: #1498452
Change-Id: I4dc20ef8805d7c414fedb1dc441deb3f9fcd75b5
cinder/tests/unit/test_huawei_drivers.py
cinder/volume/drivers/huawei/constants.py