summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-07-12 03:00:17 +0000
committerGerrit Code Review <review@openstack.org>2018-07-12 03:00:17 +0000
commit70a809dd21acfdefe0e82621cd2fa2d44921c6e6 (patch)
treef44f395f7389092aff75128d571be90cb3821dc5
parent8ddca1ed55fe63ccf1b537e6c22960c9628224ff (diff)
parent48a61877cee8665c96a16025e33b693636e9a359 (diff)
Merge "RemoteFS: Use summarize option for "du""
-rw-r--r--cinder/tests/unit/volume/drivers/test_nfs.py14
-rw-r--r--cinder/volume/drivers/remotefs.py2
2 files changed, 15 insertions, 1 deletions
diff --git a/cinder/tests/unit/volume/drivers/test_nfs.py b/cinder/tests/unit/volume/drivers/test_nfs.py
index da76418..20ed172 100644
--- a/cinder/tests/unit/volume/drivers/test_nfs.py
+++ b/cinder/tests/unit/volume/drivers/test_nfs.py
@@ -692,6 +692,20 @@ class NfsDriverTestCase(test.TestCase):
692 provider_location=loc, 692 provider_location=loc,
693 size=size) 693 size=size)
694 694
695 def test_get_provisioned_capacity(self):
696 self._set_driver()
697 drv = self._driver
698
699 mock_execute = self.mock_object(drv, '_execute')
700 mock_execute.return_value = ("148418423\t/dir", "")
701
702 with mock.patch.object(drv, 'shares') as shares:
703 shares.keys.return_value = {'192.0.2.1:/srv/nfs1'}
704 shares.return_value = {'192.0.2.1:/srv/nfs1', ''}
705 ret = drv._get_provisioned_capacity()
706
707 self.assertEqual(ret, 0.14)
708
695 def test_create_sparsed_volume(self): 709 def test_create_sparsed_volume(self):
696 self._set_driver() 710 self._set_driver()
697 drv = self._driver 711 drv = self._driver
diff --git a/cinder/volume/drivers/remotefs.py b/cinder/volume/drivers/remotefs.py
index f5c5b6c..937041a 100644
--- a/cinder/volume/drivers/remotefs.py
+++ b/cinder/volume/drivers/remotefs.py
@@ -217,7 +217,7 @@ class RemoteFSDriver(driver.BaseVD):
217 provisioned_size = 0.0 217 provisioned_size = 0.0
218 for share in self.shares.keys(): 218 for share in self.shares.keys():
219 mount_path = self._get_mount_point_for_share(share) 219 mount_path = self._get_mount_point_for_share(share)
220 out, _ = self._execute('du', '--bytes', mount_path, 220 out, _ = self._execute('du', '--bytes', '-s', mount_path,
221 run_as_root=self._execute_as_root) 221 run_as_root=self._execute_as_root)
222 provisioned_size += int(out.split()[0]) 222 provisioned_size += int(out.split()[0])
223 return round(provisioned_size / units.Gi, 2) 223 return round(provisioned_size / units.Gi, 2)