From 917df5a8c55562956297bb80c8c4d94881e31044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 29 Dec 2017 00:56:16 +0100 Subject: [PATCH] tools/qvm-ls: fix handling columns with underscore Mangling column type was inconsistent, resulting in KeyError('VIRT_MODE'). --- qubesadmin/tests/tools/qvm_ls.py | 11 +++++++++++ qubesadmin/tools/qvm_ls.py | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/qubesadmin/tests/tools/qvm_ls.py b/qubesadmin/tests/tools/qvm_ls.py index 437710a..17f3581 100644 --- a/qubesadmin/tests/tools/qvm_ls.py +++ b/qubesadmin/tests/tools/qvm_ls.py @@ -86,6 +86,17 @@ class TC_50_List(qubesadmin.tests.QubesTestCase): 'dom0 Running TestVM black - -\n' 'test-vm Running TestVM green template sys-net\n') + def test_101_list_with_underscore(self): + app = TestApp() + app.domains['test-vm'].virt_mode = 'pv' + app.domains['test-vm'].label = 'green' + app.domains['dom0'].label = 'black' + with qubesadmin.tests.tools.StdoutBuffer() as stdout: + qubesadmin.tools.qvm_ls.main(['-O', 'name,virt_mode,class'], app=app) + self.assertEqual(stdout.getvalue(), + 'NAME VIRT-MODE CLASS\n' + 'dom0 - TestVM\n' + 'test-vm pv TestVM\n') class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase): def test_100_list_with_status(self): diff --git a/qubesadmin/tools/qvm_ls.py b/qubesadmin/tools/qvm_ls.py index 3d9cde4..81510e7 100644 --- a/qubesadmin/tools/qvm_ls.py +++ b/qubesadmin/tools/qvm_ls.py @@ -389,7 +389,8 @@ class Table(object): ''' def __init__(self, app, colnames, spinner, raw_data=False): self.app = app - self.columns = tuple(Column.columns[col.upper()] for col in colnames) + self.columns = tuple(Column.columns[col.upper().replace('_', '-')] + for col in colnames) self.spinner = spinner self.raw_data = raw_data