xenapi: test functions for _stream_disk

Add test cases to cover nova.virt.xenapi.vm_utils:_stream_disk, so that
it could be refactored/extended without fear.

Change-Id: Ice43218680d2d5dffad51155cd8da2c2ad2e2cfa
Fix logic in add_host_to_aggregate()

Commit I788782a9f21ec2672551f75123753175bb268586 introduced some
changes into the add_host_to_aggregate() method to catch adding an
host to an availability zone when the host was already a member of
a different availability zone. However there were a couple of issues
with this change. There was no check that the availability_zone was
in the metadata grabbed from the database which would raise a
KeyError back to the api. Additionally, the check wouldn't always
work as expected because the database returned a set of availability
zones (including sometimes an empty set) so the check would fail in
some conditions when it was expected to pass.

This commit fixes the logic for checking if the host is already in an
availability zone. It also replaces the try/except block in the
aggregates extension to check up front if the action is valid instead
of waiting for a key error when it goes to use the action.

Fixes bug 1208627
Fixes bug 1208628

Change-Id: I81b79602e23e78c8b077d313e556796de1255bbf
correct the name style issue of ExtendedServerAttributes in v3 api

correct the camel style issue of the attribute ExtendedServerAttributes:
namespace in v3 api

fix Bug #1214317

Change-Id: If58d8cd8a82a88a94302c3b0aa3d23f5414328cb
Add unique constraint to AggregateMetadata

Added unique constraint
'uniq_aggregate_metadata0aggregate_id0key0deleted'
('aggregate_id', 'key', 'deleted') to
AggregateMetadata model and migrate
scripts.

Exception from UC violation used in method
aggregate_metadata_add() for race condition check.

blueprint db-enforce-unique-keys

Change-Id: I793706964ce76340c87e536af35a2dfa37408869
Use the common function is_neutron in servers.py

Remove duplicate code and use common utility function

Change-Id: Iff957a56cf0d43dcc9f7eba00a36530c485486ae
Allow more than one ephemeral device in the DB

This patch changes the database api behaviour when creating/updating a
block device mapping to allow more than one ephemeral device instead of
overriding the old ones.

Part of blueprint: improve-block-device-handling

Change-Id: I71c283cbd5ad3d28a27d06cb01b5ba9433f8ab46
Use new BDM syntax when determining boot metadata

This patch makes it possible to use new BDM syntax (if it was used in
the request when booting) to be used when determining where to get the
metadata from.

Since the new syntax has the boot_index field - it is easy to determine
which device is intended to be booted from.

blueprint: improve-block-device-handling

Co-authored-by: Xavier Queralt <xqueralt@redhat.com>

Change-Id: If92c9df261880eb0dcf0fd0a81fd1ae7c688d201
Merge "Add unique constraint to AggregateMetadata"
Clean up some unused wrap_exception() stuff

The only use of wrap_exception() without notifier and publisher_id
arguments is in nova/virt/libvirt/driver.py ... and since no notifier
argument is supplied, this decorator does exactly nothing useful. So
let's delete the useless uses of this in the libvirt driver.

Now we can make the notifier and publisher_id the only arguments to the
decorator and make them mandatory, allowing us to clean up some unused
stuff.

blueprint: oslo-messaging
Change-Id: I482e7f5e536493c06334b6aefb50c0e48d80c478
Merge "Use the common function is_neutron in servers.py"
Merge "xenapi: test functions for _stream_disk"
Merge "Clean up some unused wrap_exception() stuff"
Merge "Allow more than one ephemeral device in the DB"
Merge "Use new BDM syntax when determining boot metadata"
Merge "Fix logic in add_host_to_aggregate()"
Merge "correct the name style issue of ExtendedServerAttributes in v3 api"
XenAPI: Support local connections

Currently there is no way to connect to XAPI through the unix socket,
requiring a URL and credentials.

This change allows you to run in dom0 (particularly in xenserver-core
environments) and connect to XAPI using the unix domain socket by
specifying "unix://local"
DocImpact

Change-Id: I3d5ace31c9c0411fa711cfdf87383d36f61bfa4a
XenAPI: Return platform_version if no product_version

Nova now requires a version to be set.  In the case of xapi-XCP/xenserver-core
no product_version exists, so use the platform_version instead.

Fixes bug 1206948

Change-Id: I4d6008216075716c8b969493b7a2ccb7713f755d
XenAPI: Generic Fake.get_all_records_where implementation

Tests were incorrectly passing due to bad implementations.

Note that link to xenserver-core blueprint is due to patch following this
change

Implements blueprint xenserver-core

Change-Id: I051877551611e001295403af8369bcc97c8ba0fb
XenAPI: SR location should default to location stored in PBD

This value must be read from the PBD as it may change for different
installations.  The existing default is preserved as a fallback
for the cases where a PBD path is not set.

Implements blueprint xenserver-core

Change-Id: I055ebe8d7d79f238b0b9565277acac945bbe12e1