Make hypervisor_version an int in fakeVirt driver

This is a follow up to 9e770e62135fe9c2c8ac0121a5a79245b25a7847, which
missed the change in a duplicate copy of host_status.

Add regression test to test_virt_drivers.

This requires changes to the API samples, because they were wrong. virt
drivers use convert_version_to_int which converts a version string to a
4 digit number ("1.0" becomes to 1000)

Change-Id: I28ce23509e3c9feae183a49a8fc5bf3c7c601295
Closes-Bug: #1285035
VM in rescue state must have a restricted set of actions

Right now it is possible to pause, suspend and stop a VM in state RESCUED,
so after the state is changed, it's not possible to trigger unrescue anymore
since the original state is lost.

This patch remove vm_states.RESCUED as valid state from stop,
pause and suspend actions.

The vm_states devref is also updated to reflect this change including the
current reboot flow.( vm_states.RESCUED cannot be rebooted as per
today code)

DocImpact
Closes-Bug: #1319182
Co-Authored-By: Cyril Roelandt <cyril.roelandt@enovance.com>
Change-Id: I531dea5a5499bf93c24bea37850d562134dee281
Use VIF details dictionary to get physical_network

Modify mlnx_direct plug and unplug to retrieve physical_network
from VIF details dictionary if network meta dictionary does not contain
physical_network. This will serve ML2 case following the guidelines to
populate vif_details dictionary with attributes required for port plugging.

Change-Id: I0d97bc875be2fff18087c78accef3ec81c059c4b
Closes-Bug: 1304872
Fixes hyper-v volume attach when host is AD member

The domain name gets added to the initiator name used by the host
if it's an Active Directory member.

Currently the method which gets the initiator name does not take
this into account when retrieving the default initiator name.

Trying to use a wrong initiator name will lead to an exception when
trying to log in to the according iSCSI target.

This patch simply appends the domain name (when the host is an AD
member) to the initiator name used to log in to iSCSI targets.

Closes-Bug: #1328870

Change-Id: Ifbe762c685e46081059a01043431b2c4ac5473fc
VMware: remove unused parameter 'network_info'

The parameter 'network_info' is not used for destroying an instance and
doesn't need to be passed through the whole stack.

Change-Id: I0a8b912ff7693478917e849e17093d1541adeeeb
Libvirt: Added suffix to configdrive_path required for rescue

It was observed that during nova rescue, nova failed to create
a rescue disk for disk.config. The reason being that .rescue
suffix was missing from the configdrive path. It was working
till Havana but the functionality broke in Icehouse. This commit
fixes the suffix problem.

Unittests have been added to verify following scenarios:
    1. Make sure that .rescue disks are created when not using
        config drive
    2. Make sure that .rescue disks are created when using
        config drive

Closes-Bug: #1334024

Change-Id: I87449ffddd047cb84b7b881757ea4c29927b95da
check ephemeral disk format at libvirt before use

Add ephemeral disk format at libvirt. There is no check before
so it will be used directly. This patch adds valid check function
and validate it before eph disk was used in virt layer.

Change-Id: I1934573e79f126e725cef4848b15c11a595161c9
Closes-Bug: #1293880
Fix virt BDM __setattr__ and __getattr__

Previously we would only allow these to work on fields that are found in
the _proxy_as_attr collection of the object and we would unconditionally
raise an AttributeError otherwise.

This behaviour is too restrictive as it prevents us from using mock on
these objects properly, Instead we now delegate back to the parent
class for a more natural behaviour.

Change-Id: I5c221eef8f05c66ac2e2fb4abf645748407462c0
Move retry of prep_resize to conductor instead of scheduler

Prep_resize in Compute Manager calls back Scheduler prep_resize if
an Exception is raised. There is no sense of calling back the
scheduler, it should call Conductor instead.

Implements blueprint move-prep-resize-to-conductor

Change-Id: I2131843c291f5bd01eb4dbd6c8f36a9218120c19
XenAPI: VM diagnostics for v3 API

For V3 API the diagnostics will have the format defined at:
https://wiki.openstack.org/wiki/Nova_VM_Diagnostics

This will support backward compatability with the existing APIs

Part of the blueprint v3-diagnostics

DocImpact

Change-Id: I8377f86a97ca554028e4ca8c1c1af7fd5643cc2e
libvirt: Support IPv6 with LXC

Libvirt's LXC implementation exposes a read-only  `/proc/sys/net` to the
guests. This causes some of the guest's default network configuration scripts
to fail.

This patch works-around the issue by using `post-up` hooks to configure IPv6.

Closes-Bug: 1340791

Change-Id: I805cad98d855fcb2c90b07e98ad3653d1620bd42
Update requirements to include decorator>=3.4.0

This third party package is used but there was no specific
requirement for it.

Change-Id: I50fcc7a1c4029b36e02e75eaf27df7ca791aef4e
Xen: Cleanup orphan volume connections on boot failure

If the boot process fails after the VDI creation but before a VBD is
created then the current cleanup methods will not work as they all rely
on lookups via VBD.

Change-Id: Id0d93ee60f75bf319baf7859b220ca325175128a
Closes-bug: #1329941
Enable live migration unit test use instance object

test_post_live_migration_no_shared_storage_working_correctly is
still using instance dict, we should change it to using instance
object.

Related to blueprint compute-manager-objects-juno

Change-Id: I7709b32ebeef88eb9759d0275c3076091b6be669
libvirt: remove unused list_instance_ids method

All code has been converted to use list_instance_domains so the
list_instance_ids method can finally be removed.

Blueprint: libvirt-domain-listing-speedup
Change-Id: I9ce33cda5608796e0eec4ec0804ee179a4704d9d
Fix Cells ImagePropertiesFilter can raise exceptions

In a misconfigured scenario the ImagePropertiesFilter can raise an
exception which causes the image to be unbuildable in the region. This
happens when the capabilities is set for prominent_hypervisor_version
to an empty list.

Change-Id: I17bd9d87fa69ad34b19591018543a34dfd050978
Closes-Bug: 1343462
Cleanup: remove unused argument

The vm_util.get_values_from_object_properties(...) method in the VMware
driver takes an unused param 'properties'.

This patch cleans up the method signature.

Change-Id: Iba738c2b49f829c1c0e17973b5265e88741fade7
Remove stubs in favor of mock in test_policy

This patch converts tests_policy to use mock instead of stubs. I was
stealing some tests from nova to another openstack project and made this
change there so I figured nova would benefit from it too.

Change-Id: I6d086795c559ac8f04028d820e8e88bfd5305426
Cleanup and gate on hacking E711 and E712 rule

Fix the offending instances of the rule
and removes it from the ignore list in tox.ini
so that we can gate on E711 and E712 rules.

Most violations were in DB queries. Replace as follows:
  False -> sqlalchemy.sql.false()
  None  -> sqlalchemy.sql.null()
  True  -> sqlalchemy.sql.true()

Change-Id: Id84aa04697d1b3c23dc03195113e296c6715379d
Removes useless stub of glanceclient create

There was a stub out of glanceclient.create that was being called from a
couple unit test setUp()'s, but the stub method stubs out something that
is overridden by the stub_out_glance() fake method.

Change-Id: I300f6ccc999958c33a2dd729cb8bde89bed63967