qvm-device: handle 'list-device-classes' and 'list-classes'
QubesOS/qubes-issues#5213
This commit is contained in:
parent
3dce4e9742
commit
41c6fbed72
1
qubesadmin/qubesadmin
Symbolic link
1
qubesadmin/qubesadmin
Symbolic link
@ -0,0 +1 @@
|
||||
/home/user/qubes-builder/qubes-src/core-admin-client/qubesadmin
|
@ -263,6 +263,9 @@ def get_parser(device_class=None):
|
||||
attach_parser.set_defaults(func=attach_device)
|
||||
detach_parser.set_defaults(func=detach_device)
|
||||
|
||||
parser.add_argument('--list-device-classes', action='store_true',
|
||||
default=False)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
@ -272,7 +275,13 @@ def main(args=None, app=None):
|
||||
devclass = None
|
||||
if basename.startswith('qvm-') and basename != 'qvm-device':
|
||||
devclass = basename[4:]
|
||||
|
||||
args = get_parser(devclass).parse_args(args, app=app)
|
||||
|
||||
if args.list_device_classes:
|
||||
print('\n'.join(qubesadmin.Qubes().list_deviceclass()))
|
||||
return 0
|
||||
|
||||
try:
|
||||
args.func(args)
|
||||
except qubesadmin.exc.QubesException as e:
|
||||
@ -282,4 +291,10 @@ def main(args=None, app=None):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Special treatment for '--list-device-classes' (alias --list-classes)
|
||||
curr_action = sys.argv[1:]
|
||||
if set(curr_action).intersection(
|
||||
{'--list-device-classes', '--list-classes'}):
|
||||
sys.exit(main(args=['', '--list-device-classes']))
|
||||
|
||||
sys.exit(main())
|
||||
|
Loading…
Reference in New Issue
Block a user