Rename want_vm_* in vmname_nargs
This commit is contained in:
parent
d4c74d210f
commit
910276e898
@ -35,9 +35,7 @@ import qubes.tools
|
|||||||
|
|
||||||
parser = qubes.tools.QubesArgumentParser(
|
parser = qubes.tools.QubesArgumentParser(
|
||||||
description='Send monitor layout to one qube or to all of them',
|
description='Send monitor layout to one qube or to all of them',
|
||||||
want_app=True,
|
want_app=True, vmname_nargs='?')
|
||||||
want_vm=True,
|
|
||||||
want_vm_optional=True)
|
|
||||||
|
|
||||||
|
|
||||||
def main(args=None):
|
def main(args=None):
|
||||||
|
@ -30,8 +30,7 @@ import qubes.exc
|
|||||||
import qubes.tools
|
import qubes.tools
|
||||||
|
|
||||||
parser = qubes.tools.QubesArgumentParser(
|
parser = qubes.tools.QubesArgumentParser(
|
||||||
description='forceful shutdown of a domain',
|
description='forceful shutdown of a domain', vmname_nargs='+')
|
||||||
want_vm=True)
|
|
||||||
|
|
||||||
|
|
||||||
def main(args=None):
|
def main(args=None):
|
||||||
@ -43,12 +42,15 @@ def main(args=None):
|
|||||||
|
|
||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
|
|
||||||
try:
|
exit_code = 0
|
||||||
args.vm.force_shutdown()
|
for domain in args.domains:
|
||||||
except (IOError, OSError, qubes.exc.QubesException) as e:
|
try:
|
||||||
parser.error_runtime(str(e))
|
domain.force_shutdown()
|
||||||
|
except (IOError, OSError, qubes.exc.QubesException) as e:
|
||||||
|
exit_code = 1
|
||||||
|
parser.print_error(str(e))
|
||||||
|
|
||||||
return 0
|
return exit_code
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -28,9 +28,8 @@ import sys
|
|||||||
import qubes
|
import qubes
|
||||||
|
|
||||||
|
|
||||||
parser = qubes.tools.QubesArgumentParser(
|
parser = qubes.tools.QubesArgumentParser(vmname_nargs='+',
|
||||||
want_vm=True,
|
description='pause a domain')
|
||||||
description='pause a domain')
|
|
||||||
|
|
||||||
|
|
||||||
def main(args=None):
|
def main(args=None):
|
||||||
@ -41,7 +40,8 @@ def main(args=None):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
args.vm.pause()
|
for domain in args.domains:
|
||||||
|
domain.pause()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import qubes.vm
|
|||||||
|
|
||||||
parser = qubes.tools.QubesArgumentParser(
|
parser = qubes.tools.QubesArgumentParser(
|
||||||
want_force_root=True,
|
want_force_root=True,
|
||||||
want_vm=True)
|
vmname_nargs=1)
|
||||||
|
|
||||||
parser.add_argument('--help-properties',
|
parser.add_argument('--help-properties',
|
||||||
action=qubes.tools.HelpPropertiesAction,
|
action=qubes.tools.HelpPropertiesAction,
|
||||||
@ -63,18 +63,18 @@ def main(args=None):
|
|||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
|
|
||||||
if args.property is None:
|
if args.property is None:
|
||||||
properties = args.vm.property_list()
|
properties = args.domain.property_list()
|
||||||
width = max(len(prop.__name__) for prop in properties)
|
width = max(len(prop.__name__) for prop in properties)
|
||||||
|
|
||||||
for prop in sorted(properties):
|
for prop in sorted(properties):
|
||||||
try:
|
try:
|
||||||
value = getattr(args.vm, prop.__name__)
|
value = getattr(args.domain, prop.__name__)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print('{name:{width}s} U'.format(
|
print('{name:{width}s} U'.format(
|
||||||
name=prop.__name__, width=width))
|
name=prop.__name__, width=width))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if args.vm.property_is_default(prop):
|
if args.domain.property_is_default(prop):
|
||||||
print('{name:{width}s} D {value!s}'.format(
|
print('{name:{width}s} D {value!s}'.format(
|
||||||
name=prop.__name__, width=width, value=value))
|
name=prop.__name__, width=width, value=value))
|
||||||
else:
|
else:
|
||||||
@ -83,21 +83,22 @@ def main(args=None):
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if args.property not in [prop.__name__ for prop in args.vm.property_list()]:
|
if args.property not in [prop.__name__
|
||||||
|
for prop in args.domain.property_list()]:
|
||||||
parser.error('no such property: {!r}'.format(args.property))
|
parser.error('no such property: {!r}'.format(args.property))
|
||||||
|
|
||||||
if args.value is not None:
|
if args.value is not None:
|
||||||
setattr(args.vm, args.property, args.value)
|
setattr(args.domain, args.property, args.value)
|
||||||
args.app.save()
|
args.app.save()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if args.delete:
|
if args.delete:
|
||||||
delattr(args.vm, args.property)
|
delattr(args.domain, args.property)
|
||||||
args.app.save()
|
args.app.save()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
print(str(getattr(args.vm, args.property)))
|
print(str(getattr(args.domain, args.property)))
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -31,9 +31,7 @@ import qubes.exc
|
|||||||
import qubes.tools
|
import qubes.tools
|
||||||
|
|
||||||
|
|
||||||
parser = qubes.tools.QubesArgumentParser(
|
parser = qubes.tools.QubesArgumentParser(vmname_nargs='+')
|
||||||
want_vm=True,
|
|
||||||
want_vm_all=True)
|
|
||||||
|
|
||||||
parser.add_argument('--user', '-u', metavar='USER',
|
parser.add_argument('--user', '-u', metavar='USER',
|
||||||
help='run command in a qube as USER')
|
help='run command in a qube as USER')
|
||||||
@ -84,7 +82,7 @@ def main(args=None):
|
|||||||
if args.color_output is None and args.filter_esc:
|
if args.color_output is None and args.filter_esc:
|
||||||
args.color_output = '31'
|
args.color_output = '31'
|
||||||
|
|
||||||
if len(args.vm) > 1 and args.passio:
|
if len(args.domains) > 1 and args.passio:
|
||||||
parser.error('--passio cannot be used when more than 1 qube is chosen')
|
parser.error('--passio cannot be used when more than 1 qube is chosen')
|
||||||
if args.localcmd and not args.passio:
|
if args.localcmd and not args.passio:
|
||||||
parser.error('--localcmd have no effect without --pass-io')
|
parser.error('--localcmd have no effect without --pass-io')
|
||||||
@ -92,7 +90,7 @@ def main(args=None):
|
|||||||
parser.error('--color-output must be used with --filter-escape-chars')
|
parser.error('--color-output must be used with --filter-escape-chars')
|
||||||
|
|
||||||
retcode = 0
|
retcode = 0
|
||||||
for vm in args.vm:
|
for vm in args.domains:
|
||||||
if args.autostart and not vm.is_running():
|
if args.autostart and not vm.is_running():
|
||||||
vm.start()
|
vm.start()
|
||||||
|
|
||||||
|
@ -25,17 +25,14 @@
|
|||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import qubes.config
|
|
||||||
import qubes.tools
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import qubes.config
|
||||||
|
import qubes.tools
|
||||||
|
|
||||||
parser = qubes.tools.QubesArgumentParser(
|
parser = qubes.tools.QubesArgumentParser(
|
||||||
description='gracefully shut down a qube',
|
description='gracefully shut down a qube', vmname_nargs='+')
|
||||||
want_vm=True,
|
|
||||||
want_vm_all=True)
|
|
||||||
|
|
||||||
parser.add_argument('--force',
|
parser.add_argument('--force',
|
||||||
action='store_true', default=False,
|
action='store_true', default=False,
|
||||||
@ -56,14 +53,14 @@ parser.add_argument('--timeout',
|
|||||||
def main(args=None):
|
def main(args=None):
|
||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
|
|
||||||
for vm in args.vm:
|
for vm in args.domains:
|
||||||
vm.shutdown(force=args.force)
|
vm.shutdown(force=args.force)
|
||||||
|
|
||||||
if not args.wait:
|
if not args.wait:
|
||||||
return
|
return
|
||||||
|
|
||||||
timeout = args.timeout
|
timeout = args.timeout
|
||||||
current_vms = list(sorted(args.vm))
|
current_vms = list(sorted(args.domains))
|
||||||
while timeout >= 0:
|
while timeout >= 0:
|
||||||
current_vms = [vm for vm in current_vms
|
current_vms = [vm for vm in current_vms
|
||||||
if vm.get_power_state() != 'Halted']
|
if vm.get_power_state() != 'Halted']
|
||||||
|
@ -21,17 +21,19 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
'''qvm-start - Start a domain'''
|
'''qvm-start - Start a domain'''
|
||||||
|
|
||||||
# TODO notification in tray
|
# TODO notification in tray
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import qubes
|
import qubes
|
||||||
|
|
||||||
|
|
||||||
class DriveAction(argparse.Action):
|
class DriveAction(argparse.Action):
|
||||||
'''Action for argument parser that stores drive image path.'''
|
'''Action for argument parser that stores drive image path.'''
|
||||||
|
|
||||||
# pylint: disable=redefined-builtin,too-few-public-methods
|
# pylint: disable=redefined-builtin,too-few-public-methods
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
option_strings,
|
option_strings,
|
||||||
@ -49,10 +51,8 @@ class DriveAction(argparse.Action):
|
|||||||
setattr(namespace, self.dest, self.prefix + values)
|
setattr(namespace, self.dest, self.prefix + values)
|
||||||
|
|
||||||
|
|
||||||
parser = qubes.tools.QubesArgumentParser(
|
parser = qubes.tools.QubesArgumentParser(vmname_nargs=1,
|
||||||
want_vm=True,
|
description='start a domain')
|
||||||
description='start a domain')
|
|
||||||
|
|
||||||
|
|
||||||
parser_drive = parser.add_mutually_exclusive_group()
|
parser_drive = parser.add_mutually_exclusive_group()
|
||||||
|
|
||||||
@ -98,6 +98,7 @@ parser.add_argument('--skip-if-running',
|
|||||||
|
|
||||||
parser.set_defaults(drive=None)
|
parser.set_defaults(drive=None)
|
||||||
|
|
||||||
|
|
||||||
def main(args=None):
|
def main(args=None):
|
||||||
'''Main routine of :program:`qvm-start`.
|
'''Main routine of :program:`qvm-start`.
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ def main(args=None):
|
|||||||
# if options.tray:
|
# if options.tray:
|
||||||
# tray_notify_init()
|
# tray_notify_init()
|
||||||
|
|
||||||
vm = args.vm
|
vm = args.domains[0]
|
||||||
|
|
||||||
if args.skip_if_running and vm.is_running():
|
if args.skip_if_running and vm.is_running():
|
||||||
return
|
return
|
||||||
|
@ -29,9 +29,10 @@ import qubes
|
|||||||
|
|
||||||
|
|
||||||
parser = qubes.tools.QubesArgumentParser(
|
parser = qubes.tools.QubesArgumentParser(
|
||||||
want_vm=True,
|
vmname_nargs=1,
|
||||||
description='unpause a domain')
|
description='unpause a domain')
|
||||||
|
|
||||||
|
|
||||||
def main(args=None):
|
def main(args=None):
|
||||||
'''Main routine of :program:`qvm-unpause`.
|
'''Main routine of :program:`qvm-unpause`.
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ def main(args=None):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
args.vm.unpause()
|
args.domains[0].unpause()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user