qvm-ls: fix listing domains and labels

This commit is contained in:
Wojtek Porczyk 2015-09-26 00:13:30 +02:00
parent b0be1ad584
commit ce60915fb0
2 changed files with 4 additions and 19 deletions

View File

@ -185,23 +185,11 @@ class PropertyColumn(Column):
super(PropertyColumn, self).__init__(
head=holder.ls_head,
width=holder.ls_width,
attr=holder.__name__,
fmt=getattr(holder, 'ls_fmt', None),
doc=holder.__doc__)
self.holder = holder
def format(self, vm):
try:
value = getattr(vm, self.holder.__name__)
except AttributeError:
return None
if not hasattr(self.holder, 'ls_fmt') or self.holder.ls_fmt is None:
return value
return self.holder.ls_fmt.format(
getattr(vm, self.holder.__name__)).ljust(
self.ls_width)
def __repr__(self):
return '{}(head={!r}, width={!r} holder={!r})'.format(
self.__class__.__name__,
@ -409,10 +397,6 @@ class StatusColumn(Column):
# todo maxmem
Column('LABEL', width=14,
attr='label.name',
doc='Colour of the label.')
Column('GATEWAY', width=15,
attr='netvm.gateway',
doc='Network gateway.')

View File

@ -138,6 +138,7 @@ class QubesVM(qubes.vm.BaseVM):
label = qubes.property('label',
setter=_setter_label,
saver=(lambda self, prop, value: 'label-{}'.format(value.index)),
ls_width=14,
doc='''Colourful label assigned to VM. This is where the colour of the
padlock is set.''')