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:
|
else:
|
||||||
for domain in app.domains:
|
for domain in app.domains:
|
||||||
|
try:
|
||||||
for dev in domain.devices[args.devclass].available():
|
for dev in domain.devices[args.devclass].available():
|
||||||
devices.add(dev)
|
devices.add(dev)
|
||||||
|
except qubesadmin.exc.QubesVMNotFoundError:
|
||||||
|
continue
|
||||||
except qubesadmin.exc.QubesDaemonAccessError:
|
except qubesadmin.exc.QubesDaemonAccessError:
|
||||||
raise qubesadmin.exc.QubesException(
|
raise qubesadmin.exc.QubesException(
|
||||||
"Failed to list '%s' devices, this device type either "
|
"Failed to list '%s' devices, this device type either "
|
||||||
@ -105,6 +108,7 @@ def list_devices(args):
|
|||||||
if domain == dev.backend_domain:
|
if domain == dev.backend_domain:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
for assignment in domain.devices[args.devclass].assignments():
|
for assignment in domain.devices[args.devclass].assignments():
|
||||||
if dev != assignment:
|
if dev != assignment:
|
||||||
continue
|
continue
|
||||||
@ -115,6 +119,8 @@ def list_devices(args):
|
|||||||
assignment.options.items())))
|
assignment.options.items())))
|
||||||
else:
|
else:
|
||||||
result[dev].frontends.append(str(domain))
|
result[dev].frontends.append(str(domain))
|
||||||
|
except qubesadmin.exc.QubesVMNotFoundError:
|
||||||
|
continue
|
||||||
|
|
||||||
qubesadmin.tools.print_table(prepare_table(result.values()))
|
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':
|
if basename.startswith('qvm-') and basename != 'qvm-device':
|
||||||
devclass = basename[4:]
|
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:
|
if args.list_device_classes:
|
||||||
print('\n'.join(qubesadmin.Qubes().list_deviceclass()))
|
print('\n'.join(qubesadmin.Qubes().list_deviceclass()))
|
||||||
@ -290,7 +297,7 @@ def main(args=None, app=None):
|
|||||||
try:
|
try:
|
||||||
args.func(args)
|
args.func(args)
|
||||||
except qubesadmin.exc.QubesException as e:
|
except qubesadmin.exc.QubesException as e:
|
||||||
print(str(e), file=sys.stderr)
|
parser.print_error(str(e))
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -467,17 +467,25 @@ class Table(object):
|
|||||||
table_data.append(self.get_head())
|
table_data.append(self.get_head())
|
||||||
self.spinner.update()
|
self.spinner.update()
|
||||||
if self.tree_sorted:
|
if self.tree_sorted:
|
||||||
|
#FIXME: handle qubesadmin.exc.QubesVMNotFoundError
|
||||||
|
# (see QubesOS/qubes-issues#5105)
|
||||||
insertion_vm_list = self.sort_to_tree(self.domains)
|
insertion_vm_list = self.sort_to_tree(self.domains)
|
||||||
for insertion, vm in insertion_vm_list:
|
for insertion, vm in insertion_vm_list:
|
||||||
table_data.append(self.get_row(vm, insertion))
|
table_data.append(self.get_row(vm, insertion))
|
||||||
else:
|
else:
|
||||||
for vm in sorted(self.domains):
|
for vm in sorted(self.domains):
|
||||||
|
try:
|
||||||
table_data.append(self.get_row(vm))
|
table_data.append(self.get_row(vm))
|
||||||
|
except qubesadmin.exc.QubesVMNotFoundError:
|
||||||
|
continue
|
||||||
self.spinner.hide()
|
self.spinner.hide()
|
||||||
qubesadmin.tools.print_table(table_data, stream=stream)
|
qubesadmin.tools.print_table(table_data, stream=stream)
|
||||||
else:
|
else:
|
||||||
for vm in sorted(self.domains):
|
for vm in sorted(self.domains):
|
||||||
|
try:
|
||||||
stream.write('|'.join(self.get_row(vm)) + '\n')
|
stream.write('|'.join(self.get_row(vm)) + '\n')
|
||||||
|
except qubesadmin.exc.QubesVMNotFoundError:
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
#: Available formats. Feel free to plug your own one.
|
#: Available formats. Feel free to plug your own one.
|
||||||
@ -576,7 +584,7 @@ def get_parser():
|
|||||||
parser = qubesadmin.tools.QubesArgumentParser(
|
parser = qubesadmin.tools.QubesArgumentParser(
|
||||||
vmname_nargs=argparse.ZERO_OR_MORE,
|
vmname_nargs=argparse.ZERO_OR_MORE,
|
||||||
formatter_class=argparse.RawTextHelpFormatter,
|
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'
|
epilog='available formats (see --help-formats):\n{}\n\n'
|
||||||
'available columns (see --help-columns):\n{}'.format(
|
'available columns (see --help-columns):\n{}'.format(
|
||||||
wrapper.fill(', '.join(sorted(formats.keys()))),
|
wrapper.fill(', '.join(sorted(formats.keys()))),
|
||||||
|
Loading…
Reference in New Issue
Block a user