api/admin: add 'included_in' to admin.pool.Info call
QubesOS/qubes-issues#3240 QubesOS/qubes-issues#3241
This commit is contained in:
parent
d40fae9756
commit
1bc640f3e0
@ -606,19 +606,26 @@ class QubesAdminAPI(qubes.api.AbstractQubesAPI):
|
|||||||
|
|
||||||
self.fire_event_for_permission(pool=pool)
|
self.fire_event_for_permission(pool=pool)
|
||||||
|
|
||||||
size_info = ''
|
other_info = ''
|
||||||
try:
|
try:
|
||||||
size_info += 'size={}\n'.format(pool.size)
|
other_info += 'size={}\n'.format(pool.size)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
size_info += 'usage={}\n'.format(pool.usage)
|
other_info += 'usage={}\n'.format(pool.usage)
|
||||||
|
except NotImplementedError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
included_in = pool.included_in(self.app)
|
||||||
|
if included_in:
|
||||||
|
other_info += 'included_in={}\n'.format(str(included_in))
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return ''.join('{}={}\n'.format(prop, val)
|
return ''.join('{}={}\n'.format(prop, val)
|
||||||
for prop, val in sorted(pool.config.items())) + \
|
for prop, val in sorted(pool.config.items())) + \
|
||||||
size_info
|
other_info
|
||||||
|
|
||||||
@qubes.api.method('admin.pool.Add',
|
@qubes.api.method('admin.pool.Add',
|
||||||
scope='global', write=True)
|
scope='global', write=True)
|
||||||
|
@ -557,6 +557,7 @@ class TC_00_VMs(AdminAPITestCase):
|
|||||||
usage=102400,
|
usage=102400,
|
||||||
size=204800)
|
size=204800)
|
||||||
}
|
}
|
||||||
|
self.app.pools['pool1'].included_in.return_value = None
|
||||||
value = self.call_mgmt_func(b'admin.pool.Info', b'dom0', b'pool1')
|
value = self.call_mgmt_func(b'admin.pool.Info', b'dom0', b'pool1')
|
||||||
|
|
||||||
self.assertEqual(value,
|
self.assertEqual(value,
|
||||||
@ -568,6 +569,7 @@ class TC_00_VMs(AdminAPITestCase):
|
|||||||
'pool1': unittest.mock.Mock(config={
|
'pool1': unittest.mock.Mock(config={
|
||||||
'param1': 'value1', 'param2': 'value2'})
|
'param1': 'value1', 'param2': 'value2'})
|
||||||
}
|
}
|
||||||
|
self.app.pools['pool1'].included_in.return_value = None
|
||||||
type(self.app.pools['pool1']).size = unittest.mock.PropertyMock(
|
type(self.app.pools['pool1']).size = unittest.mock.PropertyMock(
|
||||||
side_effect=NotImplementedError)
|
side_effect=NotImplementedError)
|
||||||
type(self.app.pools['pool1']).usage = unittest.mock.PropertyMock(
|
type(self.app.pools['pool1']).usage = unittest.mock.PropertyMock(
|
||||||
@ -578,6 +580,24 @@ class TC_00_VMs(AdminAPITestCase):
|
|||||||
'param1=value1\nparam2=value2\n')
|
'param1=value1\nparam2=value2\n')
|
||||||
self.assertFalse(self.app.save.called)
|
self.assertFalse(self.app.save.called)
|
||||||
|
|
||||||
|
def test_152_pool_info_included_in(self):
|
||||||
|
self.app.pools = {
|
||||||
|
'pool1': unittest.mock.MagicMock(config={
|
||||||
|
'param1': 'value1',
|
||||||
|
'param2': 'value2'},
|
||||||
|
usage=102400,
|
||||||
|
size=204800)
|
||||||
|
}
|
||||||
|
self.app.pools['pool1'].included_in.return_value = \
|
||||||
|
self.app.pools['pool1']
|
||||||
|
self.app.pools['pool1'].__str__.return_value = 'pool1'
|
||||||
|
value = self.call_mgmt_func(b'admin.pool.Info', b'dom0', b'pool1')
|
||||||
|
|
||||||
|
self.assertEqual(value,
|
||||||
|
'param1=value1\nparam2=value2\nsize=204800\nusage=102400'
|
||||||
|
'\nincluded_in=pool1\n')
|
||||||
|
self.assertFalse(self.app.save.called)
|
||||||
|
|
||||||
@unittest.mock.patch('qubes.storage.pool_drivers')
|
@unittest.mock.patch('qubes.storage.pool_drivers')
|
||||||
@unittest.mock.patch('qubes.storage.driver_parameters')
|
@unittest.mock.patch('qubes.storage.driver_parameters')
|
||||||
def test_160_pool_add(self, mock_parameters, mock_drivers):
|
def test_160_pool_add(self, mock_parameters, mock_drivers):
|
||||||
|
Loading…
Reference in New Issue
Block a user