diff --git a/doc/manpages/qvm-create.rst b/doc/manpages/qvm-create.rst index f17607b..44c8f8b 100644 --- a/doc/manpages/qvm-create.rst +++ b/doc/manpages/qvm-create.rst @@ -24,6 +24,14 @@ Options Decrease verbosity. +.. option:: --standalone + + shortcut for --class StandaloneVM, see below + +.. option:: --disp + + shortcut for --class DispVM --label red, see below + .. option:: --help-classes List available qube classes and exit. See below for short description. diff --git a/qubesadmin/tests/tools/qvm_create.py b/qubesadmin/tests/tools/qvm_create.py index 70ff4ad..e758fa6 100644 --- a/qubesadmin/tests/tools/qvm_create.py +++ b/qubesadmin/tests/tools/qvm_create.py @@ -328,3 +328,25 @@ class TC_00_qvm_create(qubesadmin.tests.QubesTestCase): app=self.app) self.assertIn('red, blue', stderr.getvalue()) self.assertAllCalled() + + def test_014_standalone_shortcut(self): + self.app.expected_calls[('dom0', 'admin.vm.Create.StandaloneVM', + None, b'name=new-vm label=red')] = b'0\x00' + self.app.expected_calls[('dom0', 'admin.label.List', None, None)] = \ + b'0\x00red\nblue\n' + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ + b'0\x00new-vm class=StandaloneVM state=Halted\n' + qubesadmin.tools.qvm_create.main(['-l', 'red', '--standalone', 'new-vm'], + app=self.app) + self.assertAllCalled() + + def test_015_disp_shortcut(self): + self.app.expected_calls[('dom0', 'admin.vm.Create.DispVM', + None, b'name=new-vm label=red')] = b'0\x00' + self.app.expected_calls[('dom0', 'admin.label.List', None, None)] = \ + b'0\x00red\nblue\n' + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ + b'0\x00new-vm class=DispVM state=Halted\n' + qubesadmin.tools.qvm_create.main(['--disp', 'new-vm'], + app=self.app) + self.assertAllCalled() diff --git a/qubesadmin/tools/qvm_create.py b/qubesadmin/tools/qvm_create.py index 5bd47df..fa0b4d1 100644 --- a/qubesadmin/tools/qvm_create.py +++ b/qubesadmin/tools/qvm_create.py @@ -43,6 +43,14 @@ parser.add_argument('--class', '-C', dest='cls', default='AppVM', help='specify the class of the new domain (default: %(default)s)') +parser.add_argument('--standalone', + action="store_true", + help=' shortcut for --class StandaloneVM') + +parser.add_argument('--disp', + action="store_true", + help='alias for --class DispVM --label red') + parser.add_argument('--property', '--prop', action=qubesadmin.tools.PropertyAction, help='set domain\'s property, like "internal", "memory" or "vcpus"') @@ -113,6 +121,13 @@ def main(args=None, app=None): if args.one_pool: pool = args.one_pool + if args.disp: + args.properties.setdefault('label', 'red') + args.cls = 'DispVM' + + if args.standalone: + args.cls = 'StandaloneVM' + if 'label' not in args.properties: parser.error('--label option is mandatory')