Fix NovaObject versioning attribute usage

A typo made early in the object prototyping process has meant that
all objects thus far have been exposing a version of '1.0' because
the base object has been using an attribute of 'version'. The
object implementations have been exposing a 'VERSION' attribute
with their desired version advertisement.

Since we are still relatively early in the process of deploying
objects, the impact from this should be relatively minor, although
it is important to get this fixed ASAP before any incompatible
object changes are made.

(cherry picked from commit 99cbfb3492c80ded53fa018fe5a0881f977dc407)

Change-Id: If9154dc663111f304f72ef7f6f37c465e84ff504
Closes-bug: #1239709
Open stable/havana

Change-Id: I1f59561b357c03866672c2d9576568a67630a033
Fixes datastore selection bug

Currently the vmwareapi drivers will only select the first
available datastore it finds, even when there are other
datastores with capacity, it will fill one datastore completely
and then die.

Closes-bug: 1227825

Change-Id: I24f85114ea3f014950c27c0c91a6be352990d263
(cherry picked from commit 6c4b89a2ad51f92707acc01908b63bc507ad8fe7)
VMware: fix regression attaching iscsi cinder volumes

VMware drivers fail to attach a iSCSI backed cinder volume with an
error 'unable to find iscsi targets' because the underlying
retrieval api was updated to a newer version but not it's usage in
volume_util (see commit e331287cdd1300878bfb9bbb3630889370e5fa72).
This is a regression over Grizzly release.

Fixes: bug #1193980

(cherry picked from commit e70211ff89785fed6a868eaab723847833590502)

Change-Id: I14fe62ad98fd9161df3ce6c06160b2759a9e38b2
Fixes inconsistency in flavors list with marker

Flavors list with marker is supposed to use flavorid as the marker since this is
the only id attribute the users can see, but it was using id (the confusion was
probably caused by the fact that flavorid attribute shows up to the user as id).

The change on db unit test shows makes the bug evident, and justify the changes
on the filter_by criteria.

Fixes bug 1226698

Change-Id: I3ffa636febb63be796fffc94be6486bf74e8239b
(cherry picked from commit c2c0958ad768581cd0e92f88207430227cb6539a)
Fixes unicode issue in the Hyper-V driver

The XML string returned by the WMI API calls requires unicode
conversion before further processing, e.g. with ElementTree.

This affects the vhdutilsv2._get_vhd_info_xml method due to
the textual description. The issue came to light using the
host with Chinese locale, while not present on a en_US host.

Fixes bug: #1229671

Change-Id: I09435a205abfc8ae9470c53c5446cbb28dee0115
(cherry picked from commit c8c7c01d68b34b76ebe6c4b39f93915480c1ccea)
catch exception in start and stop server api

this catches exception.InstanceIsLocked in start and stop
server api.

Closes-Bug: #1233026

Change-Id: Ibb882178ab0770837702d503ef88c6510072e33f
(cherry picked from commit aa8938d696e6e2ecf23709f748de825dc2d07fd0)
Fix getting nwinfo for Instance obj

This fixes the get_nw_info_for_instance() method in nova/compute/utils.

If an instance object has no 'info_cache' (means we lack an entry in the
instance_info_caches table for the instance), don't try to access the
'network_info' attribute.  Just return a network model with empty
networking information like the dict version of an instance would do.

Change-Id: Ib1f49f10cefeefc55a87fea69b6fbc772c978dca
Closes-bug: 1243291
(cherry picked from commit a907c2f06b65dca7c2c0ea6119fe649864c6de11)
VMware: fix bug with booting from volumes

When booting from a volume without an image reference would cause
an exception.

Change-Id: Ib0302197b8d4f5e054a8c4426cb0dde7cb82842e
Closes-bug: #1235022
(cherry picked from commit 026843773b71ab0ac30abb36fe9eed92f5e11f7a)
ensure we don't boot oversized images

Since we can't generally shrink incoming images, add extra checks
to ensure oversized images are not allowed through.
All cases when populating the libvirt image cache are now handled,
including the initial download from glance, where we avoid
converting to raw, as that could generate non sparse images
much larger than the downloaded image.

* nova/virt/libvirt/utils.py (fetch_image): Allow passing through
of the max_size parameter.
* nova/virt/images.py (fetch_to_raw): Accept the max_size parameter,
and use it to discard images with larger (virtual) sizes.
* nova/virt/libvirt/imagebackend.py (verify_base_size): A new
refactored function to identify and raise exception to oversized images.
(Raw.create_image): Pass the max_size to the fetch function.
Also enforce virtual image size checking for already fetched images,
as this class (despite the name) can be handling qcow files.
(Qcow2.create_image): Pass the max_size to the fetch function,
or verify the virtual size for the instance as done previously.
(Lvm.create_image): Pass the max_size to the fetch function.
Also check the size before transferring to the volume to improve
efficiency by not even attempting the transfer of oversized images.
(Rbd.create_image): Likewise.
* nova/tests/virt/libvirt/fake_libvirt_utils.py: Support max_size arg.
* nova/tests/virt/libvirt/test_libvirt.py (test_fetch_raw_image):
Add a case to check oversized images are discarded.
* nova/tests/virt/libvirt/test_imagebackend.py
(test_create_image_too_small): Adjust to avoid the fetch size check.

Fixes bug: 1177830
Fixes bug: 1206081
Change-Id: I3d47adaa2ad07434853f447feb27d7aae0e2e717
Pull system_metadata for notifications on instance.save()

When saving changes on an instance object a notification is sent out.
An attempt is made to pull flavor information from the instance but if
system_metadata is not joined then an exception is raised and the
notification fails.  This ensures that system_metadata is available for
those notifications.

Conflicts:

	nova/objects/base.py

The conflict is from change Icd2944f17b6100d51007dbc48da90e4e992bbd48

Change-Id: Ifd317f847c3839cd6019038bb3dc856b9f107000
Closes-bug: 1244311
(cherry picked from commit e03963b1e42ca2900b108201e77edf2386c5c46a)
Fix all scripts to honor the enabled_ssl_apis flag

Add logic to allow configuration of SSL for all the cmd scripts
that start a WSGIService

Change-Id: I921013d113081a91a3fe9bb574bae5cd7bb06bcc
Closes-Bug: 1237126
(cherry picked from commit 08c6664d8f36ef48f28bed9afbd4aae21f6eb2d5)
Remove unnecessary "LOG.error()" statement

Removes apparent debug statement left in from
Ifd41886b9bc7dff01cdf741a833946bed1bdddc

Closes-Bug: #1239603
Change-Id: I9c5b9a6b2349a6c62bef2974ab3b0bb986533741
(cherry picked from commit 7ef98b44374945cd157b125a9b46ee5727d285fe)
Make unshelve use new style BDM

Unshelving an instance requires recreating it, and since change
I5b9c3e2d959c602fa22f49db681da918ae0adcea, it is necessary to call
compute manager's _prep_block_device with new style BDMs.

This patch makes the conductor return new-style BDMs when unshelving the
instance.

Closes-bug: 1246412
blueprint: clean-up-legacy-block-device-mapping

Change-Id: I0ba9f53c31c4d5238319cfd09600ad64f298629e
(cherry picked from commit 7fb9fcc970324236267d893185b421e26b1cb1d9)
Sanitize passwords when logging payload in wsgi

adminPass (or admin_pass) can be either part of a json object or
an xml element or xml attribute. The patch includes
regexps to support all these cases and adds tests
as well

Change-Id: Ic119f986a03863c1d13b566b4c005f3bc77d83d0
Closes-Bug: 1231263
(cherry picked from commit c6d82083295e9b1b42f22d3a2d25a1ab7d341a13)
Add notification on deleting instance without host

If an instance which does not have a host associated is deleted, the
corresponding notifications were not being sent. Fixed the issue.

Closes-Bug: #1211742

Change-Id: I56482ab38725e6f1ddfb14350637d329f35095b3
(cherry picked from commit bbab55c4da531e4695a6e3e577aaa4975f0fce79)
VMware: fix bug for reporting instance UUID's

Ensure that the correct UUID's are reported to the compute
manager. The fix will return only valid UUID's and not all
of the names of the instances running.

Closes-Bug: #1237795

Change-Id: I32bb6f4783dcc80697abebd5a7f45ef9950a0896
(cherry picked from commit 74289aacb5363bd72b449580325a651117e5342d)
Fix setting backdoor port in service start

Previously if self.manager wasn't defined for a Service object but a
backdoor_port was specified then that particular service would not
start because it would try to set the backdoor port in an object that
didn't exist. This commit fixes setting the backdoor port only if
manager is defined when calling start().

Closes-Bug: #1243260

Change-Id: Ib0e709cfd0e299a3e010450b7eba6e92bc108e4e
(cherry picked from commit e5c96505c0b4eac51c0925dcb691f0a1699216ce)
Fail quickly if file injection for boot volume

Previously if the user attempted file injection on a booted volume it
would fail and retry several times, which slowed down the instance
spawning.  Instead of attempting file injection, fail quickly, and
log a warning

Fix bug 1188543

Change-Id: I264540de736c2bcb92567826fe5ba672e1244ba2
(cherry picked from commit f59c2d64ac8f0523c587e23b2d1c59fdfe7ea131)
Fixes Hyper-V snapshot spawning issue

In Hyper-V, snapshoting an instance and then spawning a new
one using the resulted snapshot image with the same flavor,
will result an Hyper-V Exception.

Hyper-V will get the request to resize the base image to it's
actual size, leading to an error.

The reason is that the logic of the resize_vhd method has been
changed, as it is meant to resize images to the flavor size minus
the image metadata size, thus it's maximum internal size. For this
reason, the way to decide whether the root image should be resized
or not must also be changed.

So, instead of comparing the root image and base image sizes,
we should compare their maximum internal sizes.

Closes-Bug: #1234759

Change-Id: I83d2df76b726d705cedc52a8309a2be7037d6a79
(cherry picked from commit efdca8eeaffe6e63d57243147658f4691da3d89e)