qubes.tools
– Command line utilities¶
Those are Python modules that house actual functionality of CLI tools – the
files installed in /usr/bin
only import these modules and run main()
function.
The modules should make available for import theirs command line parsers
(instances of argparse.ArgumentParser
) as either .parser
attribute or function get_parser()
, which returns parser. Manual page will
be automatically checked during generation if its “Options” section contains all
options from this parser (and only those).
Module contents¶
Qubes’ command line tools
-
class
qubes.tools.
AliasedSubParsersAction
(option_strings, prog, parser_class, dest='==SUPPRESS==', required=False, help=None, metavar=None)[source]¶ Bases:
argparse._SubParsersAction
-
class
qubes.tools.
HelpPropertiesAction
(option_strings, klass=None, dest='==SUPPRESS==', default='==SUPPRESS==', help='list all available properties with short descriptions and exit')[source]¶ Bases:
argparse.Action
Action for argument parser that displays all properties and exits.
-
class
qubes.tools.
PoolsAction
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶ Bases:
qubes.tools.QubesAction
Action for argument parser to gather multiple pools
-
parse_qubes_app
(parser, namespace)[source]¶ This method is called by
qubes.tools.QubesArgumentParser
after the namespace.app is instantiated. Oerwrite this method when extendingqubes.tools.QubesAction
to initialized values based on the namespace.app
-
-
class
qubes.tools.
PropertyAction
(option_strings, dest, metavar='NAME=VALUE', required=False, help='set property to a value')[source]¶ Bases:
argparse.Action
Action for argument parser that stores a property.
-
class
qubes.tools.
QubesAction
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶ Bases:
argparse.Action
Interface providing a convinience method to be called, after namespace.app is instantiated.
-
parse_qubes_app
(parser, namespace)[source]¶ This method is called by
qubes.tools.QubesArgumentParser
after the namespace.app is instantiated. Oerwrite this method when extendingqubes.tools.QubesAction
to initialized values based on the namespace.app
-
-
class
qubes.tools.
QubesArgumentParser
(want_app=True, want_app_no_instance=False, want_force_root=False, vmname_nargs=None, **kwargs)[source]¶ Bases:
argparse.ArgumentParser
Parser preconfigured for use in most of the Qubes command-line tools.
Parameters: - want_app (bool) – instantiate
qubes.Qubes
object - want_app_no_instance (bool) – don’t actually instantiate
qubes.Qubes
object, just add argument for custom xml file - want_force_root (bool) – add
--force-root
option - vmname_nargs (mixed) –
The number of
VMNAME
arguments that should be consumed. Values include:- N (an integer) consumes N arguments (and produces a list)
- ’?’ consumes zero or one arguments
- ’*’ consumes zero or more arguments (and produces a list)
- ’+’ consumes one or more arguments (and produces a list)
kwargs are passed to
argparser.ArgumentParser
.- Currenty supported options:
--force-root
(optional)--qubesxml
location ofqubes.xml
(help is suppressed)--offline-mode
do not talk to hypervisor (help is suppressed)--verbose
and--quiet
-
dont_run_as_root
(namespace)[source]¶ Prevent running as root.
Parameters: args (argparse.Namespace) – if there is .force_root
attribute set to true, run anyway
- want_app (bool) – instantiate
-
class
qubes.tools.
RunningVmNameAction
(option_strings, nargs=1, dest='vmnames', help=None, **kwargs)[source]¶ Bases:
qubes.tools.VmNameAction
Action for argument parser that gets a running domain from VMNAME
-
parse_qubes_app
(parser, namespace)[source]¶ This method is called by
qubes.tools.QubesArgumentParser
after the namespace.app is instantiated. Oerwrite this method when extendingqubes.tools.QubesAction
to initialized values based on the namespace.app
-
-
class
qubes.tools.
SinglePropertyAction
(option_strings, dest, metavar='VALUE', const=None, nargs=None, required=False, help=None)[source]¶ Bases:
argparse.Action
Action for argument parser that stores a property.
-
class
qubes.tools.
VmNameAction
(option_strings, nargs=1, dest='vmnames', help=None, **kwargs)[source]¶ Bases:
qubes.tools.QubesAction
Action for parsing one ore multiple domains from provided VMNAMEs
-
parse_qubes_app
(parser, namespace)[source]¶ This method is called by
qubes.tools.QubesArgumentParser
after the namespace.app is instantiated. Oerwrite this method when extendingqubes.tools.QubesAction
to initialized values based on the namespace.app
-
-
class
qubes.tools.
VmNameGroup
(container, required, vm_action=<class 'qubes.tools.VmNameAction'>, help=None)[source]¶ Bases:
argparse._MutuallyExclusiveGroup
Adds an a VMNAME, –all & –exclude parameters to a :py:class:
argparse.ArgumentParser`
.
-
class
qubes.tools.
VolumeAction
(help='A pool & volume id combination', required=True, **kwargs)[source]¶ Bases:
qubes.tools.QubesAction
Action for argument parser that gets the :py:class:
qubes.storage.Volume
from a POOL_NAME:VOLUME_ID string.
-
qubes.tools.
get_parser_for_command
(command)[source]¶ Get parser for given qvm-tool.
Parameters: command (str) – command name
Return type: Raises: - ImportError – when command’s module is not found
- AttributeError – when parser was not found
-
qubes.tools.
print_table
(table)[source]¶ Uses the unix column command to print pretty table.
Parameters: text (str) – list of lists/sets
-
qubes.tools.
VM_ALL
= <object object>¶ constant returned when some action should be performed on all qubes