[Container driver] Fix volume group data collection
On different distros, the vgs command may have a different format. So, lets ask very specific questions about the total and free size, and use that response. Change-Id: I36e5e3ba7be562846687c7cc989028371efae2fc Needed-By: https://review.openstack.org/#/c/604929/ Closes-Bug: #1794402
This commit is contained in:
parent
5ef1a71dc4
commit
53d15d3bbe
@ -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),
|
||||
|
@ -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)))
|
||||
|
||||
|
@ -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.
|
Loading…
x
Reference in New Issue
Block a user