Skip to content

Commit

Permalink
q-dev: more elaborated assignment listing
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Aug 26, 2024
1 parent d799cfc commit 9a7ff4b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions qubesadmin/tools/qvm_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ def prepare_table(dev_list):
return header + sorted(output)


class Line(object):
class Line:
"""Helper class to hold single device info for listing"""

# pylint: disable=too-few-public-methods
def __init__(self, device: DeviceInfo, attached_to=None):
self.ident = "{!s}:{!s}".format(device.backend_domain, device.port_id) # TODO!
self.ident = "{!s}:{!s}".format(
device.backend_domain, device.port_id)
self.description = device.description
self.attached_to = attached_to if attached_to else ""
self.frontends = []
Expand Down Expand Up @@ -151,11 +152,14 @@ def _frontend_desc(vm, assignment):
"""
Generate description of frontend vm with optional device connection options.
"""
mode = assignment.mode.value
if mode == 'manual':
mode = 'attached'
if assignment.options:
return '{!s} ({})'.format(
vm, ', '.join('{}={}'.format(key, value)
return '{!s} ({}: {})'.format(
vm, mode, ', '.join('{}={}'.format(key, value)
for key, value in assignment.options.items()))
return str(vm)
return f'{vm} ({mode})'


def attach_device(args):
Expand Down

0 comments on commit 9a7ff4b

Please sign in to comment.