Make test_evacuate from compute API DRYer

test_evacute creates a context in almost every test
and sets its properties. Move that to a method to avoid extra
copy/paste.

Change-Id: Ib75575061bddf2546c46a6ef788ab85b5926ce69
Fix monkey_patch docstring bug

Modify Flags.monkey_patch to CONF.monkey_patch

Change-Id: I773a94d97d206bf78ac52de8e22d9e6db7650eb9
Closes-Bug: #1258048
Add error as not-in-progress migration status

When a migration status becomes "error" the migration is no longer
in progress, i.e. it is in a terminal state.  However, the
migration_get_in_progress_by_host_and_node method returns migrations
that have an "error" status, causing, among other things, the
Resource Tracker to continually log messages about how an
Instance is not resizing, creating excessive noise in the logs,
especially since the fact that a migration is entering the "error"
status is already logged.  This change causes "error"-status
migrations to not be included when retrieving "in progress"
migrations.

Closes-Bug: #1258275

Change-Id: I67bfec9f91f89ff38422469a5d86e14c4fffa40b
Remove update_service_capabilities from nova

From the comments of update_service_capabilities, it is said that
once publish_service_capabilities was removed, then we can begin the
process of its removal.

publish_service_capabilities has been removed in patch
I31c21055163e94b712d337568b16b9b7a224b52f, so we can remove
update_service_capabilities now.

Change-Id: I46be33462321f5e3ff0904bdff8dbfe2fbe115cd
Closes-Bug: #1263569
XenAPI: Allow use of clone_vdi on all SR types

All XenServer SR types support VDI.clone - even if they perform
an internal VDI.copy.  Always use the clone function if COW is
enabled.

Change-Id: I85c580fba43d3bb52149626419d0f0c03ed69145
Update log message when remove pci device

When remove pci device, the log message does not include exception
message even the exception has been caught.

This patch was put the exception to the warning message.

Change-Id: I3c604a3c80b501dedf1f0dd9fab9f399ae73f481
VMware: improve connection issue diagnostic

This exception block can swallow all issues with a connection
adding something to log the exception thrown can aid in
the troubelshooting of a Nova node's configuration. This is
invaluable when guiding someone in the field through setup
because they may mis-type a key value or misconfigure an IP.

Change-Id: I27e5ed5c51926cfeb6747980df02a396f566dd77
Add alias as prefix for flavor_rxtx v3

As v3 api rules, the extended attribute should be with extension
alias as prefix. So fix this case for flavor-rxtx v3 extension.

Closes-bug: 1252986
DocImpact

Change-Id: I9f5984a406d039245db4bef2df53cfe10a331cc2
Allow deleting instances while uuid lock is held

Avoid issues where locked up operations on the instance prevent it
from being deleted by the user. Reasons for the lock up are a separate
issue and will be handled elsewhere, but terminating the instance
should not affect any tasks anyway. Any modification should already
gracefully handle the instance going away.

For more discussion about the issue see:
http://lists.openstack.org/pipermail/openstack-dev/2013-October/017454.html

Partial-Bug: #1248563

Change-Id: Ife26ffefccea11d6e9ca5fbd970192b322fc04fd
Update class/function name for test_extended_availability_zone.py

In test_extended_availability_zone.py, it was using class name and
function name as following:
1) ExtendedServerAttributesTest
2) assertServerAttributes

This is not accurate as this test file is for availability zone,
this patch was change the above two names to:
1) ExtendedAvailabilityZoneTest
2) assertAvailabilityZone

Change-Id: I52d6ebcb1388fc10ac92d66cae166391d46e68c1
Revert "Whitelist external netaddr requirement"

This reverts commit de59c55e77ead72df42c0445c09cf4d63131f6bd.

The netaddr developers have agreed to go back to uploading releases
to PyPI, so this workaround is no longer necessary. For details see
https://github.com/drkjam/netaddr/issues/57#issuecomment-31796111 .

Change-Id: Ieeb3e8e549d9e4b53dba0165277fa2423d2eba01
Enable compute_node_update to tolerate deadlocks

When running the CI there were cases when the aformentioned method would
throw a DBDeadlock exception.

Change-Id: I98d1a804c51e1bf3bb96193d82ffe7e5d064e134
Closes-bug: #1253455
Ignore duplicate delete requests

Stop delete requests from queueing up in the compute manager if the
task_state is already set to DELETING. This prevents exhausting thread
pools when the service is stuck on a lock/external request.

Dealing with delete requests that never got executed is not in scope of
this change and will be submitted separately.

Change-Id: I2f97f93bd714e0ea3b6d4fa3ac457ab43eed00e1
Partial-Bug: #1248563
Cleanup 'deleting' instances on restart

In case some instance was marked as deleting but for some reason didn't
finish (for example request was stuck in libvirt), retry the delete at
startup. This happens at startup and on the host owning the instance,
so there's no reason to use the lock.

Change-Id: Iad18e9a7c6cb8e272e67a82284127ad895441dcf
Partial-Bug: #1248563
Closes-Bug: 1247174
Implements: blueprint recover-stuck-state
Make availability_zone optional in create for aggregates

As the novaclient's help message, we can create aggregate without
availability_zone. But the api didn't allow it, so this patch make
it optional.

Closes-bug: 1252177

DocImpact

Change-Id: I64629d71648900bf5be554d9afa4ae47d6b651d0
Improve error message in services API

The awkward grammar of the original error message was making i18n
translations hard.

Change-Id: I2ff98f2d3585d5f1ccf0deb552e73c452393f124
Closes-Bug: #1266620
Rename instance_type to flavor in vmware virt driver tests

Renames 'instance_type' to 'flavor' in the vmware virt driver tests.
There were no occurrences of 'instance_type' in the virt driver itself,
so this patch only changes the tests.

Part of blueprint flavor-instance-type-dedup

Change-Id: I81ea543e0ab480e35cf5b7b59bd9ecb1cf361c6f
Rename instance_type to flavor in libvirt virt driver tests

Renames 'instance_type' to 'flavor' in the libvirt virt driver tests.
There were no occurrences of 'instance_type' in the virt driver itself,
so this patch only changes the tests.

This also removes the unused _create_instance_type method in
test_libvirt.

Note that instance_type_id and instance_type_swap are not changed since
those are part of the database model and would require a database
migration to change them.

Part of blueprint flavor-instance-type-dedup

Change-Id: Iec71509e38aed1341f37194fb94dd34b10ac2f54
VMware: fix rescue with disks are not hot-addable

Some disks, for example IDE, cannot be attached to an instance
when the instance is running.

Change-Id: I3360066ea6406564caa328ec052b9e3ca9d63dc6
Closes-Bug: #1247556
Add API schema for v3 multinic API

By defining the API schema, it is possible to separate the validation
code from the API method. The API method can be more simple.
In addition, a response of API validation error can be consistency for
the whole Nova API.

Partially implements blueprint nova-api-validation-fw

Change-Id: I62a55c498a1164ff56f82495f720cba67da8483b