Include list of attached volumes with instance info

Fixes bug 1112998

Change-Id: I1c3eb578339aabbcfed107043f39e30daf633c4a
Optimize db.instance_floating_address_get_all method

Optimize db.instance_floating_address_get_all
Was:
Get FixedIps with corresponding instance_uuid
For each FixedIp get associated FloatIp (N request)
Now:
Get only list of FixedIps ids
Get all corresponding FloatingIp with one query (select in)
Get only addresses from FloatingIps (because we are using only it)

Add temporary test for db.instance_floating_address_get_all to
ensure that it works as expected.

Change-Id: Id3c515de0ca35707bbfe46b991c2d7cf591e431b
Extract getting instance's AZ into a helper module.

An instance's availability zone logic may used by many modules,
so move it from extend API into helper module `nova.availability_zones`.
Also add some tests for the new method.

part of bp: different-availability-zone-filter

Change-Id: I5916a0b09d5dddec338e8e36503953720dfd6bcd
Refactor nova.volume.cinder.API to reduce roundtrips with Cinder

Make cinder.API methods accept volume_id instead of the whole volume object.
This will remove redundant roundtrip to get the volume before
passing it to other methods as in fact they only need the id.

Fixes bug 1172297

Change-Id: I5e7f944c1c29b2f211ece2ef86c0959c81e806df
Refactored tests for db.key_pair_*() functions.

All tests for db.key_pair_*() functions are in KeyPairTestCase class now.

blueprint test-db-api

Change-Id: I92358bcda157c95290b31e3b7997e3432a65b404
Add missing unique constraint to KeyPair model.

Added a missing unique constraint ("name", "user_id") to KeyPair model
(this constraint was in db schema but not in model definition).

blueprint db-enforce-unique-keys

Change-Id: Id231bca256e0cb39fcd8068acc7039240326fde2
Handle IPMI transient failures better.

Sometimes, IPMI "power status" doesn't return either "on" or "off".
When this happens, the IPMI driver shouldn't assume what the state is,
and the baremetal driver shouldn't assume that NOSTATE means SHUTDOWN.

This patch also improves the doc strings for the IPMI driver.

Fix bug 1178378.

Change-Id: I54a5e6309f68ab8e5601e65039366d7d87c03478
Reverse path SNAT for DNAT floating-ip.

This patch applies a reverse SNAT rule to allow instances that have an
assigned floating IP to communicate with other instances in the same
OpenStack deployment, security group rules permitting. The patch
allows members of the same private network to communicate with each
other using their floating-ips in a more consistent fashion. The rule
also addresses the situation where the target is on another private
network.

This will only work for interaction between two servers that both have
floating IPs assigned to them.

Specifically, this patch solves the problem where a target server
"sees" the private address of the client. By SNAT'ing to the client's
floating-IP, the "sees" the correct reply address and the reverse
route follows the same path that an actual external connection would
take. The SNAT ONLY occurs if a DNAT occurred before hand, allowing
communication on private networks using private IPs to remain fully
private and internal. The limitation is of course if a DNAT occurs for
other reasons, there may be issues.

Resolves bug 1178745

Change-Id: I55b7131cff5fd5a2ebf826945370d4d550e74136
Fix quantum security group driver to accept none for from/to_port

The quantum security group driver did not accept none values for
from_port/to_port which the nova security group api supports. This
patch allows None values to be passed in for those params and adds a unit test.

In addition the from/to_port responses would be different if using quantum
instead of nova. This patch fixes that and adds unit tests.

Fixes bug 1176027

Change-Id: Id57e253c9dd1787ee25fc5cbb562743692d7abe4
Pass the proper admin context to update_dhcp

Bug 1180111

Commit 14e2ed3ace769c4deaca3c48a2fa59863f637a5f introduced changes
to contexts passed around during resize. One of the calls to
update_dhcp was missed and was causing stack traces on
resize-revert.

Change-Id: Ib7bec51324c7bced009407af13a7fff7a724e020
Cells: Don't allow active -> build

Adds support for passing 'expected_vm_state' in an instance_update dict
much like the current support for 'expected_task_state'.

For cells, when the API cell receives an instance update containing a
vm_state of BUILDING, raise an exception if the instance is in some
other state.  This addresses out-of-order messaging issues that can
cause an instance to appear to have a huge delay going ACTIVE.  (A
periodic task run can later heal the state, but it can take a long
while)

Fixes bug 1180283

Change-Id: I64252b30e2596812f3b84da64b1fc8681661d7f8
Merge "Optimize db.instance_floating_address_get_all method"
Merge "Refactored tests for db.key_pair_*() functions."
Merge "Add missing unique constraint to KeyPair model."
Merge "Pass the proper admin context to update_dhcp"
xenapi: ensure vdi is not too big when resizing down

Fix for bug 1155066

This change adds some rollback into the resize disk down
code within xenapi, and reports a better error message
when the disk is too big to resize down.

On a successful rollback, the user is notified of the error
by the instance actions, rather than leaving
the server in the error state.

The user is then able to free up some disk space such that
the resize can work correctly.

Change-Id: Ibad568ab3cfb9caaf4fe002572c8cda973d501a7
Add missing tests for db.fixed_ip_*(). functions.

Added new tests for fixed_ip*() functions.
Function fixed_ip_create() should return FixedIp instance rather than
FixedIp.address, because it is used in a tests later.
Fix calls of fixed_ip_create() respectively.

blueprint test-db-api

Change-Id: Id5e9d4486605bde9d9fd1e631d868603a7a7c604
Merge "Handle IPMI transient failures better."
Merge "xenapi: ensure vdi is not too big when resizing down"
Merge "Include list of attached volumes with instance info"