qvm-ls: hide flags (aka status), get more descriptive

Enterprise™ continues.
This commit is contained in:
Wojtek Porczyk 2017-06-08 13:10:44 +02:00
parent 23fe5e431c
commit 59eda63923
2 changed files with 26 additions and 26 deletions

View File

@ -82,9 +82,9 @@ class TC_50_List(qubesadmin.tests.QubesTestCase):
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
qubesadmin.tools.qvm_ls.main([], app=app)
self.assertEqual(stdout.getvalue(),
'NAME STATUS LABEL TEMPLATE NETVM\n'
'dom0 -r------ black - -\n'
'test-vm -r------ green template sys-net\n')
'NAME STATE CLASS LABEL TEMPLATE NETVM\n'
'dom0 Running TestVM black - -\n'
'test-vm Running TestVM green template sys-net\n')
class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
@ -110,13 +110,7 @@ class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
'label': b'type=label green',
'template': b'type=vm template1',
'netvm': b'type=vm sys-net',
'updateable': b'type=bool False',
'provides_network': b'type=bool False',
'hvm': b'type=bool False',
'installed_by_rpm': b'type=bool False',
'internal': b'type=bool False',
'debug': b'type=bool False',
'autostart': b'type=bool False',
# 'hvm': b'type=bool False',
}
for key, value in props.items():
self.app.expected_calls[
@ -125,7 +119,6 @@ class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
# setup template1
props['label'] = b'type=label black'
props['updateable'] = b'type=bool True'
for key, value in props.items():
self.app.expected_calls[
('template1', 'admin.vm.property.Get', key, None)] = \
@ -136,8 +129,6 @@ class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
# setup sys-net
props['label'] = b'type=label red'
props['provides_network'] = b'type=bool True'
props['updateable'] = b'type=bool False'
for key, value in props.items():
self.app.expected_calls[
('sys-net', 'admin.vm.property.Get', key, None)] = \
@ -146,8 +137,8 @@ class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
qubesadmin.tools.qvm_ls.main([], app=self.app)
self.assertEqual(stdout.getvalue(),
'NAME STATUS LABEL TEMPLATE NETVM\n'
'sys-net ar-N---- red template1 sys-net\n'
'template1 t-U----- black - sys-net\n'
'vm1 ar------ green template1 sys-net\n')
'NAME STATE CLASS LABEL TEMPLATE NETVM\n'
'sys-net Running AppVM red template1 sys-net\n'
'template1 Halted TemplateVM black - sys-net\n'
'vm1 Running AppVM green template1 sys-net\n')
self.assertAllCalled()

View File

@ -191,13 +191,13 @@ def simple_flag(field, letter, attr, doc=None):
return helper
class StatusColumn(Column):
class FlagsColumn(Column):
'''Some fancy flags that describe general status of the domain.'''
# pylint: disable=no-self-use
def __init__(self):
super(StatusColumn, self).__init__(
head='STATUS',
super(FlagsColumn, self).__init__(
head='FLAGS',
doc=self.__class__.__doc__)
@ -333,6 +333,15 @@ def calc_used(vm, volume_name):
# todo maxmem
Column('STATE',
attr=(lambda vm: vm.get_power_state()),
doc='Current power state.')
Column('CLASS',
attr=(lambda vm: type(vm).__name__),
doc='Class of the qube.')
Column('GATEWAY',
attr='netvm.gateway',
doc='Network gateway.')
@ -372,7 +381,7 @@ Column('ROOT-USED',
doc='Disk utilisation by root image as a percentage of available space.')
StatusColumn()
FlagsColumn()
class Table(object):
@ -421,11 +430,11 @@ class Table(object):
#: Available formats. Feel free to plug your own one.
formats = {
'simple': ('name', 'status', 'label', 'template', 'netvm'),
'network': ('name', 'status', 'netvm', 'ip', 'ipback', 'gateway'),
'full': ('name', 'status', 'label', 'qid', 'xid', 'uuid'),
# 'perf': ('name', 'status', 'cpu', 'memory'),
'disk': ('name', 'status', 'disk',
'simple': ('name', 'state', 'class', 'label', 'template', 'netvm'),
'network': ('name', 'state', 'netvm', 'ip', 'ipback', 'gateway'),
'full': ('name', 'state', 'class', 'label', 'qid', 'xid', 'uuid'),
# 'perf': ('name', 'state', 'cpu', 'memory'),
'disk': ('name', 'state', 'disk',
'priv-curr', 'priv-max', 'priv-used',
'root-curr', 'root-max', 'root-used'),
}