Merge remote-tracking branch 'origin/pr/168'
* origin/pr/168: qvm-ls & qvm-device: Handle removal of VM during on_shutdown.
This commit is contained in:
commit
c5da14e42b
@ -91,8 +91,11 @@ def list_devices(args):
|
||||
|
||||
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 "
|
||||
@ -105,6 +108,7 @@ def list_devices(args):
|
||||
if domain == dev.backend_domain:
|
||||
continue
|
||||
|
||||
try:
|
||||
for assignment in domain.devices[args.devclass].assignments():
|
||||
if dev != assignment:
|
||||
continue
|
||||
@ -115,6 +119,8 @@ def list_devices(args):
|
||||
assignment.options.items())))
|
||||
else:
|
||||
result[dev].frontends.append(str(domain))
|
||||
except qubesadmin.exc.QubesVMNotFoundError:
|
||||
continue
|
||||
|
||||
qubesadmin.tools.print_table(prepare_table(result.values()))
|
||||
|
||||
@ -281,7 +287,8 @@ def main(args=None, app=None):
|
||||
if basename.startswith('qvm-') and basename != 'qvm-device':
|
||||
devclass = basename[4:]
|
||||
|
||||
args = get_parser(devclass).parse_args(args, app=app)
|
||||
parser = get_parser(devclass)
|
||||
args = parser.parse_args(args, app=app)
|
||||
|
||||
if args.list_device_classes:
|
||||
print('\n'.join(qubesadmin.Qubes().list_deviceclass()))
|
||||
@ -290,7 +297,7 @@ def main(args=None, app=None):
|
||||
try:
|
||||
args.func(args)
|
||||
except qubesadmin.exc.QubesException as e:
|
||||
print(str(e), file=sys.stderr)
|
||||
parser.print_error(str(e))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
@ -467,17 +467,25 @@ class Table(object):
|
||||
table_data.append(self.get_head())
|
||||
self.spinner.update()
|
||||
if self.tree_sorted:
|
||||
#FIXME: handle qubesadmin.exc.QubesVMNotFoundError
|
||||
# (see QubesOS/qubes-issues#5105)
|
||||
insertion_vm_list = self.sort_to_tree(self.domains)
|
||||
for insertion, vm in insertion_vm_list:
|
||||
table_data.append(self.get_row(vm, insertion))
|
||||
else:
|
||||
for vm in sorted(self.domains):
|
||||
try:
|
||||
table_data.append(self.get_row(vm))
|
||||
except qubesadmin.exc.QubesVMNotFoundError:
|
||||
continue
|
||||
self.spinner.hide()
|
||||
qubesadmin.tools.print_table(table_data, stream=stream)
|
||||
else:
|
||||
for vm in sorted(self.domains):
|
||||
try:
|
||||
stream.write('|'.join(self.get_row(vm)) + '\n')
|
||||
except qubesadmin.exc.QubesVMNotFoundError:
|
||||
continue
|
||||
|
||||
|
||||
#: Available formats. Feel free to plug your own one.
|
||||
@ -576,7 +584,7 @@ def get_parser():
|
||||
parser = qubesadmin.tools.QubesArgumentParser(
|
||||
vmname_nargs=argparse.ZERO_OR_MORE,
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description='List Qubes domains and their parametres.',
|
||||
description='List Qubes domains and their parameters.',
|
||||
epilog='available formats (see --help-formats):\n{}\n\n'
|
||||
'available columns (see --help-columns):\n{}'.format(
|
||||
wrapper.fill(', '.join(sorted(formats.keys()))),
|
||||
|
Loading…
Reference in New Issue
Block a user