Metadata-Version: 2.5
Name: trytond_strings_xo_compute
Version: 8.0.0.9
Summary: Xen Orchestra Compute Inventory
Author: Clemens Hupka
Maintainer-email: Clemens Hupka <clemens.hupka@backend.at>
License-Expression: GPL-3.0-or-later
License-File: COPYRIGHT
License-File: LICENSE
Keywords: inventory,orchestra,tryton,virtualization,xcp-ng,xen
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Plugins
Classifier: Framework :: Tryton
Classifier: Topic :: Office/Business
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.10
Requires-Dist: trytond-company<8.1,>=8.0
Requires-Dist: trytond-strings-xo-infrastructure<8.1,>=8.0
Requires-Dist: trytond-strings-xo<8.1,>=8.0
Requires-Dist: trytond<8.1,>=8.0
Provides-Extra: test
Description-Content-Type: text/x-rst

Xen Orchestra Compute
=====================

The ``strings_xo_compute`` module mirrors the compute inventory of a
Xen Orchestra (XO) instance into Tryton: the virtual machines, the
templates and the disk and network attachments of the ``/vms``,
``/vm-templates``, ``/vbds`` and ``/vifs`` collections are kept in sync
as read-only records.

Features
--------

- **Virtual machines**: name, description, power state, pool, host,
  template, CPU number and topology, CPU weight and cap, memory size,
  usage and dynamic range, primary address and guest address list,
  operating system and its details, BIOS strings, other configuration,
  tags, notes, secure boot, auto power on, high availability policy,
  resource set, virtualization mode, start, install and start delay.
- **Templates**: name, description, pool, CPU topology, memory,
  operating system, template information (disks and install methods),
  default template flag, secure boot, virtualization mode, tags and
  notes.
- **Power and lifecycle actions**: a virtual machine is started, paused,
  suspended, shut down and rebooted through the power operations of Xen
  Orchestra, either gracefully or by destroying the guest.  An action is
  guarded by the power state of the machine, the destructive ones are
  confirmed by the user, and every action is tracked by an asynchronous
  task linked to the machine.
- **Disk attachments (VBD)**: virtual machine, disk, device, position,
  bootable, attached, read-only and CD drive flags.
- **Disk lifecycle**: an existing disk is attached to a machine, an
  empty disk is created on a storage repository and attached to it, a
  raw or VHD file is imported into a repository or over the content of
  an existing disk, an attachment of a running machine is hot-plugged
  and hot-unplugged, and a disk is grown, on line or while its machine
  is halted.
- **Movement and duplication**: a machine is migrated to another host of
  its pool, live while it runs and cold while it is halted, and moved to
  another pool with each of its disks placed on a repository of the
  destination; it is cloned on the repository of its own disks, sharing
  their blocks when the clone is fast, and copied onto another one,
  compressing the stream it is transferred in.  A movement validates its
  destination, the capacity of the hosts and the repositories and the
  networks of the machine before Xen Orchestra is asked to run it, and
  it is tracked by an asynchronous task linked to the movement.
- **Interfaces (VIF)**: virtual machine, network, device, MAC, MTU,
  address, attached flag, locking mode, rate limit, TX checksumming and
  the allowed IPv4 and IPv6 addresses.
- **Interface lifecycle**: a network is attached to a machine at a device
  position left free, with an address generated by Xen Orchestra or given
  explicitly, at a maximum transmission unit of its own and with a
  locking mode, a rate limit, the offloading of its checksumming and the
  addresses it is allowed to use; the interface of a running machine is
  hot-plugged and hot-unplugged, its traffic rules are changed by a
  wizard, and the operations destroying an interface and changing the
  traffic rules of a running guest are confirmed by the user.
- **PCI and USB passthrough**: the PCI devices of a host and the USB
  devices, the groups they belong to and the attachments binding a
  group to a machine, with the class, the name, the address, the host
  and the pool of a PCI device and the description, the vendor, the
  version, the speed, the host, the group and the passthrough flag of a
  USB device.  A device is assigned to a halted machine and taken back
  from it, the USB devices of a host are scanned, the passthrough of a
  device is switched and the attachments of a machine are unplugged and
  destroyed; every assignment accepted by Xen Orchestra is recorded in a
  history.
- **Read-only synchronisation**: an idempotent upsert keyed on the
  ``(server, uuid)`` pair, driven from the Xen Orchestra REST API v0
  through the ``strings_xo`` client and the generic synchronisation
  framework of the ``strings_xo`` base module.  Records that are no
  longer reported by Xen Orchestra are deactivated instead of being
  deleted.
- **Relationships**: a virtual machine belongs to a pool, runs on a
  host and may reference a template; it owns its disk attachments and
  its interfaces, and its disks are resolved through the attachments; a
  disk exposes the machines it is attached to and the machine using it;
  a host, a pool and a network expose the machines and the interfaces
  they carry.
- **XVA export and import**: an archive of a virtual machine is
  streamed from Xen Orchestra to a destination and back without ever
  being buffered in memory.  An interrupted export is resumable and its
  archive is checksummed; an import only destroys a machine that is
  explicitly selected.
- **Cloud-init customisation**: the host name set in the guest, the
  users created in it with their groups, their shell, their sudo rule,
  their authorised public keys and their hashed password, and a custom
  user-data or network configuration document.  The documents are
  generated from the configuration and applied on demand through the
  configuration drive of Xen Orchestra; the public keys and the hashed
  passwords are encrypted at rest and masked when read.
- **Security**: dedicated access rights reusing the ``strings_xo``
  groups, with read-only access for Xen Orchestra users and full access
  for the Xen Orchestra administration group.  The users of the
  self-service portal of ``strings_xo_web``, which reads the inventory
  with the access checks of the identity a request authenticated with,
  are granted read-only access on the virtual machines and on the
  templates by this module, the only module that may declare access on
  them (Heptapod issue #822).  The power operations are restricted to
  the administration groups: reading a machine never lets an operation
  through.

Integration
-----------

The module extends the models of ``strings_xo_infrastructure`` instead
of redefining them, as required by the VDI inventory of that module:

- ``xo.vdi`` gains the ``vbd_ids`` collection and the ``vm_ids`` and
  ``vm`` relations resolving the virtual machines using a disk, the
  ``in_use`` flag telling whether a running machine uses it, the
  ``transfer_ids`` collection of the imports replacing its content and
  the *Resize* button.
- ``xo.vm`` gains the ``boot_order`` summary of its disks, the
  ``cloudinit_ids`` collection of the cloud-init configurations applied
  to it, the ``movement_ids`` collection of its migrations and
  duplications, the ``attached_pcis`` list of the devices it reports as
  assigned to it, the ``pci_ids``, ``usb_ids`` and
  ``device_assignment_ids`` collections of the devices given to it and
  of the history of its assignments, and the *Attach Disk*, *Create
  Disk*, *Import Disk*, *Apply*, *Migrate*, *Clone / Copy*, *Attach
  Interface*, *Attach PCI Device* and *Attach USB Device* buttons.
- ``xo.vm.vbd`` gains the *Plug*, *Unplug* and *Detach* buttons.
- ``xo.vm.vif`` gains the *Plug*, *Unplug*, *Configure* and *Detach*
  buttons.
- ``xo.host`` gains its ``vm_ids``, ``pci_ids`` and ``usb_ids``
  collections and the *Scan USB* button.
- ``xo.pci``, ``xo.usb.group``, ``xo.usb`` and ``xo.vm.vusb`` mirror the
  PCI devices, the USB devices, the groups they belong to and the
  attachments binding a group to a machine; ``xo.pci`` and ``xo.vm.vusb``
  gain the *Detach* button, ``xo.usb`` the *Enable Passthrough* and
  *Disable Passthrough* buttons, and ``xo.vm.vusb`` also the *Unplug*
  button.
- ``xo.vm.device.assignment`` holds the history of the devices given to
  a machine and taken back from it.
- ``xo.network`` gains its ``vif_ids`` collection.
- ``xo.server`` gains the compute collections, the *Sync Compute*,
  *Process XVA*, *Process Disks* and *Process Movements* buttons, the
  *Disk Transfers* and *VM Movements* pages, the ``movement_ids``
  collection of the movements running against it and the resolution of
  the interface addresses.
- ``xo.task`` gains the virtual machine, the disk attachment, the
  movement and the interface as target models, so that the task started
  by an action is linked to the object it acts upon.  The passthrough
  operations are synchronous calls of the JSON-RPC API, so they start no
  task and add no target model.

Xen Orchestra reports templates as a distinct object type served by the
``/vm-templates`` collection instead of a flag on the virtual machines,
therefore the templates are mirrored by the dedicated ``xo.vm.template``
model rather than by an ``is_template`` flag on ``xo.vm``.

Xen Orchestra does not report the template of a virtual machine, the
address of an interface nor the host of a machine directly: the host is
resolved from the ``$container`` of the machine (the host it runs on, or
the pool of a machine that is not running) and the address of an
interface is resolved from the guest addresses reported on its machine.

XVA Export and Import
---------------------

A *destination* (``xo.xva.destination``) is a configured location the
archives are written to and read from.  A destination is a directory of
the server running Tryton today; the model is the extension point for
the other storage backends of the suite, which register their own type.
The directory must exist and be writable by the user running Tryton,
and the name of an archive is restricted to the last component of the
requested name, so that a crafted name can neither leave the
destination nor address a hidden file.

An export streams ``GET /rest/v0/vms/<uuid>.<format>`` into a partial
file of the destination, which is renamed once the archive is complete;
the checksum covers the whole archive.  Xen Orchestra does not announce
the size of the streamed archive, so the progress of an export is only
known once it completes.  An interrupted export resumes from the
partial file it left behind when Xen Orchestra honours the ranged
request, and starts over otherwise.

An import streams ``POST /rest/v0/pools/<pool>/vms`` from an archive of
the destination, optionally into a given storage repository.  An
existing machine is only destroyed when it is explicitly selected in
the transfer: the machine to replace is never inferred from the
archive.  The archive itself is only read, which makes a failed import
safe to retry.

A transfer is created in the ``queued`` state and processed by the
scheduled *Xen Orchestra: Process XVA Transfers* action; the *Run*
button and the *Process XVA* button of a server process the selected
transfers immediately.  A transfer is only cancellable while it has not
started: a transfer that is already running cannot be stopped, its
stream being driven by the process performing it.  The counters of a
transfer are written in the transaction of the caller, so a run
publishes its journal and its counters when it completes.

Disks
-----

A machine uses a disk through an attachment: a *virtual block device*
(``xo.vm.vbd``) binds a disk (``xo.vdi``) to a machine at a device
position, either as a bootable disk or as a data disk.  The module
drives the whole lifecycle of a disk:

- *Attach Disk* adds an existing disk to a machine, choosing the device
  position left free and the bootable flag;
- *Create Disk* creates an empty disk on a storage repository and
  attaches it to the machine, so that a disk never has to be created
  before being usable;
- *Import Disk* imports a raw or VHD file of a destination into a
  storage repository, or writes it over the content of an existing
  disk, and optionally attaches the result to the machine;
- *Plug* and *Unplug* hot-plug and hot-unplug an attachment of a
  running machine;
- *Detach* destroys the attachment, leaving the disk itself untouched;
- *Resize* grows a disk, either on line or while its machine is halted.

The attachment of a disk is guarded by the state of the machine it
belongs to.  A device position stays within the range the Xen API
accepts and is only used once; a disk belonging to another server, to
another pool, no longer reported by Xen Orchestra or already attached
to the machine is refused.  The boot disk of a running machine is
neither unplugged nor detached, and an attached disk is not detached
before it has been unplugged, so that a guest is never deprived of a
disk it is using without the user having been told.  The operations
destroying an attachment, replacing the content of a disk and growing a
disk in use are confirmed by the user through ``res.user.warning``, and
the confirmations are remembered per user and per operation.

A disk is only grown: the Xen API refuses to shrink one, and the free
space of the storage repository bounds the growth, so a disk never
overcommits its repository.  A disk in use is grown on line, which its
guest only sees once it has rescanned the device.

The import of a file is a long running operation, so it is driven by
``xo.disk.transfer`` exactly as an XVA transfer is: the file is
streamed to Xen Orchestra without ever being buffered in memory, the
counters of the transfer are stored while it runs, an error is recorded
on the record instead of being raised, and the queued transfers are
processed by the scheduled action of the module.  The file is read from
a destination of the ``xo.xva.destination`` model, which restricts a
name to the destination it belongs to, so that a crafted name addresses
neither a file outside of the destination nor a hidden file.  The
processing of the queued disk transfers reuses the ``xva_cron`` setting
of the XVA transfers: when it is disabled, the *Import Disk* wizard
processes the transfer it created immediately.

An operation performed here is only reflected on the records it created
or changed by the next synchronisation, so the wizards report the
identifiers they obtained and the disks and the attachments they
created are mirrored by the next *Sync*.

Power and Lifecycle Actions
---------------------------

The power operations of Xen Orchestra are exposed as buttons of a
virtual machine, grouped on its form and, for the most common ones, on
its list:

- ``start`` and ``start_on`` power a halted machine on, the latter on a
  host selected in the *Start on Host* wizard, which is the only
  operation taking a parameter;
- ``pause``, ``unpause``, ``suspend`` and ``resume`` change the state of
  a machine without ending its guest;
- ``shutdown``, ``clean_shutdown``, ``reboot`` and ``clean_reboot`` stop
  or restart a running machine gracefully;
- ``hard_shutdown`` and ``hard_reboot`` destroy the guest.

An action is guarded by the power state the machine reports: its button
is hidden outside of the states the operation applies to, and the guard
is enforced again when the button is pressed, so that an inconsistent
state never reaches Xen Orchestra.  A machine reporting an unknown power
state is never guarded, the server remaining the authority; a selection
containing an impossible action is refused as a whole and no machine is
acted upon.

The operations destroying the guest are confirmed by the user before
the task is started.  The confirmation is remembered per user and per
action, so that acknowledging a hard shutdown never acknowledges a hard
reboot.

Every action starts a task of the Xen Orchestra instance, mirrored by
the ``xo.task`` model of the ``strings_xo`` base module and linked to
the machine it acts upon.  The tasks of a machine are listed in the
*Lifecycle* page of its form, where their state and their error are
read, and they are followed by the scheduled task polling of the base
module; the *Poll* and *Show Error* buttons of a task and the
*Poll Tasks* button of a server act on them as on any other task.

Movement and Duplication
------------------------

A machine is moved or duplicated through the two REST actions of the
REST API v0 that the module drives with a *movement*
(``xo.vm.movement``):

- ``migrate`` runs a machine on another host.  The operation is
  performed live while the machine runs, keeping its memory on the
  destination host, and cold while it is halted.  It is the destination
  host that decides whether the machine stays in its pool or changes
  pool: a machine changing pool has its disks moved to the storage
  repositories of the destination pool, which the ``srIdByVdiId``
  parameter of the action describes disk by disk, so that the disks of a
  machine are never assumed to share a repository.  The
  ``migrationNetworkId`` parameter names the network the migration
  traffic uses, the management network of the hosts being used when it
  is empty;
- ``clone`` duplicates a machine.  A clone stays on the repositories of
  its disks and is either *fast*, sharing the blocks of its source
  through the storage, or a full copy; a copy names the repository its
  disks are written to with ``srId`` and is therefore the only way to
  duplicate a machine across pools, optionally compressing the stream it
  is transferred in with ``compress``.

A machine is only cloned when the repository selected for it is the one
every one of its disks is stored on, and copied onto it otherwise: the
distinction is the one of the ``clone`` action, and it is made by the
wizard from the inventory, so that the user selects a repository and not
an operation.

The whole request is checked before anything is posted to Xen Orchestra,
so that a machine is never moved onto a host or a storage repository
that cannot hold it, and a movement fails as a whole instead of being
refused by Xen Orchestra halfway through:

- a machine no longer reported by Xen Orchestra, a destination host of
  another server, no longer reported or disabled, the host the machine
  already runs on, and a migration network of another server are
  refused;
- a duplication onto a repository of another server, no longer reported,
  in maintenance mode or on the repository of every one of the disks of
  the machine is refused, as is a duplication naming no repository or no
  name;
- a machine changing pool has each of its disks placed on a repository
  of the destination pool, and every network of its interfaces must have
  a counterpart on a host of that pool, resolved by bridge or, failing
  that, by name; a disk left on a repository of the pool the machine
  leaves is refused, so that a disk is never copied over the network
  without the user having placed it;
- the free space of every repository a disk is written to bounds the
  operation, a fast clone and a disk staying on its own repository
  consuming none; a repository whose capacity Xen Orchestra does not
  report is never refused;
- the memory a running machine uses must be free on the host it is
  migrated to, a halted machine consuming none.

A movement is created in the ``queued`` state, or in the ``draft`` state
when the destination repository of each of its disks has to be reviewed
first.  It holds one line (``xo.vm.movement.line``) per disk of the
machine, where the repository of the disk is selected and may be changed
while the movement has not started, and it follows the task it started
to a final state:

- a movement that succeeded ends there, and a duplication reports the
  identifier of the machine it created, from where the machine mirrored
  by the next synchronisation is resolved;
- a movement that failed records the error of its task; the error is
  surfaced on demand by the *Show Error* button, so that the recorded
  state is never rolled back;
- a movement that has not started yet is cancelled by the *Cancel*
  button; a running movement is left to Xen Orchestra, its task being
  the one that can be aborted;
- a failed or a cancelled movement is queued again by the *Retry*
  button.

The *Migrate* and *Clone / Copy* buttons of a machine, the buttons of a
movement and the *Process Movements* button of a server are restricted to
the administration groups exactly as the power operations are: reading a
machine never lets a movement through.  The dispatch of the queued
movements honours the ``xva_cron`` setting of the transfers, so that the
wizards only process the movement they created when the setting is
disabled.

Cloud Init
----------

Cloud-init customises the guest of a machine at its first boot: the
host name of the machine, the accounts created in the guest, their
groups, their login shells, their sudo rules and their authorised public
keys, the network configuration of the interfaces and any additional
user-data are described by a ``#cloud-config`` document and a network
configuration document, which Xen Orchestra turns into a configuration
drive attached to the machine.

A cloud-init *configuration* (``xo.vm.cloudinit``) is reusable: the host
name and the *users* (``xo.vm.cloudinit.user``) are edited once and the
documents are generated from them, deterministically, so that the same
configuration always produces the same documents.  The documents are
written by a minimal YAML serialiser instead of a dependency: the
scalars are quoted with the JSON syntax, which is a subset of YAML, so a
value carrying a colon, a quote or a non-ASCII character never breaks a
document.

A configuration may also carry a custom user-data, a custom network
configuration or both, which then take precedence over the generated
documents; the *Read Template* button reads the default configuration of
the template of a configuration back into its custom user-data, from
where it is adapted.

A network configuration is only generated when *Generate Network* is
checked: it matches the interfaces of the machine of the configuration by
their MAC address and asks for a DHCP lease, so that a guest is
reachable whatever the interface it presents itself on.  The
configuration drive is applied on demand:

- *Apply* opens the *Apply Cloud Init* wizard, where the machine to
  customise and the storage repository its configuration drive is
  created on are selected; the wizard defaults to the target of the last
  application of the configuration;
- applying a configuration to a running machine is confirmed by the user
  first, as its guest only reads the configuration drive at its next
  boot; the confirmation is remembered per user and per configuration;
- a configuration may only be applied to a machine and a storage
  repository of its own server, reported by Xen Orchestra, so that a
  customised guest is never built from another instance.

The public keys and the hashed passwords of the users are secrets: they
are encrypted at rest with the same Fernet key as the credentials of the
``strings_xo`` base module, they are masked in read results and they are
never logged.  The generated documents embed those secrets, so they are
masked in read results as well, exactly like the fields they are built
from; the documents are materialised by Xen Orchestra when the
configuration is applied.

The cloud-init operations are absent from the REST API v0 of Xen
Orchestra and are only exposed through its historical JSON-RPC API, so
the module calls them through ``XOClient.rpc``.

A machine created by another part of the suite announces its
customisation through ``get_creation_data()``, the parameters the
``vm.create`` operation of Xen Orchestra expects; the creation itself is
not driven by this module.

PCI and USB Passthrough
-----------------------

A physical device of a host is given to a guest by *assigning* it to a
virtual machine: the hypervisor stops using the device itself and the
guest drives it directly.  Xen Orchestra supports two kinds of device,
which the module drives:

- the *PCI devices* (``xo.pci``) of the ``/pcis`` collection of the REST
  API v0.  A device is assigned by writing its address in the additional
  configuration of the machine, which the hypervisor reads when the
  machine is started, and it is that address Xen Orchestra reports the
  assignment under.  The machine of a device is resolved from the
  ``attachedPcis`` of the machines of the server, so the machine of a
  device no longer reported by any machine is cleared by the next
  synchronisation;
- the *USB devices* (``xo.usb``).  A device belongs to a *USB group*
  (``xo.usb.group``), which is what is bound to a machine by a *virtual
  USB device* (``xo.vm.vusb``): a group carries at most one attachment
  and a machine carries at most six of them.  The machine a group is
  bound to is not reported on the group nor on its devices but on the
  attachment, so the ``assigned`` flag of a device is resolved once the
  groups, the devices and the attachments have been synchronised.

The two inventories are not reachable the same way.  The PCI devices are
part of the REST API v0, so they are mirrored by the generic
synchronisation framework exactly as the machines and their interfaces
are, and they are fetched with the compute inventory.  The USB devices,
groups and attachments are absent from that API: they are only exposed
by the ``xo.getAllObjects`` method of the historical JSON-RPC API, which
the module calls through ``XOClient.rpc`` for each of the ``PUSB``,
``USB_group`` and ``VUSB`` types, upserting the objects it answers with
the same framework.  The passthrough of a USB device is discovered by
the hypervisor: a device plugged into a running host is only reported
once the host has been scanned, which the *Scan USB* button of a host
does.

An assignment is only made to a machine that is halted: the hypervisor
of a running guest is not reconfigured, and a device given to a machine
this way reaches it at its next start anyway.  The device must belong to
the same Xen Orchestra server as the machine, must still be reported and
must not be assigned to another machine, a device being the property of
one guest at a time.  A PCI device must be plugged on a host of the pool
of the machine, so that a machine is never given a device it cannot
reach; a USB device must have its passthrough *enabled*, which is what
tells the hypervisor to hand the device over instead of using it itself,
and its group must be free.  A machine whose pool or whose host Xen
Orchestra does not report is never refused, the server remaining the
authority.

The operations are the *Attach PCI Device* and *Attach USB Device*
wizards, opened from the buttons of a machine, the *Detach* button of a
PCI device or of a USB attachment, the *Unplug* button of an attachment,
the *Enable Passthrough* and *Disable Passthrough* buttons of a USB
device and the *Scan USB* button of a host.  They run the
``vm.attachPcis``, ``vm.detachPcis``, ``vusb.create``, ``vusb.unplug``,
``vusb.destroy``, ``pusb.set`` and ``pusb.scan`` methods of the
JSON-RPC API; the REST API v0 exposes no way of attaching or detaching a
device.  Every button checks the guards of its whole selection before
acting on any record, so that a selection containing an impossible
operation is refused as a whole and nothing is acted upon.

Every operation accepted by Xen Orchestra is recorded in
``xo.vm.device.assignment``: the date, the user, the action, the kind of
device, the machine, the host and the values of the device snapshotted
when it was assigned, so that the history of the devices of a machine
stays readable for an audit even once they have been given back or are
no longer reported by Xen Orchestra.  The history is written once the
operation succeeded, so that it never holds an assignment the server
refused.

The two inventories and the history are mirrored read-only: an operation
performed here is only reflected on the records it created or changed by
the next synchronisation, so the wizards report the identifier they
obtained so that the operation can be followed until then.

Configuration
-------------

After installing the module, open *Xen Orchestra > Servers* and use the
*Sync Compute* button on a server to pull its compute inventory.  The
whole inventory is synchronised by the *Sync* button, the *Manual Sync*
wizard and the scheduled *Xen Orchestra: Synchronise* action.  The
synchronised compute inventory is available under *Xen Orchestra >
Compute*.  The cloud-init configurations are managed under *Xen
Orchestra > Compute > Cloud Init*.

The XVA and disk transfers are configured in the ``[strings_xo]``
section of ``trytond.conf``:

- ``xva_cron`` — whether the queued transfers are processed by the
  scheduled actions; defaults to enabled.  When it is disabled, the
  wizards process the transfers they create immediately.  The setting
  covers the disk transfers as well as the XVA transfers, an imported
  file being streamed exactly as an archive is, and the movements of the
  machines, a migration being as long running as a transfer is.
- ``xva_chunk_size`` — the size in bytes of the chunks an archive is
  streamed in; defaults to 1 MiB.
- ``xva_progress_interval`` — the number of bytes between two progress
  updates of a running transfer; defaults to 16 MiB.  The intermediate
  updates are disabled with ``0``.

Dependencies
------------

- Tryton modules: ``ir``, ``res``, ``company``, ``strings_xo``,
  ``strings_xo_infrastructure``.

Models
------

- ``xo.vm`` — ``XOVM``: a virtual machine.
- ``xo.vm.template`` — ``XOVMTemplate``: a virtual machine template.
- ``xo.vm.vbd`` — ``XOVMBD``: a disk attachment of a virtual machine.
- ``xo.vm.vif`` — ``XOVMIF``: an interface of a virtual machine.
- ``xo.vm.movement`` — ``XOVMMovement``: one migration or one
  duplication of a virtual machine, and the task performing it.
- ``xo.vm.movement.line`` — ``XOVMMovementLine``: the destination
  storage repository of one disk of a movement.
- ``xo.xva.destination`` — ``XOXVADestination``: a location the XVA
  archives are stored in.
- ``xo.xva.transfer`` — ``XOXVATransfer``: one export or one import of
  an archive.
- ``xo.disk.transfer`` — ``XODiskTransfer``: one import of a file into
  a disk.
- ``xo.vm.cloudinit`` — ``XOVMCloudInit``: the cloud-init customisation
  of the guest of a machine.
- ``xo.vm.cloudinit.user`` — ``XOVMCloudInitUser``: a user created in
  the guest by cloud-init.
- ``xo.pci`` — ``XOPci``: a PCI device of a host.
- ``xo.usb.group`` — ``XOUsbGroup``: the group of USB devices a machine
  is given a device of.
- ``xo.usb`` — ``XOUsb``: a USB device of a host.
- ``xo.vm.vusb`` — ``XOVMUsb``: an attachment binding a USB group to a
  virtual machine.
- ``xo.vm.device.assignment`` — ``XOVMDeviceAssignment``: one device
  given to a machine, or taken back from it.

Cron Jobs
---------

The module plugs into the generic *Xen Orchestra: Synchronise*
(``xo.server|sync_cron``) scheduled action of the ``strings_xo`` base
module, which synchronises the whole inventory of every active server.

The module also registers the *Xen Orchestra: Process XVA Transfers*
(``xo.xva.transfer|process_cron``) and *Xen Orchestra: Process Disk
Transfers* (``xo.disk.transfer|process_cron``) scheduled actions, which
process the queued XVA and disk transfers of every server.  An error on
a single transfer is recorded on the transfer and does not abort the
run.  Both actions are disabled by the ``xva_cron`` setting.

The *Xen Orchestra: Process VM Movements*
(``xo.vm.movement|process_cron``) scheduled action dispatches the queued
movements and follows the tasks of the running ones to their final
state.  An error on a single movement is recorded on the movement and
does not abort the run, and the action is disabled by the ``xva_cron``
setting as well.

Wizards
-------

The module plugs into the generic *Manual Sync* wizard of the
``strings_xo`` base module.  The *Sync Compute* button of a server
synchronises the compute collections only.

The module adds the *Export XVA* wizard, opened from the *Export XVA*
button of a virtual machine, and the *Import XVA* wizard.  Both create
their transfers in the ``queued`` state and process them immediately
when the ``xva_cron`` setting is disabled.

The module adds the disk wizards, opened from the buttons of a virtual
machine and of a disk:

- *Attach Disk* attaches an existing disk to the selected machine;
- *Create Disk* creates an empty disk on a storage repository and
  attaches it to the machine;
- *Import Disk* imports a file of a destination, either into a new disk
  or over the content of an existing one, and optionally attaches the
  result to the machine;
- *Resize* grows the selected disk, reporting the free space of its
  storage repository and refusing a size it cannot hold.

Only the *Import Disk* wizard creates a transfer: it queues it and, when
the ``xva_cron`` setting is disabled, processes it immediately, so that
the user does not have to wait for the next tick of the scheduled
action.

The module also adds the *Start on Host* wizard, opened from the *Start
on Host* button of a virtual machine, which starts the selected
machines on a host of their own server and reports the tasks it
started.  Every other power operation is run directly from its button.

The module adds the movement wizards, opened from the buttons of a
virtual machine:

- *Migrate* migrates the selected machines to a host of their own
  server, on the storage repository selected for their disks, with the
  network their migration traffic uses; the pool and the default
  repository of the destination are defaulted from the host, and the
  wizard refuses a selection holding a machine of another server before
  any movement is created;
- *Clone / Copy* duplicates a single machine, which the restriction of
  the wizard makes the safe default for an expensive operation: the
  repository selected decides whether the machine is cloned on the
  repository of its disks or copied onto another one, the name of the
  created machine is defaulted from its source, and the compression of
  the stream is only used by a copy across pools.

Both wizards create their movements in the ``queued`` state and process
them immediately when the ``xva_cron`` setting is disabled; unchecking
*Run Immediately* leaves them in the ``draft`` state, so that the
storage repository of each disk is reviewed before the machines are
moved.

The module adds the *Apply Cloud Init* wizard, opened from the *Apply*
button of a cloud-init configuration, which applies the selected
configuration to a machine on the storage repository selected in the
wizard and reports the target of the application.

The module adds the *Attach PCI Device* and *Attach USB Device* wizards,
opened from the buttons of a virtual machine, which assign the selected
device to a halted machine and report the identifier Xen Orchestra
answered for the operation.
