hyperv: Initialize target_iqn in attach_volume

The target_iqn is referenced before it is declared in the
case that an exception is encountered in _login_storage_target
or _get_mounted_disk_from_lun.  This causes the exception path
to cause an additional, misleading, traceback to be printed
after an exception is encountered.

This commit initializes target_iqn at the beginning of
attach_volume to avoid the traceback.

Change-Id: I1cdfb9dfa054ee4f4f6918d7bc49081ccaebab9d
Close-Bug: 1233837
VMware: remove deprecated configuration variable

Removes support for vnc_password configuration variable.

Closes-bug: #1235118

Change-Id: I70fd7d3ee06040d6ce49d93a4becd9cbfdd71f78
Plug Vif into Midonet using Neutron port binding

Currently Midokura uses its own script (mm-ctl) to bind ports. However, support
for using this script is left out of the nova and neutron projects. This causes
confusion and makes deployments unnecessarily complicated for customers using
Havana. This fix is to change nova to properly use mm-ctl. Corresponding
changes will be submitted to devstack and neutron.

Change-Id: I7c9edded5ab6fe19b63e54cd6905d9242e4a90cc
Closes-Bug: 1235132
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
Fix root disk not be detached after deleting lxc container

Add teardown_container action when cleanup lxc instance to make
sure root disk be detached and no resource leak.

Fixes: bug #1208387
       bug #1203927

Change-Id: I063fd3a9856bba089bcde5cdefd2576e2eb2b0e9
Fix status code of server's action confirm_resize for v3

The status code of confirm_resize should be 202, but it
returns 204 now. That because it returns HTTPNoContent
that overwrites the status code of decorator 'wsgi.response(202)'

And adds API samples for confirm_resize that used to test
the status code of confirm_resize.

Partially implements blueprint v3-api-unittests
Closes-bug: #1233561

Change-Id: I50a3046866af0a1efdb5c41ded40f973b02843e8
catch exception in start and stop server api

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

Closes-Bug: #1233026

Change-Id: Ibb882178ab0770837702d503ef88c6510072e33f
baremetal: Use network API to get fixed IPs

Previously baremetal volume driver used DB API to get fixed ips and
DBNotAllowed was raised.

Change-Id: Ie2281311af1b60f55b5b719a2e2df6316bbaa9f6
Partial-Bug: #1208707
Use print function rather than print statement

This is for Python 3 compatibility, since Python 3 does not support
the print statement, only the print function.  (Python 2.6 and 2.7
support both, depending on whether a __future__ import is used.)

Paths containing "xen" were left alone, because of comments in a
couple of the files indicating that the XenServer code needed to be
compatible with Python 2.4.

Fixes bug 1226943

Change-Id: I23b804a4d99500b4acf81dd19645ab06dfcc9f1c
Fix typos in nova/api code

blueprint fix-nova-typos

Change-Id: Idd9c5458c5fc0facd9f3c55f907acb7acc4c1b0f
Fix incorrect root partition size and compatible volume name

When using rbd backend, it needs to resize volume size if size presents. Else
we will get wrong image size.

Rbd volume always uses uuid as the main pattern of volume name, now change to
it is necessary.

Fix bug 1219658

Change-Id: I3dc8d639b066eac35d190b8d4687c41c9f4d5824
Fixes Hyper-V issue with VHD file format

The VHD format cookie signature needs to be checked in the footer
instead of the header as fixed format VHDs don't have a copy of the
footer at the beginning of the file.

Fixes bug: #1233853

Change-Id: Ibe44f0d895cde2edbc03dcd6ecebac24b0936660
Remove compute_api_class config option

This option was deprecated in Havana and can now be removed.  Its only
use was for changing out the API class if cells was in use.
Technically, it used to be possible to configure an arbitrary compute
API class.  However, that would have been an unsupported setup, and has
been completely broken since 9f902c7e17249cf5af1504f31d80c0247a02fe20
anyway.

As a part of this change, the cell_type configuration option needed a
default value.  I set it to 'compute'.  My reasoning was that you would
have more compute cells than API cells, so might as well set it to the
more common case.

Change-Id: I5ec44f84267a700da16b350e686eee886e0d1183
Add a get_root_bdm utility function

Getting the root block device out of a list of block devices is a common
idiom and we use it in several places in our code base. This patch
factors it out in a handy utilty method and adds tests for it.

Change-Id: I4a2cb3c689fed9fbc0bc51ddba095e1269cacb2d
blueprint: clean-up-legacy-block-device-mapping
Move is_volume_backed_instance to new style BDM

Compute API is_volume_backed_instance used to rely on matching the
device name to the root_device_name field of the instance which had
several problems and edge cases.

Now that we have moved to the new BDM format that has the boot_index
and destination_type field for each block device - it is pretty
staightforward to implement.

Change-Id: Ia2c235f8bce577ed4ac6a480a4a051d159a5fad7
blueprint: clean-up-legacy-block-device-mapping
fix missing host when unshelving

An instance has the hostname of the host on which it is running.
The hostname is deleted when shelving. However, the hostname is not
recreated when unshelving.

This patch sets the hostname when unshelving.

Change-Id: I2e431718198321c46b9335e6fb7ab7be3943fab6
Closes-Bug: #1237868
cleanup after boto 2.14 fix

we had a fix that worked fine in the gate, but this was a good
suggestion of a cleaner version. Fixing now while everyone is still
fresh on this.

Change-Id: Id88f3532fe8096c4f7322c683faeaf20bfb431bc
Replace incorrect Null checking to return correctly

Null checking for metadata in check_img_metadata_properties_
quota function doesn't work as designed, fix incorrect Null
checking code.

Change-Id: Id3f971091d857d6b2aebc4985cb932417c21b5dc
Fixes: bug #1220120
Move exception definitions out of db api

The two exceptions, NoMoreNetworks and NoMoreTargets, are defined
in nova/db/api. While NoMoreTargets is unused and can be removed,
NoMoreNetworks are still used and should be moved to exception.py
where all other exceptions live.

This came up during review of https://review.openstack.org/#/c/42980/
where compute manager would need to import nova.db to make use of
NoMoreNetworks.

Change-Id: I57f0a081d2fea35394421932ae7d2a3e67540a31
Utilizes assertIn - tests/api/v3

Using assertTrue and the 'in' operator to test
if an element is in a sequence is too python2.4.
Our unit testing framework supports assertIn,
which was created for these types of tests.
Using assertIn will enhance readability of the test scripts.

Change-Id: Ic3ae0a0eca219bd7d114580ad3642e7df04ad1f4