tools: add qvm-create --help-classes
List available VM classes QubesOS/qubes-issues#3017
This commit is contained in:
parent
0464a3ebfc
commit
0fa374264f
@ -7,6 +7,7 @@ Synopsis
|
|||||||
--------
|
--------
|
||||||
|
|
||||||
:command:`qvm-create` [-h] [--verbose] [--quiet] [--force-root] [--class *CLS*] [--property *NAME*=*VALUE*] [--pool *POOL_NAME:VOLUME_NAME*] [--template *VALUE*] --label *VALUE* [--root-copy-from *FILENAME* | --root-move-from *FILENAME*] *VMNAME*
|
:command:`qvm-create` [-h] [--verbose] [--quiet] [--force-root] [--class *CLS*] [--property *NAME*=*VALUE*] [--pool *POOL_NAME:VOLUME_NAME*] [--template *VALUE*] --label *VALUE* [--root-copy-from *FILENAME* | --root-move-from *FILENAME*] *VMNAME*
|
||||||
|
:command:`qvm-create` --help-classes
|
||||||
|
|
||||||
Options
|
Options
|
||||||
-------
|
-------
|
||||||
@ -23,6 +24,10 @@ Options
|
|||||||
|
|
||||||
Decrease verbosity.
|
Decrease verbosity.
|
||||||
|
|
||||||
|
.. option:: --help-classes
|
||||||
|
|
||||||
|
List available qube classes and exit. See below for short description.
|
||||||
|
|
||||||
.. option:: --class, -C
|
.. option:: --class, -C
|
||||||
|
|
||||||
The new domain class name (default: **AppVM** for
|
The new domain class name (default: **AppVM** for
|
||||||
|
@ -156,3 +156,13 @@ class TC_00_qvm_create(qubesadmin.tests.QubesTestCase):
|
|||||||
'--root-copy-from=/invalid', 'new-vm'],
|
'--root-copy-from=/invalid', 'new-vm'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
|
def test_009_help_classes(self):
|
||||||
|
self.app.expected_calls[('dom0', 'admin.vmclass.List',
|
||||||
|
None, None)] = b'0\x00StandaloneVM\nAppVM\nTemplateVM\nDispVM\n'
|
||||||
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
|
qubesadmin.tools.qvm_create.main(['--help-classes'],
|
||||||
|
app=self.app)
|
||||||
|
self.assertEqual(stdout.getvalue(),
|
||||||
|
'AppVM\nDispVM\nStandaloneVM\nTemplateVM\n')
|
||||||
|
self.assertAllCalled()
|
||||||
|
@ -67,6 +67,10 @@ parser.add_argument('--label', '-l',
|
|||||||
help='specify the label to use for the new domain'
|
help='specify the label to use for the new domain'
|
||||||
' (e.g. red, yellow, green, ...)')
|
' (e.g. red, yellow, green, ...)')
|
||||||
|
|
||||||
|
parser.add_argument('--help-classes',
|
||||||
|
action='store_true',
|
||||||
|
help='List available classes and exit')
|
||||||
|
|
||||||
parser_root = parser.add_mutually_exclusive_group()
|
parser_root = parser.add_mutually_exclusive_group()
|
||||||
parser_root.add_argument('--root-copy-from', '-r', metavar='FILENAME',
|
parser_root.add_argument('--root-copy-from', '-r', metavar='FILENAME',
|
||||||
help='use provided root.img instead of default/empty one'
|
help='use provided root.img instead of default/empty one'
|
||||||
@ -90,6 +94,12 @@ def main(args=None, app=None):
|
|||||||
'''Main function of qvm-create tool'''
|
'''Main function of qvm-create tool'''
|
||||||
args = parser.parse_args(args, app=app)
|
args = parser.parse_args(args, app=app)
|
||||||
|
|
||||||
|
if args.help_classes:
|
||||||
|
vm_classes = args.app.qubesd_call('dom0', 'admin.vmclass.List').decode()
|
||||||
|
vm_classes = vm_classes.splitlines()
|
||||||
|
print('\n'.join(sorted(vm_classes)))
|
||||||
|
return 0
|
||||||
|
|
||||||
pools = {}
|
pools = {}
|
||||||
pool = None
|
pool = None
|
||||||
if hasattr(args, 'pool') and args.pool:
|
if hasattr(args, 'pool') and args.pool:
|
||||||
|
Loading…
Reference in New Issue
Block a user