Ver código fonte

qvm-ls: fix listing domains and labels

Wojtek Porczyk 8 anos atrás
pai
commit
ce60915fb0
2 arquivos alterados com 4 adições e 19 exclusões
  1. 3 19
      qubes/tools/qvm_ls.py
  2. 1 0
      qubes/vm/qubesvm.py

+ 3 - 19
qubes/tools/qvm_ls.py

@@ -99,7 +99,7 @@ class Column(object):
         Return value to put in a table cell.
 
         :param qubes.vm.qubesvm.QubesVM: Domain to get a value from.
-        :returns: Value to put, or :py:obj:`None` if no value .
+        :returns: Value to put, or :py:obj:`None` if no value.
         :rtype: str or None
         '''
 
@@ -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.')

+ 1 - 0
qubes/vm/qubesvm.py

@@ -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.''')