Rename instance_type to flavor in test_utils and nova.tests.utils

Renames occurrences of 'instance_type' to 'flavor' in
nova.tests.test_utils and nova.tests.utils along with any impacted tests
using the changed parts.

Part of blueprint flavor-instance-type-dedup

Change-Id: Ie816356c176c2be61b4a346a4d47d8f3461ae84a
Prevent spoofing instance_id from neutron to nova

Previously, one could update a port's device_id in neutron to be
that of another tenant's instance_id and then be able to retrieve
that instance's metadata. This patch prevents this from occurring by
checking that X-Tenant-ID received from the metadata request matches
the tenant_id in the nova database.

DocImpact - This patch is dependent on another patch in neutron
            which adds X-Tenant-ID to the request. Therefore to
            minimize downtime one should upgrade Neutron first (then
            restart neutron-metadata-agent) and lastly update nova.

Change-Id: I93bf662797c3986324ca2099b403833c2e990fb4
Closes-Bug: #1235450
Add IPAddress field type in object models

In object models, there are ipv4 address type and ipv6 address type.
However, for some fields in models.py, for instance, host_ip in compute node,
and a bunch of IPAddress variables in network, and address in other tables.

There is no field type corresponding to them, no matter whether it is v4 or
v6. So, add one more field type in object models to specify that type.

Change-Id: Ic53ed644f4bbc1e280b2f8cbb9b9c145c3d8a2e9
Pass Instance object to compute vnc rpc api

Pass a real Instance object to the get_vnc_console() method of the
compute rpc api.  The object_compat() decorator is used to provide
backwards compatibility with receiving data in the old format.

Change-Id: Ib615fd653e0ef6196241fde81f541b1e18eb3ced
Send Instance object to validate_console_port

Update the validate_console_port() method of the compute rpc api to take
in an Instance object instead of a dict.  The object_compat() decorator
is used to ensure the change is backwards compatible, and that the code
will still work if it receives an instance in dict format.

Change-Id: Ief8fabc8490315acb41bf85ad421683fea31daf9
Pass Instance object to console output virt driver api

Update the get_console_output() method of the virt driver API to be
defined to accept an Instance object.  While we're at it, pass the
context, as well.

Change-Id: If325a39f6314cff936e604fcc5816deefbb1199b
Remove unneeded call to conductor in network interface

The following patch removes an unneeded call to conductor to retrieve
data already available in instance.

Note: six.text_type() was added and wrapped around info_cache in some of
the tests. This was done because values from the db are in unicode
(text_type). The reason the test changed is because previously we
did not check the type of string from what the conductor was returning.

Closes-bug: #1258360

Change-Id: I45a24af11534911be68fd0964b79fdf726d88de6
Merge "Prevent spoofing instance_id from neutron to nova"
Merge "Pass Instance object to compute vnc rpc api"
Merge "Rename instance_type to flavor in test_utils and nova.tests.utils"
Merge "Send Instance object to validate_console_port"
Merge "Pass Instance object to console output virt driver api"
Merge "Add IPAddress field type in object models"
Merge "Remove unneeded call to conductor in network interface"
XenAPI: Speedup host_ref cannot change - get it once

The host we run on is fixed - getting this each time from XAPI
is expensive

Change-Id: Ifee9a778f3ed855ef52b001de3fc2ebbd0b972cf
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