LXC: Image device should be reset in mount() and teardown()

When fixing bug#1208387, image device name is returned in function
setup_container. But it's missed to reset in function mount() and
teardown().

This patch is to fix it. We now just return the device name when
mounting disk image during setting up container and remove the
member variable 'device' from Class _DiskImage added in last patch.

Closes-bug: #1243108
Related-bug: #1208387

Change-Id: I2aaed6f3367edce4fb23b78f0e979440954609a8
Rename instance_type to flavor in nova.cloudpipe

Renames 'instance_type' to 'flavor' in the nova.cloudpipe module.

The deprecated vpn_instance_type option is removed as part of
change I64548e40f so I leave it untouched here.

Part of blueprint flavor-instance-type-dedup

Change-Id: Id4fd757fabfb81ee81999e7978c924aabd0a712b
Rename instance_type to flavor in nova.utils and nova.compute.utils

Renames 'instance_type' to 'flavor' in nova.utils and nova.compute.utils
and related tests. Removes the unused fake_get method in
test_compute_utils.

Note that the nova.notifications payload isn't updated yet to store
flavor instead of instance_type so this patch still uses
payload['instance_type'] when processing the notification in
test_compute_utils.

Note that instance_type_id and the instance_type_* keys in
system_metadata are part of the data model and would require a database
migration to change, so those are not part of this patch.

Part of blueprint flavor-instance-type-dedup

Change-Id: I56815e5c8238f8e4ad4e3a2a599310da2b7f4568
Retry on deadlock in instance_metadata_update

THe instance_metadata_update() method in the sqlalchemy db API may hit a
DBDeadlock, as shown in the bug report.  Apply the necessary decorator
that will have the method retry in that case.

Change-Id: Ice3f13857ba8f4ee1d1d2dc06cef293e6d17daca
Closes-bug: #1262154
Merge "Retry on deadlock in instance_metadata_update"
Merge "Rename instance_type to flavor in nova.cloudpipe"
Merge "Rename instance_type to flavor in nova.utils and nova.compute.utils"
Merge "LXC: Image device should be reset in mount() and teardown()"
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:

	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