Merge "[Container driver] Fix volume group data collection"

This commit is contained in:
Zuul 2018-10-03 15:59:08 +00:00 committed by Gerrit Code Review
commit 82b6618202
3 changed files with 25 additions and 8 deletions

View File

@ -52,9 +52,19 @@ class LVMHelper(driver.ExecuteMixin):
def get_share_server_pools(self, share_server=None):
out, err = self._execute('vgs',
self.configuration.container_volume_group,
'--rows', run_as_root=True)
total_size = re.findall("VSize\s[0-9.]+g", out)[0][6:-1]
free_size = re.findall("VFree\s[0-9.]+g", out)[0][6:-1]
'--options', 'vg_size,vg_free',
'--noheadings',
'--units', 'g',
run_as_root=True)
if err:
msg = _("Unable to gather size of the volume group %(vg)s to be "
"used by the driver. Error: %(err)s")
raise exception.ShareBackendException(
msg % {'vg': self.configuration.container_volume_group,
'err': err})
(free_size, total_size) = sorted(re.findall("\d+\.\d+|\d+", out),
reverse=False)
return [{
'pool_name': self.configuration.container_volume_group,
'total_capacity_gb': float(total_size),

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
"""Unit tests for the Storage helper module."""
import ddt
import functools
import mock
@ -24,6 +24,7 @@ from manila import test
from manila.tests.share.drivers.container.fakes import fake_share
@ddt.ddt
class LVMHelperTestCase(test.TestCase):
"""Tests ContainerShareDriver"""
@ -46,12 +47,12 @@ class LVMHelperTestCase(test.TestCase):
storage_helper.LVMHelper,
None)
def test_get_share_server_pools(self):
ret_vgs = "VSize 100g size\nVFree 100g whatever"
@ddt.data("62.50g 72.50g", " 72.50g 62.50g\n", " <62.50g <72.50g\n")
def test_get_share_server_pools(self, ret_vgs):
expected_result = [{'reserved_percentage': 0,
'pool_name': 'manila_docker_volumes',
'total_capacity_gb': 100.0,
'free_capacity_gb': 100.0}]
'total_capacity_gb': 72.5,
'free_capacity_gb': 62.5}]
self.mock_object(self.LVMHelper, "_execute",
mock.Mock(return_value=(ret_vgs, 0)))

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Pool stats collection has been fixed in the container driver to reflect
the differences in formatting of information for the underlying volume
groups across different operating systems.