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
VlanManager creates superfluous quota reservations

The VlanManager does not enforce quotas on fixed IPs because it
allocates an entire network to a project. However the process
of deallocating an IP address still creates an entry in the
reservations table.

The VlanManager now loads the NoopQuotaDriver and no longer
writes superflously to the database.

Change-Id: Idf95085a5c1f4e71f3f0fc92618607073602eed3
Fixes: Bug #1204714
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
VMware: fix rescue/unrescue instance

Fixes bug 1199955

The problem is due to the way in which the VM's are named on vCenter.
That is, in Nova a VM has a name and a UUID. In vCenter the VM only
has a name. The VM name on vCenter is Nova's instance UUID. When the
rescue/unrescue operation takes place a new VM is spawned/destroyed.
The Nova VM has the name '<name>-rescue'. The problem is that the
new rescue name was not passed correctly to the vCenter, that is,
it should have been '<uuid>-rescue' but it was just '<uuid>'. This
caused the opertaion to fail as there is already a VM with that name
on vCenter. A new name should have been passed which is '<uuid>-rescue'.

Change-Id: Icfe6e5021b29026788bec8f3526f94a8ec0a65e2
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
Upgrade to Hacking 0.7

There was a bug in hacking 0.6 that broke H202, assertRaises Exception
too broad, so switch to Hacking 0.7 and fix the one H202 bug.

Change-Id: Ia3fb22d1524022479d7068cb84a3bdf7ca19f408
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
Have tox install via setup.py develop

tox 1.6 was released, which means that we can now take advantage of the
feature we added to it - which is using setup.py develop to install the
code into the virtualenv. The logic was taken from run_tests.sh - so the
performance issues around using tox vs. using install_venv should now be
gone.

run_tests.sh is still needed to handle the ui switching between
parallel, single and debug modes to testr.

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