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
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
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
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
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
Utilizes assertIn - tests/api/contrib

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.
Adapting assertIn will enhance the readability of the test scripts.

Change-Id: Id2237b7a35c5c759e571b138faa8d1bef46a7e27
Utilizes assertIn - tests/virt

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: Ifa0f7e12a1ba84052e1e64ed2775056fafd2b13b
Utilizes assertIn - tests/api/etc

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.
Adapting assertIn will enhance the readability of the test scripts.

Change-Id: I9995c6668710e94902d97da21303274965df17e9
Improve logging messages in libvirt driver

This is a trivial change to correct an uninformative log message.
There are two checks in get_instance_disk_info that look at a disk.
One checks for the type of a disk and logs its path if it is not a file.
The other checks for the path and logs the instance name it belongs to
if it does not exist. The first will log None if the path does not exist,
so reverse the order of the checks.

Closes-Bug: #1239747
Change-Id: Ieb52ba0584ad789dc55f40e0172cf5ed41e86fbe
Use `versionutils.is_compatible` for Dom0 plugin

Related-Oslo-Commit: d7d74a752e34d5249fa47c8e8252da491d46012a
Change-Id: Iffb19f186fe2b239361fc342de0042acfa5e098d
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
Add extension access_ips for v3 API

The functionality of access ips overlaps heavily with floating ips,
and the most deployments don't use access ips now. So we decided to
demote access_ips to extensions, the more detail discussion at:
https://etherpad.openstack.org/NovaV3APICore

New extension add prefix 'os-access-ips' for properties 'access_ip_v4' and
'access_ip_v6' to follow v3 API rules. And add unittest for new extension.

For making this patch small, this patch just add the code of extension
and related unittest, without enable the new extension and remove the
old access_ips attributes. That will be done by next patch.

If you want to test this new extension, you can enable it by adding
'access_ips = nova.api.openstack.compute.plugins.v3.access_ips:AccessIPs'
to entry point 'nova.api.v3.extensions' and
'nova.api.v3.extensions.server.create*/rebuild*/update' in setup.cfg.

DocImpact

Partially implements bp nova-v3-api

Change-Id: Ib56e4ff9145798792f062fc107390565673ac9a1
Fix docstring related to create_backup API

This patch adds "returns" of backup() and removes unnecessary
"backup_type" from _create_image().

Change-Id: If00c6437ee8415ba1e21ae2cceba0817606f27b0
Update timeutils.py from oslo

This fix is related to oslo-incubator commits:
3bc6f79d794aee9d51abc0be10e846b971fae847
af76064855c5bb888e1a0d2800d1f49470e19091
df3f2bafbe76d78d017d40e7dc08909fee7dbe34

Change-Id: I1194df94d85d3dde29e81003c0c3db735c66b35f
Adding Read-Only volume attaching support to Nova

Supporting attach a volume with Read-Only mode in libvirt driver.

Implements bp: read-only-volumes

Related-Id: I4c84614d6541d5f7c358abadb957da7b8c3d9c48
Change-Id: Id5ef7b25350cb1bde9d30fbfa98fb7a80081827f
Signed-off-by: Zhi Yan Liu <lzy.dev@gmail.com>
Manage None value for the 'os_type' property

The I2bab617f6c1e8866650ca7dc5178b640738c9ae6 introduced a way to pass the
'os_type' property to glance when we are doing a snapshot in the libvirt
driver. Currently the code doesn't manage properly the None value for this
property and so None value is passed to glance which creates an image with
a property called 'os_type' with value 'None'.
As results of that all instances booted from a snapshot with this property will
have None value in the os_type field.
That field is used to create file name for backing images for ephemeral disks.
Now consider this scenario:
we boot an instance from an image without the os_type property defined and
with an ephemeral disk of 50 G
the resulting backing file will be called ephemeral_50_default.
At this point we take a snapshot from that instance and we boot a new instance
using this snapshot, and because of this bug we will have a new backing file
called ephemeral_50_None.
That is bad because is leaking resources in the host.

Please note that I did a small refactor of the code to make my change testable.

Change-Id: I40bca2732ee2c911344e9d361612007da1c7c3cf
Closes-bug: #1240542
Improve object instantiation syntax in some tests

This makes the base and instance tests use the improved
instantiation syntax.

Change-Id: I60aa64603a4ed225cc978f4b5b86ade759242276
Update version aliases for rpc version control

Now that Havana has been branched, add aliases for the rpc version
implemented by Havana.  These aliases can be used in the configuration
options for doing outbound rpc version control.

This is one of the items that should be done after every release, and
has been added to the new release checklist wiki page:

    https://wiki.openstack.org/wiki/Nova/ReleaseChecklist

DocImpact - 'havana' is now a valid value to provide to all of the
options in the [upgrade_levels] section of nova.conf.

Change-Id: Ifa0b3dcc00843ad3f045a450ceb0f47f0b843f98
Merge "fix missing host when unshelving"
graceful-shutdown: add graceful shutdown into compute

The following commit brings in oslo-incubator service.py which
includes calls to support graceful shutdown.  The common service
class has changed to handle signals and manage Services.  When
a signal is received the Services are stopped which in turn
waits on all child threads (Proxy callbacks) to complete.

The oslo-incubator commit hash that was used to update
nova was b5fba9e40d609d63b4dab9ca351f7e22e9d8b35b.

This allows long running commands to complete prior to killing
the process.  This change only works for SIGTERM and SIGINT
signals.

Unit test was added to verify parent stop method is called in
a shutdown condition.

Change-Id: I21a45862f491530523037632fd70c60cc0153c0a
Implements: blueprint graceful-shutdown