qvm-ls: hide flags (aka status), get more descriptive
Enterprise™ continues.
This commit is contained in:
parent
23fe5e431c
commit
59eda63923
@ -82,9 +82,9 @@ class TC_50_List(qubesadmin.tests.QubesTestCase):
|
|||||||
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
qubesadmin.tools.qvm_ls.main([], app=app)
|
qubesadmin.tools.qvm_ls.main([], app=app)
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'NAME STATUS LABEL TEMPLATE NETVM\n'
|
'NAME STATE CLASS LABEL TEMPLATE NETVM\n'
|
||||||
'dom0 -r------ black - -\n'
|
'dom0 Running TestVM black - -\n'
|
||||||
'test-vm -r------ green template sys-net\n')
|
'test-vm Running TestVM green template sys-net\n')
|
||||||
|
|
||||||
|
|
||||||
class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
|
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',
|
'label': b'type=label green',
|
||||||
'template': b'type=vm template1',
|
'template': b'type=vm template1',
|
||||||
'netvm': b'type=vm sys-net',
|
'netvm': b'type=vm sys-net',
|
||||||
'updateable': b'type=bool False',
|
# 'hvm': 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',
|
|
||||||
}
|
}
|
||||||
for key, value in props.items():
|
for key, value in props.items():
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
@ -125,7 +119,6 @@ class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
|
|||||||
|
|
||||||
# setup template1
|
# setup template1
|
||||||
props['label'] = b'type=label black'
|
props['label'] = b'type=label black'
|
||||||
props['updateable'] = b'type=bool True'
|
|
||||||
for key, value in props.items():
|
for key, value in props.items():
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('template1', 'admin.vm.property.Get', key, None)] = \
|
('template1', 'admin.vm.property.Get', key, None)] = \
|
||||||
@ -136,8 +129,6 @@ class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
|
|||||||
|
|
||||||
# setup sys-net
|
# setup sys-net
|
||||||
props['label'] = b'type=label red'
|
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():
|
for key, value in props.items():
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('sys-net', 'admin.vm.property.Get', key, None)] = \
|
('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:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
qubesadmin.tools.qvm_ls.main([], app=self.app)
|
qubesadmin.tools.qvm_ls.main([], app=self.app)
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'NAME STATUS LABEL TEMPLATE NETVM\n'
|
'NAME STATE CLASS LABEL TEMPLATE NETVM\n'
|
||||||
'sys-net ar-N---- red template1 sys-net\n'
|
'sys-net Running AppVM red template1 sys-net\n'
|
||||||
'template1 t-U----- black - sys-net\n'
|
'template1 Halted TemplateVM black - sys-net\n'
|
||||||
'vm1 ar------ green template1 sys-net\n')
|
'vm1 Running AppVM green template1 sys-net\n')
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
@ -191,13 +191,13 @@ def simple_flag(field, letter, attr, doc=None):
|
|||||||
return helper
|
return helper
|
||||||
|
|
||||||
|
|
||||||
class StatusColumn(Column):
|
class FlagsColumn(Column):
|
||||||
'''Some fancy flags that describe general status of the domain.'''
|
'''Some fancy flags that describe general status of the domain.'''
|
||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(StatusColumn, self).__init__(
|
super(FlagsColumn, self).__init__(
|
||||||
head='STATUS',
|
head='FLAGS',
|
||||||
doc=self.__class__.__doc__)
|
doc=self.__class__.__doc__)
|
||||||
|
|
||||||
|
|
||||||
@ -333,6 +333,15 @@ def calc_used(vm, volume_name):
|
|||||||
|
|
||||||
# todo maxmem
|
# 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',
|
Column('GATEWAY',
|
||||||
attr='netvm.gateway',
|
attr='netvm.gateway',
|
||||||
doc='Network gateway.')
|
doc='Network gateway.')
|
||||||
@ -372,7 +381,7 @@ Column('ROOT-USED',
|
|||||||
doc='Disk utilisation by root image as a percentage of available space.')
|
doc='Disk utilisation by root image as a percentage of available space.')
|
||||||
|
|
||||||
|
|
||||||
StatusColumn()
|
FlagsColumn()
|
||||||
|
|
||||||
|
|
||||||
class Table(object):
|
class Table(object):
|
||||||
@ -421,11 +430,11 @@ class Table(object):
|
|||||||
|
|
||||||
#: Available formats. Feel free to plug your own one.
|
#: Available formats. Feel free to plug your own one.
|
||||||
formats = {
|
formats = {
|
||||||
'simple': ('name', 'status', 'label', 'template', 'netvm'),
|
'simple': ('name', 'state', 'class', 'label', 'template', 'netvm'),
|
||||||
'network': ('name', 'status', 'netvm', 'ip', 'ipback', 'gateway'),
|
'network': ('name', 'state', 'netvm', 'ip', 'ipback', 'gateway'),
|
||||||
'full': ('name', 'status', 'label', 'qid', 'xid', 'uuid'),
|
'full': ('name', 'state', 'class', 'label', 'qid', 'xid', 'uuid'),
|
||||||
# 'perf': ('name', 'status', 'cpu', 'memory'),
|
# 'perf': ('name', 'state', 'cpu', 'memory'),
|
||||||
'disk': ('name', 'status', 'disk',
|
'disk': ('name', 'state', 'disk',
|
||||||
'priv-curr', 'priv-max', 'priv-used',
|
'priv-curr', 'priv-max', 'priv-used',
|
||||||
'root-curr', 'root-max', 'root-used'),
|
'root-curr', 'root-max', 'root-used'),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user