RemoteFS: Use summarize option for "du"
Only return the total from du rather than a full listing. The parsing code here expects du's output to only be one line. Closes-Bug: #1781276 Change-Id: Id398ad1ce3f30ccc029bfcfb1663654946d42c91
This commit is contained in:
parent
7a403f5fdf
commit
48a61877ce
@ -692,6 +692,20 @@ class NfsDriverTestCase(test.TestCase):
|
|||||||
provider_location=loc,
|
provider_location=loc,
|
||||||
size=size)
|
size=size)
|
||||||
|
|
||||||
|
def test_get_provisioned_capacity(self):
|
||||||
|
self._set_driver()
|
||||||
|
drv = self._driver
|
||||||
|
|
||||||
|
mock_execute = self.mock_object(drv, '_execute')
|
||||||
|
mock_execute.return_value = ("148418423\t/dir", "")
|
||||||
|
|
||||||
|
with mock.patch.object(drv, 'shares') as shares:
|
||||||
|
shares.keys.return_value = {'192.0.2.1:/srv/nfs1'}
|
||||||
|
shares.return_value = {'192.0.2.1:/srv/nfs1', ''}
|
||||||
|
ret = drv._get_provisioned_capacity()
|
||||||
|
|
||||||
|
self.assertEqual(ret, 0.14)
|
||||||
|
|
||||||
def test_create_sparsed_volume(self):
|
def test_create_sparsed_volume(self):
|
||||||
self._set_driver()
|
self._set_driver()
|
||||||
drv = self._driver
|
drv = self._driver
|
||||||
|
@ -217,7 +217,7 @@ class RemoteFSDriver(driver.BaseVD):
|
|||||||
provisioned_size = 0.0
|
provisioned_size = 0.0
|
||||||
for share in self.shares.keys():
|
for share in self.shares.keys():
|
||||||
mount_path = self._get_mount_point_for_share(share)
|
mount_path = self._get_mount_point_for_share(share)
|
||||||
out, _ = self._execute('du', '--bytes', mount_path,
|
out, _ = self._execute('du', '--bytes', '-s', mount_path,
|
||||||
run_as_root=self._execute_as_root)
|
run_as_root=self._execute_as_root)
|
||||||
provisioned_size += int(out.split()[0])
|
provisioned_size += int(out.split()[0])
|
||||||
return round(provisioned_size / units.Gi, 2)
|
return round(provisioned_size / units.Gi, 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user