Libvirt:Instance resize confirm issue against NFS

when I test resize-confirm on NFS (KVM) using at least two
compute nodes, OSError will occur when try to cleanup the
backup instance directory and will make instance status
"Error".

One way to cleanup resize is using delay_on_retry and
maximum attempts setting. Replace rmtree() because
execute() have more parameters choices.

Closes-Bug: #1248019

Change-Id: Ifb9a500bbba805af0317307c2e7d6903dcd02ad1
(cherry picked from commit 17d131661740e452e9729d9ac8881e6fede23dd7)
Fix for qemu-nbd hang

NBD device once used seem to run into intermittent trouble when
used with mount repeatedly. Adding code to explicitly flush the
device buffers using 'blockdev --flushbufs'.

NOTE(dmllr): Also merged regression fix:

    Consolidate the blockdev related filters

    Seeing a "/usr/local/bin/nova-rootwrap: Unauthorized command" error
    in the logs when  "blockdev --flushbufs" is executed because of the
    existing blockdev in compute.filters. We need to merge both into a
    single RegExpFilter

    Change-Id: Ic323ff00e5c23786a6e376e67a4ad08f92708aef

(cherry-picked from dd3f96e91581f465a52d10a212eb51b147dc38b5)
(cherry-picked from 31b2791e6be1768c410de5fa32283fcb637bda57)

Closes-Bug: #973413
Partial-Bug: #1254890
Change-Id: I2b7053b9a069d6e82f6f6baf9ad480efa4388d91
Update log message for add_host_to_aggregate

When add host to aggregates with availability zone, if the host
is already in one availability zone, then the host cannot be added
to another availability zone.

When user do above operation, nova api will report error message,
but the error message does not include blank space between
<availability zone> and zone name, also the error message include
two periods.

The fix was adding blank space and removes one period for the message.

Change-Id: I7307288be194d3ce6de05b77433bbe2626ae46d9
Closes-bug: #1237303
(cherry picked from commit c2ae5fb5659faeadc6f4d8afe27eb68e3c0ade0c)
Set python hash seed to 0 in tox.ini

New tox (>=1.7.0) sets a random python hash seed by default. This is
generally good for testing because it will help keep projects working
regardless of the hash seed, but nova unittests don't currently pass
with a random hash seed so set it to the python default seed.

This change will allow us to use new tox again and remove the
restriction on tox<=1.6.1 to run unittests.

Redundant setenvs for specific test envs are removed to prevent them
from overriding the PYTHONHASHSEED value.

Note this change will need to be backported to the stable branches to
keep unittests there working with new tox as well.

Conflicts:
	tox.ini

Change-Id: Ib54364877a251db48c54dfdc43c503281ea1f04a
(cherry picked from commit 4f3e3cd1883ea5aca237bcc88b64128c743a6862)
Fixes get_vm_storage_paths issue for Hyper-V V2 API

Add get_vm_storage_paths function to vmutilsv2.py

get_vm_storage_paths implementation on Hyper-V V2 API changed
compared to previous V1 API. In previous V1 APIs, using
Msvm_ResourceAllocationSettingData class can get storage
paths, but in V2 API, only using Msvm_StorageAllocationSettingData
class can get the storage paths.

Closes-Bug: #1248463

Change-Id: Ica73221524f162a6ffcd9dc64ee33c85fb5ad31d
(cherry picked from commit 6847a0ef927929e631e9c6db2e2812528ca93151)
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

(cherry-picked from commit fdc5a57d03b9a53981dc0e1623091980570456eb)

Conflicts:

	nova/tests/virt/hyperv/test_vhdutils.py

Change-Id: Ibe44f0d895cde2edbc03dcd6ecebac24b0936660
Merge "Fixes get_vm_storage_paths issue for Hyper-V V2 API" into stable/havana
Merge "Fixes Hyper-V issue with VHD file format" into stable/havana
Merge "Fix for qemu-nbd hang" into stable/havana
Merge "Update log message for add_host_to_aggregate" into stable/havana
Merge "Set python hash seed to 0 in tox.ini" into stable/havana
Hyper-v: Change the hyper-v error log for debug when resize failed

The error message is not sufficient enough for debug of hyper-v
when resize error occured, this patch adding the necessary info
in error log.

Closes-bug: #1238430
(cherry-picked from commit 6ee68137c5ea9af99c1db4e2a2ce555f43a9e3e1)

Change-Id: Ic8ecb8f08139face2c7bdca258de5e719d81833c
Fixes ConfigDrive bug on Windows

Files must be written specifying "wb" instead of "w"
to support binary files on both Windows and Linux.

Closes-Bug: #1261585

(cherry-picked from commit 1fc9eafab43accc127044351106983e2cb215520)

Change-Id: I069845136df4a11b54c931a71575ca3efb9bc6d0
Hyper-V:Preserve config drive image after the instance is resized

If we configure config_drive_cdrom=True in nova.conf,
the config drive image will be lost after the instance
is resized on hyperV. This is because nova compute will
not copy the disk file if the file's ResourceSubType
is not 'Virtual Hard Disk'.

This commit adds 'Virtual CD/DVD Disk' into disk_resources
to preserve the config drive image after the instance is
resized.

Closes-Bug: #1250324
(cherry-picked from commit 710cf4e3a7ee3b89e462ec5ff2291e1177556819)

Change-Id: Ia125a8b132d194ddc2230754fd1b813698b410a8
Fixed naming issue of variable in a debug statement formatting

Closes-bug: 1275802

(cherry-picked from commit 4d2bd3fc2777b732b8225a03d8bff2fcbcceb81f)

Change-Id: I5bf57290ff3023f6d3332a92114cc4f235e1f4af
Hyper-V: Change variable in debug log message

The variable used in the log message is incorrect. The log message
outputs the file size instead of the internal VHD size.

Closes-bug #1275805

(cherry-picked from commit 7020f6eccfd1fb7d6b52e77c363c58815915240a)

Change-Id: I270709098e058cf51bbe6494b903a461b3938d15
Fixes Hyper-V VHDX snapshot bigger than instance

In Hyper-V, the deployed images will be extended having their
metadata size added to their base image size. This may lead to
snapshots bigger than the flavor size.

This patch adds support to the V2 utils module, so that the
maximum internal size of a requested image may be calculated
in a similar way it is done in the V1 module.

VHDX format specs:
http://www.microsoft.com/en-us/download/details.aspx?id=34750

Closes-bug:  #1231911

(cherry-picked from commit 9ea92029f7846dc65238b0be3c3c95568862448d)

Change-Id: I0d6aacb275f8af24554d3e8b6f04fe8a454b913f
Replaces exception re-raising in Hyper-V

In a few cases in the Hyper-V driver classes, generic exceptions
are getting caught, logged and a domain specific exception is raised.

This creates issues in identifying the exception cause programmatically
(e.g. in unit tests).

This patch enforces the usage of excutils.save_and_reraise_exception()

Closes-Bug: #1280363

(cherry-picked from commit 80ffc9b8b38293c05c9d48cb615b24fd7255a850)

Change-Id: I27cc54941c5f592ea567ccaa8fa369362da1427f
Added missing raise statement when checking the config driver format

Closes-bug: #1275772

(cherry-picked from commit 378c28a8c05d3943324b5a39edef947ed7a9f52a)

Change-Id: I636525d0272511d4192c43d18c56e867fb7514d8
Fixes the Hyper-V agent individual disk metrics

Replaces aggregated metric values with separated values for each disk.

(cherry picked from commit a41ef0ede2cdace1db4d932e0931509a84ba837e)

Change-Id: I3c264dfd52572e5c429ee606a47a5727a4a3af3c
Closes-Bug: #1290403