Browse Source

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)
(cherry picked from commit a6e3474d31)
(cherry picked from commit 184f2a6817)
changes/25/746825/1
Sam Wan 1 month ago
parent
commit
2f1bfb6ae9
9 changed files with 69 additions and 19 deletions
  1. +9
    -0
      manila/share/drivers/dell_emc/common/enas/utils.py
  2. +6
    -4
      manila/share/drivers/dell_emc/plugins/unity/connection.py
  3. +3
    -2
      manila/share/drivers/dell_emc/plugins/vmax/connection.py
  4. +3
    -2
      manila/share/drivers/dell_emc/plugins/vnx/connection.py
  5. +16
    -0
      manila/tests/share/drivers/dell_emc/common/enas/test_utils.py
  6. +10
    -5
      manila/tests/share/drivers/dell_emc/plugins/unity/test_connection.py
  7. +6
    -3
      manila/tests/share/drivers/dell_emc/plugins/vmax/test_connection.py
  8. +6
    -3
      manila/tests/share/drivers/dell_emc/plugins/vnx/test_connection.py
  9. +10
    -0
      releasenotes/releasenotes/notes/dellemc-fix-capacity-report-25f75a6c96e12b40.yaml

+ 9
- 0
manila/share/drivers/dell_emc/common/enas/utils.py 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)

+ 6
- 4
manila/share/drivers/dell_emc/plugins/unity/connection.py View File

@@ -371,10 +371,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':


+ 3
- 2
manila/share/drivers/dell_emc/plugins/vmax/connection.py View File

@@ -629,8 +629,9 @@ class VMAXStorageConnection(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,


+ 3
- 2
manila/share/drivers/dell_emc/plugins/vnx/connection.py 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,
)


+ 16
- 0
manila/tests/share/drivers/dell_emc/common/enas/test_utils.py 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))

+ 10
- 5
manila/tests/share/drivers/dell_emc/plugins/unity/test_connection.py 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
@@ -260,14 +261,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):


+ 6
- 3
manila/tests/share/drivers/dell_emc/plugins/vmax/test_connection.py 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')


+ 6
- 3
manila/tests/share/drivers/dell_emc/plugins/vnx/test_connection.py 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')


+ 10
- 0
releasenotes/releasenotes/notes/dellemc-fix-capacity-report-25f75a6c96e12b40.yaml 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.

Loading…
Cancel
Save