Merge remote-tracking branch 'origin/pr/84'

* origin/pr/84:
  Fixed typo in documentation
  Documentation is important! Added shortcuts to manpages
  added tests for shortcuts
  diff doesn't set template
  added --standalone and --disp shortcuts
This commit is contained in:
Marek Marczykowski-Górecki 2018-12-08 15:10:42 +01:00
commit 558c5d4a7c
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 45 additions and 0 deletions

View File

@ -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.

View File

@ -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()

View File

@ -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')