Update instance.node on evacuate

The evacuate API works like a migration from a dead node. As part of
migration, the instance.node property is updated to reflect the target
node that the instance is migrating to. This is later used when the
migration is confirmed/reverted. The problem is when an instance is
being evacuated, the node property isn't getting updated and the
instance will have the old (dead) node value set on it after it's
evacuated. This patch updates instance.node when the instance is
evacuated.

Fixes bug 1198284

Change-Id: I4901fb937160e955df7c97c37265783e844fdbef
Add a VIF driver for IOVisor engine

Implements blueprint iovisor-vif-driver

Unit Test is included
Follows the same structure that OVS and Qbh drivers
Includes the rootwrap config to allow calls to ifc-ctl for managing IOVisor engine.

Change-Id: I346b4d84a6e48d56f307349ed681355d26710ecd
Unimplemented pause should not change vm state on PowerVM

The instance of PowerVM does not support pause, but
after pause the instance, the state change to PAUSED,
it's unreasonable.

Change-Id: I4fb184388c37ea8708cdacc173dc1b2dbd4d1597
Fixes: bug #1202082
Handle instance being deleted while in filter scheduler

Adds handling of InstanceNotFound when trying to update the
scheduled_at time of an instance.

Users can delete an instance at any time (and many test
cases delete very quickly), so this should be a warning
not an error

Fixes bug 1191126

Change-Id: I72b296668f60b1de71ff8c6d7bbb749023d89f12
Sync v2/v3 console_output API extensions

Synchronises changes made to the v2 version of the console_output
API extension to v3 in commit c651f4928c65407cff86a9f9efc046a0f76a9519
which fixed bug  #1194032

Partially implements blueprint nova-v3-api

Change-Id: Ie28d771d25636decb7b1f17756654be56762b35f
port disk_config API into v3 part1

This changeset only copies the v2 files into the appropriate v3
directories unchanged. The copy as-is will not be loaded by either
the v2 or v3 extension loaders. The second changeset will then
make the changes required for it to work as a v3 extension.

This is being tried in order to make reviewing of extension
porting easier as gerrit will display only what is actually
changed for v3 rather than entirely new files.

Partially implements: bp v3-api-extension-versioning

Change-Id: Ia2ef4ab8cb63878d16360378c61e5182f4593200
Port used limits extension to v3 API Part 1

This changeset only copies the v2 implementation file into the
appropriate v3 directory unchanged. The copy as-is will not be
loaded by either the v2 or v3 extension loaders. The second
changeset will then make the changes required for it to work as a
v3 extension.

This is being done in order to make reviewing of extension porting
easier as gerrit will display only what is actually changed for v3
rather than entirely new files.

Partially implements blueprint nova-v3-api

Change-Id: I34214370f53d481346eb11fec6b8fd0ddeb42918
Prompt error message when creating aggregate without aggregate name

When using API to create an availability zone via aggregate, the
prompt message will be "There was a conflict when trying to complete
your request" if the request body looks like below.
{"aggregate": {"name": "", "availability_zone": "zy1_zone53335"}}

The message is not accurate, aggregate name should not be null.

Fixes bug 1188032
Change-Id: I1fb74186886283a9b6763abb665b8ce42e4bb24c
Fix aggregate_get_by_host host filtering

aggregate_get_by_host never actually joins the _hosts relationship,
so aggregates with non-matching hosts are still included in the output.

This change adds the join and improves the tests to cover the bug.

Fixes bug 1201277.

Change-Id: I87ebfe3de193b9ae47e3a2c8350a49d9cc863fb0
Fix IPAddress and CIDR type decorators

Use load_dialect_impl() user hook instead of calling
with_variant() on a type implementation in IPAddress
and CIDR type decorators. This makes this code work
with SQLAlchemy 0.8.x versions.

Fixes bug 1200231

Change-Id: Ib0eb582f472116bda817d3e35e26888dc116ad58
Fix filtering aggregate metadata by key

Filtering by metadata key has no effect in the following two functions:

    aggregate_metadata_get_by_host
    aggregate_host_get_by_metadata_key

Rely on the explicit join instead of joinedload to load the _metadata
relationship in these functions (indicated by the contains_eager
option), so that filtering by key still applies when the metadata is
collected.

Fixes bug 1201283.

Change-Id: I3e44b5db8d67787bfa14f0e57d30a02a271a8833
Port used limits extension to v3 API Part 2

Ports the used limits extension and the corresponding unittests to
the v3 framework.

Partially implements blueprint nova-v3-api

Change-Id: I6f1aa507ffd297e56d9cfd23972bc3bb15ba181a
Remove redundant if statements in cells.state

Removed redundant if statements since checking if cell is None twice
was not intuitive.

Change-Id: I20d7ade5acd27d23ba53ef065d0e4d24218182c2
Fix blocking issue when powervm calculate checksum

In powervm driver, it takes long time to calculate file checksum
before and after transferring image file. Because nova-compute is
a single thread, it won't process any other work at the same time.
Here give other threads chance to run by using time.sleep(0), that
acts as a yield of the thread for eventlet.

Fixes bug #1181895

Change-Id: I79fbd9d7d4fb7791ca599b136cf9945dec8996e2
Make Instance object properly update *metadata

Currently, the Instance object won't notice when metadata or
system_metadata has changed and thus won't include it in updates it
makes to the database.

We could make these two dicts full-fledged objects, but that's a bit
overkill for this purpose. Stash a copy of them every time we reset
our changes so that we can detect changes in save().

Note that this includes tests to some shelve tests which are now
wrong because they modify the instance's sys_meta prematurely.
Turns out, these are the tests that pointed out the need for
this tracking :)

Related to blueprint unified-object-model
Fixes bug 1201776

Change-Id: I3df462645979742379a41060cda5bb5084fddb20
Fix Instance object handling of implied fields

The situation around info_cache and security_groups is a bit
confusing and inconsistent at the moment. Since some of the
"all" queries don't join info_cache and security_groups,
avoid assuming that they are there, either triggering an
unintentional lazy load, or a KeyError in a few cases where the
DB API returns a dict.

Also, don't ever allow us to recurse into another instance object
looking for a loaded attribute in case it fails to load from the
get query.

Related to blueprint unified-object-model

Change-Id: I40b72274cd24034b03c8e07af56e7c8d49b6b898
Fix shelve's use of system_metadata

The shelve patches needed to include a hack to make the changes
to system_metadata get saved properly. Now that it's fixed,
clean that up.

Related to blueprint unified-object-model

Change-Id: I79a2db66544e0662e48445505a818ff62f765569
Fix duplicate osapi_hide_server_address_states config option

This is causing an error in the config file tool generator.
Import the config option from the v3 API copy of this code.

Change-Id: I5a03f509c91de080d3753bf351d891d06600e84b
Fix accessing to '/' of metadata server without any checks to work

Accessing to '/' of metadata server to get version information should
be allowed without any checks. Due to the wrong comparison condition,
it failed.

Change-Id: Ia8603c321839b959b120af1d018f061f438155c7
Fixes: bug #1192774
Move resource usage sync functions to db backend

Resource usage sync functions was declared in nova/quota.py, and
using db.api public methods. This functions was moved to database
backend implementation, so now sync functions can use private
methods of database backend, and session attribute can be removed
from this public methods, and even some public methods can be removed.

Blueprint: db-session-cleanup

Change-Id: I63eeb18b8ede4b4263ee553d4e70633de463e0c4