Implement methods to modify volume metadata.

There are four methods in nova/volume/cinder.py which are
NotImplemented. They are as follows:
  1. get_volume_metadata
  2. delete_volume_metadata
  3. update_volume_metadata
  4. get_volume_metadata_value
These methods are required in cases where nova needs to modify
a cinder volume's metadata, e.g. attach and detach time. It also
completes the cinder.API class.

Change-Id: I360076ae28db43e661466f556425947813c9040e
Closes-Bug: #1296164
Keep Migration status in automatic confirm-resize

function in compute/manager.py _poll_unconfirmed_resizes
will translate the migrate status from finished to error
whenever finds a problem ,Consider the following case

1) _poll_unconfirmed_resizes runs and founds several migrations to be confirmed
2) user deletes the instance, so its task state will be changed to DELETING
3) _poll_unconfirmed_resizes will find the task state is not None,
it will make the migration error status
4) following code in _delete
if instance.vm_state == vm_states.RESIZED:
self._confirm_resize_on_deleting(context, instance)
will fail because migration status already updated

User is able to do the migration operations when they found error
so we don't need to handle this kind of error for them

Change-Id: Ia79dd56c9c1fa8add7dc138d838cbfbac4523ac3
Closes-Bug: #1301696
libvirt: VM diagnostics (v3 API only)

There is no formal definition for the VM diagnostics. For the
V2 API the diagnostics will be returned as they are today.

This will support backward compatibility with the existing API's.

Part of the blueprint v3-diagnostics

DocImpact

Change-Id: I4128e76622e73a40d25fb50b10b1c1ac710a5cc4
VMWare Driver - Ignore datastore in maintenance mode

A datastore can be part of a datastore cluster. Any
datastore which is part of a cluster can be put in maintenance
mode. Instances cannot reside on a datastore if it is in
maintenance mode.
This fix ignores a datastore in the following scenarios
1. Stats update - Ignore a datastore during stats update.
2. Ignore a datastore during instance spawn.

Change-Id: Id0cb3f5fdb4d0bc4884cf5405fadc433d4a2b6ba
Closes-Bug: #1330065
Fix fake_update in test_update_missing_server

In test_update_missing_server, fake_update should be used as update()
method but it is used as create() instead. In addition, the test comment
also is wrong.
This patch fixes them.

Change-Id: Ia4704413dd7355010546dba7096ed34225bb4b0f
Issue multiple SQL statements in separate engine.execute() calls

Some sqlalchemy drivers (eg: mysqlconnector) don't support
engine.execute("sql stmt 1; sql stmt 2;") and require a separate
execute() call for each SQL statement.  After discussions with
sqlalchemy author, he confirmed it would be better to fix callers rather
than attempt to patch in support for multiple statements.

With this patch, nova-manage db sync succeeds using mysqlconnector.

Change-Id: I57e6ecdafe90110eaffe757f0ef0bf7b41b0f3e3
Merge BadRequest tests of "attach interfaces" API

In test_attach_interfaces, there are BadRequest tests of "attach interfaces".
Most parts of them are duplicated.
This patch merges them for the readability and clarifying their purposes.

Change-Id: Ib9dd2840be46dec6b70fe9e3fda35de88f84b4a9
Network: add in a new network type - DVS

The support enables DVS network backends. In this case neutron
will return a vif type of DVS.

The name of the VC port group will be of the following format:
    <network-name>-<network-uuid>

The network name is so that the prefix will be easy for people to
understand. The UUID is to ensure that it will be unique.

Change-Id: Id125797632591bd799e215da7cbae07154e90344
Standardize logging for v3 api extensions

- add log translation hints
- remove unneeded logging imports

Change-Id: I4845ee70c23336b61e5aac70b9b5021e114f8ac5
add log exception hints in some modules

Add hints for log exception messages

Change-Id: I51b30d58bcb4b9fa8e51b29af1cfff33c0b432aa
Optimize instance_floating_address_get_all

Removed one extra round-trip to a database
and iteration through 'fixed_ip_ids' list

Change-Id: I65febddbc48350da93179aee8ff3c4130a6671d4
VMware: handle case when VM snapshot delete fails

Minesweeper fails on occasion with concurrent access to files.

If a snapshot deletion fails with the backend exception
TaskInProgress then we will retry.

A generic decorator has been added to do the retry operations.

Closes-bug: #1310817

Change-Id: I8ed7a24ccd34aeea49352ac98f34ec2960edbf97
More informative nova-scheduler log after NoValidHost is caught.

This patch adds a warning log entry for when a NoValidHost
exception causes a scheduling error. The NoValidHost
exception's message will be logged before reporting that
the machine went to error. Previously, all other exceptions
would show a stack trace. However, since the NoValidHost case
is skipped, a user may not understand why his/her machine
went to an ERROR state. This patch seeks to remove any
confusion.

Change-Id: I0f01b1095251f5c659fe010c7376f3f6bc56babe
Closes-Bug: 1336977
Backport some v3 certificate API unittest to v2 API

This patch add some v3 certificate API unittest into V2 API to improve
V2 API unittesting.

Change-Id: Icf58abbf1e83636047c1f98ff80a38077e2d694b
libvirt: fix _disk_resize to make sure converted image will be restored

During the process of resizing disk if an image is in qcow2 with
partition less the process converts the image to raw.
After the extend we should to restore the original format in all cases
not only if 'use_cow_images' is configured to True.

Change-Id: I792e0fb986a6c5cf9ac477cef0949c8a40099faa
Closes-Bug: #1298976
libvirt: skip disk resize when resize_instance is False

The method finish_migration is called with an extra
parameter 'resize_instance'. It should be used to know
if it is necessary or not to resize the disks and so
call the method 'disk_resize'.

Change-Id: Ia5a9ad7994fa9abab7cf47d36468c46d97065991
Closes-Bug: #1298981
Make API name validation failure deterministic

Makes the testing of a valid name in the API deterministic
with respect to failing when an empty name is supplied
by the user. Formerly it could fail either of two constraints
- must be at least one character long
- does not match the valid regexp which requires one character

The lack of deterministic behaviour was causing issues with
some unittests when PYTHONHASHSEED is not set to 0 because
of the two failure modes. The second constraint for validation
of names is now modified so it allows empty strings but overall the
behaviour remains the same because of the first constraint.

Change-Id: Iea89bb329a8939af5168926717b5c13bdf2a7f62
Partial-Bug: 1350287
Split EC2 ID validator to validator per resource type.

Now there is only one method to validate EC2 id: validate_ec2_id().
It's used to validate both the Instance ID as well as Volume ID for
valid EC2 ID format. However exception class raised in both cases
is "InvalidInstanceIDMalformed" and EC2 error code is
InvalidInstanceID.Malformed.

This patch addresses this problem by adding two new methods:
* validate_instance_id()
* validate_volume_id()
These methods use validate_ec2_id() and raise appropriate
exception as well as appropriate EC2 error code based on
AWS EC2 Error Code documentation:
http://docs.aws.amazon.com/AWSEC2/latest/APIReference/api-error-codes.html

Change-Id: I55591b8b643bb316e5001e645d71c13094106e96
Closes-Bug: #1199308
Fix 202 responses to contain valid content.

Using a webob.exc to generate 202s makes the response return plain
text in the body, which breaks things that expect to be able to
parse data according to the content type. Using a webob.Response
object makes sure the body of the 202 response is empty.

Change-Id: Ifca3081f573407808a2196e71ac1db87180db6ec
Resolves-bug: #1356058
Fix Trusted Filter to work with Mt. Wilson `vtime`

The Trusted Filter expects that `vtime` is returned from the
attestation server in an ISO8601 format, but the Mt. Wilson
attestation server can return it in a locale appropriate string format
instead. There's no way to configure Mt.  Wilson to do the right thing
so we should just try to parse the returned `vtime` as a string
formatted date.

Closes-Bug: #1353029

Change-Id: Ic7351e0463c014321bdb4fcfeba90ac51460b325