CA-102759: loosen HA restriction on expired hosts

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
PR-1455: Remove VMPP specific mail-alarm code

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
PR-1455: Revise default priority threshhold in mail-alarm

  * The previous PR-1455 work changed from mail-min-prioirty to mail-max-priority. I believe this is an unnecessary change that break backward compatability. "mail-min-priority" can literally mean the lowest message priority level to trigger an email alert. Which direction (greater value or smaller value) is lower is up for interpreation.
  * With PR-1455 definition, priority value between 1-3 will require actions, hence change the mail-min-priority threshhold to 3.

We should probably document this mail-min-priority config as part of PR-1455 doc in the release note (for incomptabile changes to the alert system in general).

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
PR-1455: rewrite message priorities online during rolling pool upgrade

During rolling upgrade, upgraded master might have an alerts grading system different from the not yet upgraded slaves. During this process, as a special case, we transform the priority of a received message (if the message belongs to the standard messages set).

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
PR-1455: Move some code from Xapi_message.create to Xapi_message.write

... so that we can reuse them when calling Xapi_message.write directly.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
PR-1455: rewrite message priority values during upgrade.

A host post-upgrade might have different priority on messages from pre-upgrade. In order to reduce confusions (e.g. messages with the same code before and after upgrade shown together with different priorities),  here we convert the messages pre-upgrade to use the new priority values.

We are using a very straightforward algorithm here: destroying a old message and recreating a new one keeping most of the settings untouched but the priority. A more elegant solution would be creating facilities to upgrade an existing message rather than destroy/recreate one. In fact, I was half way on that solution but decided to take the no so elegent but simpler approach. The straightfoward implementation can avoid many of the complexities because messages are not part of the datebase hence many things have to be updated manually (e.g. event, gen, symlink). It's much reliable to reuse the existing facilities rather than creating the new ones.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
PR-1455: Update pool's other-config:mail-min-priority to the new alerts grading system

Users were allowed to set the mail-min-priority to arbitray value before, so there isn't a definitive algorithm to map the setting to the new alert grades. This is just one reasonble way making the transformation:

Given previous mail-min-priority = n

    n > 10       ->  0
    n = 10       ->  1
    5 < n < 10   ->  2
    n = 5        ->  3
    1 < n < 5    ->  4
    n <= 1       ->  5
    unrecognized ->  remove (reset to default)

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Bump API version number

... for clearwater.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
CA-95053: VM.start should check if a host has enough memory

Though it should fall back to just trying anyway in case of
failure as memory checks are notoriously hard to get right.

This patch is based on a similar one by Jerome Maloberti.

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CA-101699: Run VM.copy on the master

The VDI.copy subtask(s) created by VM.copy will be forwarded to suitable
hosts, so it's debatable whether we need to forward VM.copy at all.

Before this change the VM.copy task was forwarded based on source SR(s)
only, which is definitely wrong - in the case where a VM is being copied
from shared storage to local storage, the VM.copy task would be
forwarded to a random host (with slaves preferred) and then the VDI.copy
task(s) would be forwarded again to the host connected to the local
storage.

Besides kicking off VDI.copy tasks, VM.copy mostly just creates objects
in the database and watches for events on those VDI.copy tasks, both of
which are most efficient on the master.

Maybe when the database is split up across hosts it will make more sense
to forward the VM.copy task to a host which can see both the source and
destination SRs.

Signed-off-by: John Else <john.else@citrix.com>
CA-101699: Don't serialise VM.copy per host

VDI.copy is the CPU-intensive task so there's no need to serialise
VM.copy per host, especially now that VM.copy always runs on the master.

Signed-off-by: John Else <john.else@citrix.com>
CA-101699: Allow VDI.copy if a VDI is only attached RO

Attempting to copy a VDI which is being written to can confuse
sparse_dd, however if a disk is only attached RO it's safe to copy it.

Signed-off-by: John Else <john.else@citrix.com>
Move test_ca98944.ml

This can be used as a basis for more VDI.allowed_operations tests so
let's give it a more generic name.

Signed-off-by: John Else <john.else@citrix.com>
CA-101699: Add unit tests for the allowed_operations changes

Signed-off-by: John Else <john.else@citrix.com>
CA-101175: Replace Event.next by Event.from

Signed-off-by: Vincent Bernardoff <vincent.bernardoff@citrix.com>
CA-101175: Event.from timeout now 30 seconds, only watch for the specific tasks

Signed-off-by: Vincent Bernardoff <vincent.bernardoff@citrix.com>
Add 'vgpu' option to vga platform key
CA-100685: When domain disappears during VM shutdown operation, just go ahead instead of rasing any cancellation error

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Revert Storage_interface.query_result.features to a (string list)

This means storage_interface.ml is now identical to the Tampa version.
The features are parsed into (string, int64) pairs at the xapi level
instead of at the SMAPI level.

Signed-off-by: John Else <john.else@citrix.com>
Move some boilerplate into the Test_highlevel functors

No actual functional changes to the tests, just lots of moving things
into and out of modules.

This change causes the function (val test : unit -> unit) to be
automatically generated by Test_highlevel.Make

Signed-off-by: John Else <john.else@citrix.com>