HyperV Driver - Fix to implement hypervisor-uptime

The hyperv driver currently does not return the hypervisor-uptime.
This fix does the necessary changes to return the hypervisor-uptime.
The uptime returned is in similar format to libvirt driver uptime

The uptime is calculated using the windows function GetTickCount64
More details about this function available at
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724411%28v=vs.85%29.aspx

The function GetTickCount64 returns in millisecs the time since the host
is up.

Change-Id: Ib3cd90b17f64e369badaddb764ac9e6b9f6c1a4b
Closes-Bug: #1335559
(cherry picked from commit a41543820a8f0686612213b12ab07cf70b3d997f)

Conflicts:
	nova/tests/virt/hyperv/test_hypervapi.py
Fixes Hyper-V volume mapping issue on reboot

Hyper-V does not manage iSCSI mounted passthrough disks
correctly on reboot in some circumstances where disk
number assignment can change, resulting in instances potentially
booting with the wrong volume attached.

Co-Authored-By: Adelina Tuvenie <atuvenie@cloudbasesolutions.com>
Co-Authored-By: Adrian Bora <abora@cloudbasesolutions.com>

Closes-Bug: #1322926
(cherry picked from commit 50636a881b60f112027494bcd84af66888db8c1c)

Conflicts:
	nova/tests/virt/hyperv/test_vmutils.py
	nova/tests/virt/hyperv/test_vmutilsv2.py
	nova/virt/hyperv/vmutils.py
	nova/virt/hyperv/vmutilsv2.py

Change-Id: I99fa75aaa950de2ada8a03bd23c910c3ff810d69

Conflicts:
	nova/tests/virt/hyperv/test_hypervapi.py
Add differencing vhdx resize support in Hyper-V Driver

Differencing VHDX images can be resized, unlike differencing VHD images.
Even so, the Nova Hyper-V driver currently does not support this.

This feature is required for resizing existing instances which use CoW
VHDX images and also in order to resize the root disk image when
spawning a new instance.

The methods which get the internal maximum size of a vhd/vhdx
image have been updated to lookup the parent disk and get the according
size instead of raising an exception in case of differencing images.

Change-Id: I867a9b35e5273b96afc443e5c436a15d0c45161b
Implements: blueprint add-differencing-vhdx-resize-support

Conflicts:
	nova/virt/hyperv/vmops.py
Fixes Hyper-V volume discovery exception message

On some editions of Windows / Hyper-V server the SAN policy is set
by default to "Online All", bringing online any disk, local or shared,
attached to the host.

Since only offline disks can be attached as passthrough disks to a Hyper-V
VM, this prevents Cinder volumes from being attached to instances,
resulting in an exception that can be particularly hard to troubleshoot
without a clear knowledge of the context.

This patch includes some details in the exception message for
troubleshooting purposes.

Change-Id: I6d0b49812f8ca965ca53be34ef009997c8e79728
Closes-Bug: #1361419
Fixes Hyper-V boot from volume live migration

Live migration fails on Hyper-V when boot from volume is used with
CoW, as the target host tries to cache the root disk image in
pre_live_migration, but in this case the image_ref is empty.

This patch adds a check to handle the empty image_ref case.

Change-Id: I60cb60ccaeb0cb8c536906d897249e31ae396923
Closes-Bug: #1362075
Fixes Hyper-V driver WMI issue on 2008 R2

Trying to assign properties on default Hyper-V resource setting data
WMI objects results in an exceptions before Hyper-V 2012.
Cloning the objects before assigning them solves the issue.

A similar approach was previous already implemented and has been
incorrectly removed during a refactoring.

Co-Authored-By: Robert Tingirica <rtingirica@cloudbasesolutions.com>
Change-Id: If119154f8b4756be9f98c8acd376003c52eff44f
Closes-Bug: #1356884

Conflicts:
	nova/tests/virt/hyperv/test_migrationops.py
	nova/tests/virt/hyperv/test_vmops.py
	nova/tests/virt/hyperv/test_vmutils.py
	nova/tests/virt/hyperv/test_vmutilsv2.py

Conflicts:
	nova/tests/virt/hyperv/test_vmutils.py
	nova/tests/virt/hyperv/test_vmutilsv2.py
Adds Hyper-V Compute Driver soft reboot implementation

Adds a soft reboot implementation for feature parity with other
Nova drivers as specified in the base virt driver's interface.

Co-Authored-By: Simona Iuliana Toader <itoader@cloudbasesolutions.com>

Change-Id: I963cbdacdfefca47d6e45fa0aafac188963bcaed
Implements: blueprint hyper-v-soft-reboot

Conflicts:
	nova/tests/virt/hyperv/test_vmops.py
	nova/virt/hyperv/vmops.py
	nova/virt/hyperv/vmutils.py

Conflicts:
	nova/tests/virt/hyperv/test_vmops.py
	nova/tests/virt/hyperv/test_vmutils.py
Adds Hyper-V serial console log

Introduces the VM serial output log feature to the Hyper-V Nova
 Compute driver.

The VM serial port COM0 is redirected to a named pipe so that a
worker can take the VM output and write it to a file.

The VM serial output is then read from this file whenever the
console log command is issued.

Implements: blueprint hyper-v-console-log

Co-Authored-By: Adelina Tuvenie <atuvenie@cloudbasesolutions.com>

Change-Id: I7d3132c0f934ac3e8d28315f4da766466612a6c0

Conflicts:
	nova/tests/virt/hyperv/test_hypervapi.py
	nova/tests/virt/hyperv/test_vmops.py
	nova/tests/virt/hyperv/test_vmutils.py
	nova/virt/hyperv/vmops.py

Conflicts:
	nova/tests/virt/hyperv/test_vmops.py
	nova/virt/hyperv/vmops.py

Conflicts:
	nova/tests/virt/hyperv/test_vmutils.py
	nova/virt/hyperv/vmops.py
Fixes HyperV VM Console Log

This patch intends to fix some small nits introduced along with
the Nova console log patch.

The size of the console log can get bigger than expected because
of a small nit when checking the existing log file size as well
as a wrong size constant.

The method which gets the serial port pipe at the moment returns
a list which contains at most one element being the actual pipe
path. In order to avoid confusion this should return the pipe path
or None instead of a list.

Change-Id: I5ce9d1bea572f9098971990d011fa97ebf09233e
Closes-Bug: #1363899
Fixes Hyper-V should log a clear error message

When failing to access a remote SMB UNC path, Python raises
   WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: '\\\\'
This issue happens during resize/cold migration.

This fix ensures that the Nova driver will report a clear error
message.

Change-Id: I735987f3c3f8c16759f6fbbb235a0156df832855
Closes-Bug: #1367786
Fixes differencing VHDX images issue on Hyper-V

When using differencing vhdx images, one will be created pointing
to the base image when a VM is spawned. This image will be created
having the according flavor size.

In this case, due to a Win32 API issue, the image is not generated
properly.

Simply creating the root image with no size specified and resizing
it afterwards fixes the issue.

Change-Id: I7bb46a63d4c2a06ed6f63c839461cbbc1abffa65
Closes-Bug: #1370531

Conflicts:
	nova/tests/virt/hyperv/test_vhdutils.py
Fixes Hyper-V dynamic memory issue with vNUMA

vNUMA and dynamic memory are mutually exclusive, so the former
needs to be disabled for instances where dynamic memory is enabled.

Change-Id: Ic730c294ffc89925076688a44adf2594c7f6712b
Closes-Bug: #1305897

Conflicts:
	nova/tests/virt/hyperv/test_vmutils.py
	nova/tests/virt/hyperv/test_vmutilsv2.py
	nova/virt/hyperv/vmutils.py
Fixes spawn issue on Hyper-V

The current Hyper-V Technical Preview introduces slight changes
in the data returned by GetVirtualHardDiskSettingData in
Msvm_ImageManagementService.

Co-Authored-By: Adelina Tuvenie <atuvenie@cloudbasesolutions.com>
Change-Id: I830b07efb657acc1486f86a475310f5f4e584a37
Closes-Bug: #1376883