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
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
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
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
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
Add unit tests for libvirt domain creation

Tests for:
nova.virt.libvirt.driver.LibvirtDriver.get_guest_config
nova.virt.libvirt.driver.LibvirtDriver._create_domain

Partially implements: bp libvirt-lxc-user-namespaces

Change-Id: I4aada9ac06cd423b04a4c6136165c65e64e378aa
Use flavor in confirm-resize to drop claim

Current the confirm_resize() clean the stashed instance_type information
before invoking the drop_resize_claim, and the drop_resize_claim() try to
fetch the old instance_type in system metadata, which will be wrong.

We change the _cleanup_stored_instance_types() to pass back the
to_be_dropped instance_type, and use that information for drop_resize_claim.

Change-Id: Iba36acc75d3840104746596977b33bcd4e010f2e
Raise Not Implemented error from V2 diagnostics API

In case any driver does not implement functionality of providing VM
diagnostics, HTTPNotImplemented error will be raised from driver.
Nova V2 API should catch the same and pass it with proper error message
for better debugging.

This patch catch & raise  HTTPNotImplemented exception for
V2 "os-server-diagnostics" API.

Adding UT also for the same.

Change-Id: I485d3487d01eba07e3c34f6ef9b5c707af54ebb7
VMware: Create VMwareImage object for image metadata

This change pulls the nested function _get_image_properties() out of
spawn() and makes it a factory method for the new VMwareImage object.

Linked clone logic is moved from a separate function in vmops.py to
the new get_image_properties() function.

vmware_images.get_vmdk_size_and_properties() is no longer used, and is
removed.

Tests have been updated and/or moved as appropriate. No tests have
been removed.

This change has been split out of
https://review.openstack.org/#/c/87002/, which was written by Shawn
Hartsock.

partial blueprint vmware-spawn-refactor

Co-authored-by: Shawn Hartsock <hartsocks@vmware.com>
Change-Id: I580f173da798318d2675c7c70bbdd19b266259f4
VMware: Remove references to ebs_root from spawn()

spawn() contained an important boolean called ebs_root. This was True
for any spawn which contained a block device mapping. This no longer
has any meaning, and was confusing. This change removes references to
ebs_root, instead using block_device_info directly.

N.B. The block device mapping behaviour of the VMware driver is still
not correct, but fixing it is not the purpose of this patch. This
patch simply makes the existing behaviour easier to see.

N.B. test_spawn_mask_block_device_info_password in test_vmops.py
assumes internal details of spawn in order to cause a failure after
emitting a log message. In moving the log message we need to update
the dance this test does to ensure that spawn fails after the log
message, but not before.

This change has been split out of
https://review.openstack.org/#/c/87002/, which was written by Shawn
Hartsock.

partial blueprint vmware-spawn-refactor

Co-authored-by: Shawn Hartsock <hartsocks@acm.org>
Change-Id: I11b355a6b53194bc9f85f542b54c9fbb9c061e04
VMware: remove Host class

The class was only used by the ESX driver which was remove in the
commit 1deb31f85a8f5d1e261b2cf1eddc537a5da7f60b.

Change-Id: I026e4c0f463e78e33592c6408d2e688c74a0714b
VMware: remove specific VC support from class VMwareVolumeOps

This support is no longer needed as we only support the VC driver
since commit 1deb31f85a8f5d1e261b2cf1eddc537a5da7f60b.

Change-Id: Iad71fceb580620b1843ce3cf5d926343d8113945
Move _is_mapping to more central location

The logic to identify volumes is currently a nested function
in _default_block_device_names, named _is_mapping. It should
be moved to a more general location so others could utilize it
and allow it to be properly unit tested. The following patch
moves _is_mapping to nova/virt/block_device.py and renames it
to is_block_device_mapping.

Change-Id: I560abc4b57ca5bd195282af7cd1ab9bbf7600b67
Closes-Bug: #1351810
Image caching tests: use list comprehension

Use a list comprehension for creating a list of instance objects
for the tests.

Change-Id: If25d024eeeb1503d7a7dc2dbc895b2bf3152c7db
Change 'admin_password' into v2 style for servers extension

This patch changes 'admin_password' to 'adminPass' that same
with v2 api. And also change the related unittest.

The differences between v2 and v3 are described on the wiki page
https://wiki.openstack.org/wiki/NovaAPIv2tov3.

Partially implements blueprint v2-on-v3-api

Change-Id: Ie5675f98bb15c55a191a207171e2ffe3be8e6deb
Change 'image_ref'/'flavor_ref' into v2 style for servers

This patch changes 'image_ref'/'flavor_ref' to 'imageRef'/'flavorRef'
that same with v2 api. And also change the related unittest.
The differences between v2 and v3 are described on the wiki page

https://wiki.openstack.org/wiki/NovaAPIv2tov3.

Partially implements blueprint v2-on-v3-api

Change-Id: Ic17334e0a9de89488d5e0c8b75950027d51a3cd4
Libvirt: Do not raise ENOENT exception

If the disk disappears during update_status(), only need to print
a warning, and do not need to raise an exception.

Change-Id: I87800c855c7b349f69163e33031404ad25e2a9ca
Closes-Bug: 1358609