Rename instance_type to flavor in xenapi virt driver

Renames 'instance_type' to 'flavor' in the xenapi virt driver and
associated tests.

Part of blueprint flavor-instance-type-dedup

Change-Id: I0f1a17b725102eab30ce90714b50444d8d140da0
Better exception handling for deletes during build

To retain parity with the current run_instance boot process we should
not set the instance to ERROR if a delete occurs while it's building.

Some instance updates were moved into try/except blocks so the
task_state check failures are handled properly.  And a test for a
condition that can't occur was removed.

Part of bp remove-cast-to-schedule-run-instance

Change-Id: I688059404d6b697bd21f6037252dbe628c1b24f2
Whitelist external netaddr requirement

* tox.ini(testenv.install_command): Use the --allow-external and
--allow-insecure options so that pip 1.5 and later will assent to
retrieve the netaddr package even though it's not hosted on PyPI.
The --allow-insecure option is aliased to a clearer
--allow-unverified wording in 1.5, but the old form is being used to
avoid breaking users of 1.4.x and will be valid at least through
1.6.x according to comments in the pip source.

Partial-Bug: #1266513

Change-Id: I005e752c8cb9bca78b1ebe777eb5230e9bf05bd8
Don't deallocate/reallocate networks on reschedules

If network allocation is not host dependent we don't need to deallocate
and reallocate a network for each reschedule.  Only baremetal has host
dependent allocation so for that driver networks are de/reallocated on a
reschedule.

The current method in the code which checks for the length of the list
returned from _get_instance_nw_info() doesn't work because it can't
distinguish between an unallocated network and one that doesn't return
network information.

Part of bp remove-cast-to-schedule-run-instance

Change-Id: Ic427715f46cb5179a37c593c4217f239c65544c3
Merge "Rename instance_type to flavor in xenapi virt driver"
Merge "Better exception handling for deletes during build"
Merge "Don't deallocate/reallocate networks on reschedules"
Merge "Whitelist external netaddr requirement"
XenAPI: get_info was very expensive

Getting the whole VM record is expensive and slowed down Tempest tests
significantly.  Replaced with getting each required item.

When getting power state, only need that specific value, so reduce the
calls to get_info too.

Change-Id: I93bcef5b692a531aac41518dc29d5d4f46cded65
XenAPI: Tidy calls to get_all_ref_and_rec

get_all_records is more efficient than getting them individually in the
old get_all_ref_and_rec implementation.

Replaced some cases of get_all_records with a faster and more
specific API call.

Change-Id: I4725c3f1fdebdf1737941cb7db69b19afb22df9f
XenAPI: Speedup get_vhd_parent_uuid

In many cases the VDI record has already been retrieved.
Use it rather than expensively getting a new VDI record from XAPI.

Change-Id: I469e2a415c1f1924010f47d3927ca18c45a7b8f8
XenAPI: Use get_VALUE in preference to get_record()['VALUE']

Replaces calls to get_record where only a single item is retrieved
from the record with the specific get_VALUE call.

Change-Id: I52e20c4f4c9d6a6ad019694916ee057cc96b18a6
XenAPI: Monitor the GC when coalescing

Add a new host plugin to monitor whether the garbage collector is running.
This is then used by the wait_for_vhd_coalesce function to know whether
waiting any more is likely to produce the expected results.

Increased the number of times we loop waiting for coalesce as the loop
now has knowledge that something is still happening.

Change-Id: Idcc0738945bd1aee8cdb52c9cfabd798f85c31db
Closes-bug: 1258169

Conflicts:

	etc/nova/nova.conf.sample
	nova/virt/xenapi/vm_utils.py
XenAPI: Use direct IO for writing config drive

If you don't use direct IO when writing to the device, the unplug
immediately following this may not succeed as the device may still
be in use.

Also add a sync to ensure the device is not being used at the point
of unplug.

Closes-bug: 1259163

Change-Id: I68f09835648b36772a7839af9718123a4c60734f
XenAPI: Allow use of clone_vdi on all SR types

All XenServer SR types support VDI.clone - even if they perform
an internal VDI.copy.  Always use the clone function if COW is
enabled.

Change-Id: I85c580fba43d3bb52149626419d0f0c03ed69145