Fix wrong capacity in pool_stat for DellEMC manila drivers.

DellEMC manila drivers have bugs in returning capacity in pool_stat.
The current powermax/vnx manila return size in MB and unity manila
returns size in bytes.

Change-Id: I1a2c28548d02eee6632313a41a5c4d8ab6ad9532
Closes-bug: #1890372
Closes-bug: #1890375
Closes-bug: #1890376
(cherry picked from commit 53f756d065)
(cherry picked from commit ba00d1b9ab)
This commit is contained in:
Sam Wan 2020-08-05 04:06:08 -04:00
parent 483d5b214c
commit a6e3474d31
9 changed files with 69 additions and 19 deletions

View File

@ -20,6 +20,7 @@ from oslo_log import log
from oslo_utils import fnmatch
from oslo_utils import netutils
from oslo_utils import timeutils
from oslo_utils import units
import ssl
CONF = cfg.CONF
@ -179,3 +180,11 @@ def export_unc_path(ip_addr):
if netutils.is_valid_ipv6(ip_addr):
ip_addr = ip_addr.replace(':', '-') + unc_suffix
return ip_addr
def bytes_to_gb(size):
return round(float(size) / units.Gi, 2)
def mb_to_gb(size):
return bytes_to_gb(size * units.Mi)

View File

@ -631,8 +631,9 @@ class PowerMaxStorageConnection(driver.StorageConnection):
pool_stat = {
'pool_name': pool['name'],
'total_capacity_gb': total_size,
'free_capacity_gb': total_size - used_size,
'total_capacity_gb': enas_utils.mb_to_gb(total_size),
'free_capacity_gb':
enas_utils.mb_to_gb(total_size - used_size),
'qos': False,
'reserved_percentage': self.reserved_percentage,
'snapshot_support': True,

View File

@ -418,10 +418,12 @@ class UnityStorageConnection(driver.StorageConnection):
pool_stat = {
'pool_name': pool.name,
'thin_provisioning': True,
'total_capacity_gb': total_size,
'free_capacity_gb': total_size - used_size,
'allocated_capacity_gb': used_size,
'provisioned_capacity_gb': float(pool.size_subscribed),
'total_capacity_gb': enas_utils.bytes_to_gb(total_size),
'free_capacity_gb':
enas_utils.bytes_to_gb(total_size - used_size),
'allocated_capacity_gb': enas_utils.bytes_to_gb(used_size),
'provisioned_capacity_gb':
enas_utils.bytes_to_gb(pool.size_subscribed),
'qos': False,
'reserved_percentage': self.reserved_percentage,
'max_over_subscription_ratio':

View File

@ -624,8 +624,9 @@ class VNXStorageConnection(driver.StorageConnection):
pool_stat = dict(
pool_name=pool['name'],
total_capacity_gb=total_size,
free_capacity_gb=total_size - used_size,
total_capacity_gb=enas_utils.mb_to_gb(total_size),
free_capacity_gb=enas_utils.mb_to_gb(
total_size - used_size),
qos=False,
reserved_percentage=self.reserved_percentage,
)

View File

@ -139,3 +139,19 @@ class ExportUncPathTestCase(test.TestCase):
@ddt.unpack
def test_invalid_ipv6_addr(self, ip_addr):
self.assertEqual(ip_addr, utils.export_unc_path(ip_addr))
@ddt.ddt
class SizeToGbTestCase(test.TestCase):
@ddt.data({'size_in_bytes': 1073741824, 'size_in_gb': 1.0},
{'size_in_bytes': 5610301030, 'size_in_gb': 5.22})
@ddt.unpack
def test_bytes_to_gb(self, size_in_bytes, size_in_gb):
self.assertEqual(size_in_gb, utils.bytes_to_gb(size_in_bytes))
@ddt.data({'size_in_mb': 1024, 'size_in_gb': 1.0},
{'size_in_mb': 5346, 'size_in_gb': 5.22})
@ddt.unpack
def test_mb_to_gb(self, size_in_mb, size_in_gb):
self.assertEqual(size_in_gb, utils.mb_to_gb(size_in_mb))

View File

@ -21,6 +21,7 @@ from oslo_log import log
from manila import exception
from manila.share.drivers.dell_emc.common.enas import connector
from manila.share.drivers.dell_emc.common.enas import utils as enas_utils
from manila.share.drivers.dell_emc.plugins.vnx import connection
from manila.share.drivers.dell_emc.plugins.vnx import object_manager
from manila import test
@ -2212,12 +2213,14 @@ class StorageConnectionTestCase(test.TestCase):
for pool in fakes.STATS['pools']:
if pool['pool_name'] == fakes.FakeData.pool_name:
self.assertEqual(fakes.FakeData.pool_total_size,
pool['total_capacity_gb'])
self.assertEqual(
enas_utils.mb_to_gb(fakes.FakeData.pool_total_size),
pool['total_capacity_gb'])
free_size = (fakes.FakeData.pool_total_size -
fakes.FakeData.pool_used_size)
self.assertEqual(free_size, pool['free_capacity_gb'])
self.assertEqual(enas_utils.mb_to_gb(free_size),
pool['free_capacity_gb'])
def test_update_share_stats_without_matched_config_pools(self):
self.connection.pools = set('fake_pool')

View File

@ -16,14 +16,15 @@
import copy
import ddt
import mock
from oslo_utils import units
import six
from manila import exception
from manila.share.drivers.dell_emc.common.enas import utils as enas_utils
from manila import test
from manila.tests.share.drivers.dell_emc.plugins.unity import fake_exceptions
from manila.tests.share.drivers.dell_emc.plugins.unity import res_mock
from manila.tests.share.drivers.dell_emc.plugins.unity import utils
from oslo_utils import units
@ddt.ddt
@ -289,14 +290,18 @@ class TestConnection(test.TestCase):
self.assertEqual(5, len(stat_dict))
pool = stat_dict['pools'][0]
self.assertEqual('pool_1', pool['pool_name'])
self.assertEqual(500000.0, pool['total_capacity_gb'])
self.assertEqual(
enas_utils.bytes_to_gb(500000.0), pool['total_capacity_gb'])
self.assertEqual(False, pool['qos'])
self.assertEqual(30000.0, pool['provisioned_capacity_gb'])
self.assertEqual(
enas_utils.bytes_to_gb(30000.0), pool['provisioned_capacity_gb'])
self.assertEqual(20, pool['max_over_subscription_ratio'])
self.assertEqual(10000.0, pool['allocated_capacity_gb'])
self.assertEqual(
enas_utils.bytes_to_gb(10000.0), pool['allocated_capacity_gb'])
self.assertEqual(0, pool['reserved_percentage'])
self.assertTrue(pool['thin_provisioning'])
self.assertEqual(490000.0, pool['free_capacity_gb'])
self.assertEqual(
enas_utils.bytes_to_gb(490000.0), pool['free_capacity_gb'])
@res_mock.patch_connection
def test_update_share_stats__nonexistent_pools(self, connection):

View File

@ -21,6 +21,7 @@ from oslo_log import log
from manila import exception
from manila.share.drivers.dell_emc.common.enas import connector
from manila.share.drivers.dell_emc.common.enas import utils as enas_utils
from manila.share.drivers.dell_emc.plugins.vnx import connection
from manila.share.drivers.dell_emc.plugins.vnx import object_manager
from manila import test
@ -2212,12 +2213,14 @@ class StorageConnectionTestCase(test.TestCase):
for pool in fakes.STATS['pools']:
if pool['pool_name'] == fakes.FakeData.pool_name:
self.assertEqual(fakes.FakeData.pool_total_size,
pool['total_capacity_gb'])
self.assertEqual(
enas_utils.mb_to_gb(fakes.FakeData.pool_total_size),
pool['total_capacity_gb'])
free_size = (fakes.FakeData.pool_total_size -
fakes.FakeData.pool_used_size)
self.assertEqual(free_size, pool['free_capacity_gb'])
self.assertEqual(
enas_utils.mb_to_gb(free_size), pool['free_capacity_gb'])
def test_update_share_stats_without_matched_config_pools(self):
self.connection.pools = set('fake_pool')

View File

@ -0,0 +1,10 @@
---
fixes:
- |
Dell EMC Manila Driver: Fixes wrong capacity in pool_stat.
`bug 1890372 <https://bugs.launchpad.net/manila/+bug/1890372>`_
powermax manila return size in MB,
`bug 1890375 <https://bugs.launchpad.net/manila/+bug/1890375>`_
vnx manila return size in MB,
`bug 1890376 <https://bugs.launchpad.net/manila/+bug/1890376>`_
unity manila return size in bytes.