EC2-API: Fix ambiguous ipAddress/dnsName issue

Currently, the public ipAddress and dnsName take in either the
fixed or floating IP address as a value. The current fix ensures
that the public dnsName and the public ipAddress both get only
the floating ip address. A look into Amazon's EC2 API Reference
tells us that if there is no public IP associated with an instance,
an empty value is returned for <dnsName> and the key <ipAddress>
itself is never returned. This was tested with euca2ools.
Also, the key <publicDnsName> has been removed since it is
the same as <dnsName>

Fixes: bug #1096468

Change-Id: I3b3e3b3f815df41d1976444d33604363e64a7709
handle auto assigned flag on allocate floating ip

Set auto_assigned field to the right value on allocating floating ip to
avoid potential race condition in nova-network.

fix bug 1190585

Change-Id: I8ee34924439d2a29b1b5a966b92856e63cc1afdc
Make nbd reservation thread-safe

Avoid the situation where two local threads choose the same nbd number
for injecting files into the instance. If this happened quickly enough
nova was left with one qemu-nbd hanging and blocking the device forever.

Fixes bug 1207422

Change-Id: I18864b19ebd30669534e45ca7a50e12f61207302
Clean destroy for project quota

    * Destroy user quotas under the project when deleting project quota.
    * Fixes bug 1206479

Change-Id: Id8391a2f6c25974b990c4a95a6bc99d696cd1c98
Don't inject files while resizing instance

Fixes bug 1208680

As what the code owner of method 'finish_migration' in libvirt driver
said, the files injecting operation is not necessary during resize,
because they have already been injected when creating the instance,
so added a parameter to _create_image to fix this issue, which is used
for identifying the injection is needed or not.

Change-Id: I01990de0ad2c7f1c2e499144034b7a4ac9faf024
Enable no_parent and file_only security

The websockify package was recently upgraded to version 0.5.1, which added two
parameters that provide additional security:
* no_parent - returns 403 response if contents out of the web root are
requested. Required to disable directory traversal.
* file_only - returns 404 response if non-file contents are requested. Required
to disable directory listing.
This version is available in PyPi.

Nova should upgrade it's required version for websockify, and set these
parameters while creating and starting the NovaWebSocketProxy to ensure
better security.

DocImpact
Fixes bug #1195700

Change-Id: I9c4b28eb1b384048f10d365ed204b916afd371bb
Add an exception when doesn't have permissions to operate vm on hyper-v

This commit adds a wrapper checking method when creating/operating
vms on hyper-v, it will raise a HyperVAuthorizationException if the
windows account running nova-compute on this Hyper-V host doesn't
have the required permissions to create/operate the virtual machine.

Fixes bug #1195205

Change-Id: I2ef67a686c99dc83fcc3e9f47a71473929b01e9f
Don't need to init testr in run_tests.sh

In run_tests.sh, function init_testr will initialize testr if the
directory .testrepository is not existed. Actually, testr will do
the check before run the test:

In Python package testrepository, setuptools_command.py:Testr.run

68 def run(self):
69     """Set up testr repo, then run testr"""
70     if not os.path.isdir(".testrepository"):
71         self._run_testr("init")

So, init_testr can be removed safely.

Fixes Bug #1211098

Change-Id: I4bd2ef3dc107281892732efced268eb3b7c90cbb
Fix FK violation in ConsoleTestCase

setUp() of ConsoleTestCase creates a few Console instances
that reference a non-existing instance with generated UUID
value. The tests work great on SQLite (because FKs are disabled),
but fail on MySQL and PostgreSQL.

Blueprint: db-api-tests-on-all-backends

Change-Id: I2417b6f6dad8c9c84af8b49a3c6db8b9bb715e56
Removed code duplication in test_get_server_*_by_id

blueprint api-compute-servers-tests

Change-Id: I3aa8580941984029baf3d39e30b5c0e9b491bc24
Fix one port can be attached to more devices

a port attached to some device should not be attached to another device again

Change-Id: I60de0fa265358ac5b5e1b2c8f370862b32f9e724
Fixes: bug #1204850
Fix HTTP response for PortInUse during boot (v3 API)

If an in use port is passed as a network parameter in the request, Nova API
should raise an HTTPConflict (409) error. This was fixed in commit
48b31c9a1f5d2a45d881e70c6223411c5abbcb72 for the V2 API but not the V3 API.

Fixes bug 1212098

Change-Id: I94429f2c04cf81cb88a8739f65a49aa7ca0d49bd
Raises masked AssertionError in _test_network_api

The _test_network_api method was catching an AssertionError to do some
more checking but failed to raise the original error if the checking
didn't hit any matches. This patch fixes the test to raise the original
assertion error.

Closes-Bug: #1212017

Change-Id: I33147d18e33cd4babfc3f5cb572007bc7e4c07e6
Implement front end rate-limiting for Cinder volume

Cinder adds Quality-of-Service control interface to allow admin to
specify QoS parameters as well as the place where these parameters
should be consumed (Front-end: Nova Compute, Back-end: Cinder
Volume, or Both) for volume types.  KVM and other hypervisor is
known to be able to do disk rate-limit control (one form of QoS)
for virtual disks, this patch enables Nova Compute to extract
rate-limit parameters for volumes while attaching, currently
libvirt only.

implement bp volume-rate-limiting

Change-Id: Ibcc8f15ab744600e6f814b46935f8022d78074fc
Allow Cinder to specify file format for NFS/GlusterFS

These drivers now have the option of passing a QCOW2 file rather
than a raw file as the volume to attach to the VM.

Required by blueprint qemu-assisted-snapshots

Change-Id: I23929538c7dad65035db5c38ff6e52348925fa27
Unimplemented suspend/resume should not change vm state

When the underlying virt driver does not implement the suspend/resume API
and raises a NotImplementedError, the compute manager will error out and
change the instance's vm_state to ERROR. With this change, the compute
manager will handle the NotImplementedError and keep the instance
vm_state as it was before the error.

Change-Id: I8150a898fee91bbe66f1502638baca8050e2dd6d
Fixes: bug #1203986
Fix untranslated log messages in libvirt driver

Fixes bug 1213040

Change-Id: Ib3b7a46c312b88778cc6e872a2c19061a5774125
baremetal: Log IPMI power on/off timeouts

Added log messages for cloud operators so that they can tell when an
attempt to turn a device on or off via IPMI has failed after the
configured number of attempts.

This should help operators diagnose issues on devices that respond
slowly to IPMI commands.  The failure to repeatedly change the device
power state is now logged precisely along with the cause, where
before operators had to diagnose the issue through trace log captures.

Partial-Bug: #1177584
Change-Id: Iecd6fadb2b653f4ccbe75882c2ef85812b334e8d
libvirt: allow passing 'os_type' property to glance

Currently, libvirt driver doesn't pass the 'os_type' property to
glance. Thus all snapshots created don't have this property. Other
feature depend on 'os_type'(such as mkfs for ephemeral devices)
doesn't work.

This patch fixes this by passing the 'os_type' attribute to glance
as image properties. None value in metadata properties would not be
passed to glance, thus this patch has no side effect on situation
when instance has no 'os_type' attribute set.

Bug 1214372

Change-Id: I2bab617f6c1e8866650ca7dc5178b640738c9ae6
fix volume swap exception cases

Currently when the target instance id doesn't match with the instance_id of the
volume to be replaced VolumeUnattached is raised, and InvalidVolume would be a
fittest response.
In the other hand, currently, when the volme to be replaced is not attached at
all InvalidVolume is raised, and VolumeUnnatached would be a fittest response.

Change-Id: I661b97762af70765ab8111313d24cf1a175f7e6c