def list_devices(args): ''' Called by the parser to execute the qubes-devices list subcommand. ''' app = args.app devices = set() if hasattr(args, 'domains') and args.domains: for domain in args.domains: for dev in domain.devices[args.devclass].attached(): devices.add(dev) for dev in domain.devices[args.devclass].available(): devices.add(dev) else: for domain in app.domains: for dev in domain.devices[args.devclass].available(): devices.add(dev) result = {dev: Line(dev) for dev in devices} for dev in result: for domain in app.domains: if domain == dev.backend_domain: continue if dev in domain.devices[args.devclass].assignments(): result[dev].frontends.append(str(domain)) qubesadmin.tools.print_table(prepare_table(result.values()))
def list_devices(args): """ Called by the parser to execute the qubes-devices list subcommand. """ app = args.app devices = set() try: if hasattr(args, 'domains') and args.domains: for domain in args.domains: for dev in domain.devices[args.devclass].attached(): devices.add(dev) for dev in domain.devices[args.devclass].available(): devices.add(dev) else: for domain in app.domains: try: for dev in domain.devices[args.devclass].available(): devices.add(dev) except qubesadmin.exc.QubesVMNotFoundError: continue except qubesadmin.exc.QubesDaemonAccessError: raise qubesadmin.exc.QubesException( "Failed to list '%s' devices, this device type either " "does not exist or you do not have access to it.", args.devclass) result = {dev: Line(dev) for dev in devices} for dev in result: for domain in app.domains: if domain == dev.backend_domain: continue try: for assignment in domain.devices[args.devclass].assignments(): if dev != assignment: continue if assignment.options: result[dev].frontends.append('{!s} ({})'.format( domain, ', '.join( '{}={}'.format(key, value) for key, value in assignment.options.items()))) else: result[dev].frontends.append(str(domain)) except qubesadmin.exc.QubesVMNotFoundError: continue qubesadmin.tools.print_table(prepare_table(result.values()))
def list_devices(args): """ Called by the parser to execute the qubes-devices list subcommand. """ app = args.app devices = set() if hasattr(args, 'domains') and args.domains: for domain in args.domains: for dev in domain.devices[args.devclass].attached(): devices.add(dev) for dev in domain.devices[args.devclass].available(): devices.add(dev) else: for domain in app.domains: for dev in domain.devices[args.devclass].available(): devices.add(dev) result = {dev: Line(dev) for dev in devices} for dev in result: for domain in app.domains: if domain == dev.backend_domain: continue for assignment in domain.devices[args.devclass].assignments(): if dev != assignment: continue if assignment.options: result[dev].frontends.append('{!s} ({})'.format( domain, ', '.join('{}={}'.format(key, value) for key, value in assignment.options.items()))) else: result[dev].frontends.append(str(domain)) qubesadmin.tools.print_table(prepare_table(result.values()))