Skip to content

Commit 082a47f

Browse files
committed
q-dev: more elaborated assignment listing
1 parent 5210963 commit 082a47f

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

qubesadmin/tests/tools/qvm_device.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ def test_001_list_assigned_required(self):
119119
self.assertEqual(
120120
buf.getvalue(),
121121
'test-vm1:dev1 any device '
122-
'test-vm2 (option=other option, extra_opt=yes), '
123-
'test-vm3 (option=test option)\n'
124-
'test-vm3:dev3 ?******: evil inc. test-device-3 test-vm2\n'
122+
'test-vm2 (required: option=other option, extra_opt=yes), '
123+
'test-vm3 (required: option=test option)\n'
124+
'test-vm3:dev3 ?******: evil inc. test-device-3 '
125+
'test-vm2 (required)\n'
125126
)
126127

127128
def test_002_list_attach(self):
@@ -149,7 +150,8 @@ def test_002_list_attach(self):
149150
['testclass', 'list', 'test-vm3'], app=self.app)
150151
self.assertEqual(
151152
buf.getvalue(),
152-
'test-vm1:dev1 ?******: itl test-device test-vm3\n'
153+
'test-vm1:dev1 ?******: itl test-device '
154+
'test-vm3 (required)\n'
153155
)
154156

155157
def test_003_list_device_classes(self):

qubesadmin/tools/qvm_device.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ def prepare_table(dev_list):
6363
return header + sorted(output)
6464

6565

66-
class Line(object):
66+
class Line:
6767
"""Helper class to hold single device info for listing"""
6868

6969
# pylint: disable=too-few-public-methods
7070
def __init__(self, device: DeviceInfo, attached_to=None):
71-
self.ident = "{!s}:{!s}".format(device.backend_domain, device.port_id) # TODO!
71+
self.ident = "{!s}:{!s}".format(
72+
device.backend_domain, device.port_id)
7273
self.description = device.description
7374
self.attached_to = attached_to if attached_to else ""
7475
self.frontends = []
@@ -151,11 +152,14 @@ def _frontend_desc(vm, assignment):
151152
"""
152153
Generate description of frontend vm with optional device connection options.
153154
"""
155+
mode = assignment.mode.value
156+
if mode == 'manual':
157+
mode = 'attached'
154158
if assignment.options:
155-
return '{!s} ({})'.format(
156-
vm, ', '.join('{}={}'.format(key, value)
159+
return '{!s} ({}: {})'.format(
160+
vm, mode, ', '.join('{}={}'.format(key, value)
157161
for key, value in assignment.options.items()))
158-
return str(vm)
162+
return f'{vm} ({mode})'
159163

160164

161165
def attach_device(args):

0 commit comments

Comments
 (0)