diff --git a/qubes/api/admin.py b/qubes/api/admin.py index 80408dff..ddf620ae 100644 --- a/qubes/api/admin.py +++ b/qubes/api/admin.py @@ -607,14 +607,13 @@ class QubesAdminAPI(qubes.api.AbstractQubesAPI): self.fire_event_for_permission(pool=pool) other_info = '' - try: - other_info += 'size={}\n'.format(pool.size) - except NotImplementedError: - pass - try: - other_info += 'usage={}\n'.format(pool.usage) - except NotImplementedError: - pass + pool_size = pool.size + if pool_size is not None: + other_info += 'size={}\n'.format(pool_size) + + pool_usage = pool.usage + if pool_usage is not None: + other_info += 'usage={}\n'.format(pool_usage) try: included_in = pool.included_in(self.app) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index 45eb79ae..fdcdceb5 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -828,13 +828,13 @@ class Pool(object): @property def size(self): - ''' Storage pool size in bytes ''' - raise self._not_implemented("size") + ''' Storage pool size in bytes, or None if unknown ''' + return None @property def usage(self): - ''' Space used in the pool, in bytes ''' - raise self._not_implemented("usage") + ''' Space used in the pool in bytes, or None if unknown ''' + return None def _not_implemented(self, method_name): ''' Helper for emitting helpful `NotImplementedError` exceptions ''' diff --git a/qubes/tests/api_admin.py b/qubes/tests/api_admin.py index 998587ce..1a658880 100644 --- a/qubes/tests/api_admin.py +++ b/qubes/tests/api_admin.py @@ -567,13 +567,10 @@ class TC_00_VMs(AdminAPITestCase): def test_151_pool_info_unsupported_size(self): self.app.pools = { 'pool1': unittest.mock.Mock(config={ - 'param1': 'value1', 'param2': 'value2'}) + 'param1': 'value1', 'param2': 'value2'}, + size=None, usage=None), } self.app.pools['pool1'].included_in.return_value = None - type(self.app.pools['pool1']).size = unittest.mock.PropertyMock( - side_effect=NotImplementedError) - type(self.app.pools['pool1']).usage = unittest.mock.PropertyMock( - side_effect=NotImplementedError) value = self.call_mgmt_func(b'admin.pool.Info', b'dom0', b'pool1') self.assertEqual(value,