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
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
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
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
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
Add flag to make IsolatedHostsFilter less restrictive

This patch allows to run 'isolated' and 'non isolated'
images on isolated hosts by adding a flag
'restrict_isolated_hosts_to_isolated_images'.

If the flag is set to True then 'non isolated' images
can't be run on isolated hosts (same behaviour as the
current filter) otherwise they can be run on isolated
hosts.

DocImpact

blueprint improve-isolatedhostsfilter

Change-Id: I8c092caf32c05be88a547a7e8cb0530cc4925080
Port flavormanage extension to v3 API part 1

This is part 1 of the two part commit to port migrations to v3.
As part of this commit the api and test files are copied over to v3
plugins folder. The second changeset will have changes to port
migrations to v3.

Partially implements blueprint nova-v3-api

Change-Id: I2a51185f557c68022a2f3aaa006acb1e89b3c737
emit warning while running flake8 without virtual env

run_tests.sh -N -p
it will call the flake8 installed on your host to detect PEP8, and
the flake8 plugin "OpenStack hacking" may not installed on your
host, so this command may not detect the OpenStack Style Commandment
supplied by hacking(e.g H202).

run_tests.sh -p
it will call the flake8 from virtual env, flake8 plugin "OpenStack
hacking" installed in virtual env will be triggered.

The result from "run_tests.sh -p" should be trusted, and jenkins uses
virtual env to run flake8 too.

When "-N" is enabled, emit warning to remind user.

Bug #1215404

Change-Id: Ie503fa34e6a3cf7b1f52f0b53019ddea188dabff
Delete expired instance console auth tokens

Instance console auth tokens never get deleted from the cache
before the instnace is deleted, this is a waste of memory. now
we check if tokens are expired then remove them from the cache
before store new tokens.

Fix bug #1209134

Co-authored-by: Takashi Natsume <natsume.takashi@lab.ntt.co.jp>
Change-Id: I8dd5089ebaed3b3d91932f1f1558bbe302cd5675
Fix unicode key of azcache can't be stored to memcache

The memcache library we are using assumes all strings passed to
it are plain ascii, so we need to convert unicode to string.

Fix bug #1212164

Change-Id: Ibf36e6b096893cb9f056371bb43cbb441cae6e32
Add alias as prefix to request params for user_data v3

fix bug 1215710

DocImpact

Change-Id: Iae48d2caefb1de46698c57712eae357c70c78997
Fix network creation in Vlan mode

- If "vlan" is specified when creating a network, we honour the option.
- If it is not specified, the Vlan number is calculated as follows:
CONF.vlan_start + num_existing_networks + index_of_requested_network
- If the above vlan is in use, try to get the next free vlan.

Fixes bug 1194835
Fixes bug 1169026

Change-Id: Id4476c14f9dadcf498a499534337477b3f64f604
Adds V3 API samples for migrations

Partially implements blueprint v3-api-unittests

DocImpact

Change-Id: Ic1a1b96f00831b22c9499d3ac2953f3d08819905
Adds API version discovery support for V3

Adds version information for the V3 API which is only displayed
when the V3 API is enabled. Even if the the V3 API is enabled the
V3 API status is "EXPERIMENTAL" and the V2 one "CURRENT". This was
done so autodiscovery tools would not yet use the V3 version by
default.

Ports the relevant parts of the version extension and associated
tests to the V3 API to display V3 version information for /v3 GET
requests.

DocImpact

Partially implements blueprint nova-v3-api

Change-Id: Idd335ce0df63d91e94a4a757f1fbae94b576c37e
Correct default ratelimits for v3

* 'change-since' was changed to 'change_since' for v3
* Use the ratelimits middleware that is in v3 limits

fix bug 1216467

Change-Id: I8c466cf2ad8a1f00f002050db01ab68404f607e5
Disconnect from iSCSI volume sessions after live migration

The live migration source host will now disconnect from
iSCSI volume sessions after the VM is successfully migrated
to the destination host.

Fixes bug 1132146
Change-Id: I132869612bdf2baa810756586e643ea68ea8d8f6
xenapi: Improve test_xenapi unit testing performance

In investigating performance of the test_xenapi unit testing I
discovered that about 25% of the time is spent in FakeVirtAPI.instance_update.
This function in turn calls db.instance_update_and_get_original to note changes
in state during spawn for most of the unit testing in XenAPIVMTestCase.

XenAPIVMTestCase, doesn't ever check/verify the updating of db based on spawning
of instances.  As such this is wasted effort which can be eliminated since that
verificaiton is not the intent of the tests from what I can gather.

In my testing this reduced running times from 19-20 seconds down to 14-15 seconds
with all unit tests still succeeding. test_xenapi is the by and far the largest
offender in xenapi tests.  Overall xenapi tests we're reduce from
21-22 seconds to 16-17 seconds.

Fixes bug 1218012

Change-Id: Iaa6441655ad100fdb4ffd2bd5eb6265429c133f6
Added new hypervisor to support Docker containers

Docker brings an alternative to support Linux Containers (LXC)
as instances. The code has been imported from:
https://github.com/dotcloud/openstack-docker

blueprint new-hypervisor-docker

Change-Id: I0f1ff8acb5a93ba1dc680c68633c43454d1e804c
Remove unused fake run_instance() method

In a bunch of tests, we stub out rpc.call() and use it as a hook to
create instances and return their details.

The thing is, we never actually call() 'run_instance anymore .. we
always cast() it. So, these fake methods never actually get called and
can be safely removed.

A similar change was made in I63bbc98c285faebec53f8e62857c01548807db68
but some more copies of this have been added recently. Copy and pasted
code FTW!

blueprint: oslo-messaging
Change-Id: I1a5a048ed9b0d939d50f7728a348bb6c5a6074dc