Revert "Importing correlation_id middleware from oslo-incubator"

This reverts commit 26ecf7b02377b860b4412aa554ed2392f42f8d40.

This patch was merged in preparation for
https://review.openstack.org/#/c/29480/ which was never merged.

Change-Id: Iefa1478af03f748ccb5f27f8bd4ad0f5b24af070
Fixes race cond between delete and confirm resize

If we delete an instance after a confirming resize operation,
and if the instance is deleted firstly at the dest compute node,
then the *_resize dir and network info of this instance will be
left alone on the source compute node, never be cleaned up.
Please refer the bug page to get the reproduce steps

Fixes bug 1202484

Change-Id: Ib1e3d976373bd7f4d086d4f9716b0bca4b383bab
Catch more accuracy exception for _lookup_by_name

When an instance is not found by libvirtd, _lookup_by_name in libvirt
driver raises InstanceNotFound. This patch catchs this exception instead
of NotFound who is the father of InstanceNotFound.

Closes-Bug: #1222663
Change-Id: I1b4ce8f6c44eef29617a42151152cda2159a0088
Add V3 API samples for flavor-manage,flavor-extra-specs

Partially implements bp v3-api-extension-versioning

Change-Id: I54881677005cc085e5a2a604fc83eb4225ffd5d0
xenapi: ensure pool based migrate is live

The current code is missing a flag to pool_migrate that should be
included to ensure the migrate is live. This change adds that flag to
both uses of VM.pool_migrate, namely the live-migrate call and the
host_maintenance call.

Fixes bug 1201795
Change-Id: I265baaba5e9bd9132bd5e1c6f9fb18cefab02cfb
xenapi: add tests for finish_migration and spawn

Before making finish_migration and spawn share more code, lock down the
current code with unit tests.

There are also some methods that are split up, to help with some of the
next refactoring steps.

Change-Id: Icfc214ea2c7470705f5605816b8313e0ba2a1429
xenapi: stop injecting the hostname during resize

The windows PV tools will set the hostname of a server to the value
given in the hostname xenstore key. If we inject that during resize, the
users will be unable to change their server hostname, and in addition it
will be reset to the original name.

Fixes bug 1207829
Change-Id: I49ba9d9f4f8b4a86488e427d99f69236bd959c78
xenapi: regroup spawn steps for better progress

Currently the operations are not very logically grouped. Now we can see
all the individual actions more clearly, we can re-arrange the
operations so each step make more sense, and should be better at
reporting progress.

Rather than checking very late that there is no duplicate VM and enough
memory, I have moved these checks before the expensive operation of
downloading the disk.

After this change there are 10 clear steps during spawn:
* initial step so progress is not zero during download disks
* download and create disks step
* download and create kernel and ramdisk step
* create the VM record, now the disks have been downloaded
* setup the disks; resizingi up disk, and attaching, adding rescue disk
* injecting instance data, currently this means writing to xenstore
* setting up the networking, including the initial firewall setup
* starting the VM and waiting for it to boot
* configuring the VM using the agent (takes a long time on windows)
* applying the final firewall filters, now the VM is running

With this in place, it will be easy to decide which steps are required
and which are not required when reusing the spawn code to implement
finish_migration in a later change.

Change-Id: I0e33dd7d298390630f632e116c8866a64e769102
xenapi: ensure finish_migration cleans on errors

This change makes finish_migration share code with spawn.

This fixes some inconsistencies, such as applying the security
group filters during finish_migration.

Fixes bug 1073303
Fixes bug 1073306

Change-Id: Ib4f2a96618692c141708535f9463c856f3395922
Code change for nova support glance ipv6 address

This code change is for nova can parse glance api servers which is
IPv6 address correctly, also make sure nova commands can be run
successfully in pure ipv6 environment, such as 'nova image-list'
and 'nova boot' command.

Fixes bug 1182830

Change-Id: Ia71002c7038b820db7a63f7d6892e76de4743d8d
Add v3 API samples for os-extended-volumes

Partially implements blueprint v3-api-unittests

Change-Id: I347b220890980a588eaecda644b15257d85b4a85
Improve "keypair data is invalid" error message

When doing a keypair-add, I was hitting a permission denied issue with
ssh-keygen -l. This turned out to be a configuration issue, but the
error message on the client side was pretty unhelpful with debugging
the issue:

  BadRequest: Keypair data is invalid (HTTP 400)

Fix that so we get:

  BadRequest: Keypair data is invalid: failed to generate fingerprint (HTTP 400)

Also fix the other uses of InvalidKeypair so we include the general
"keypair data is invalid" prefix.

Change-Id: I209e76adaf7c18a9f2f2dbb6da62db6c1cd9461e
Fix network info injection in pure IPv6 environment

get_non_legacy_network_template assumes that IPv4 is always available

So if i try to use Nova Network without any ipv4 using say
"nova network-create public --fixed-range-v6 fd8c:215d:178e:452:0:0:0:0/64"
then the deployment fails. So fix the code to ensure ipv4 is optional

Fixes LP# 1216178

Change-Id: Ib0c47a49debd4fed83d382a301687df23ca2ec0d
Fix snapshot failure with VMwareVCDriver

The snapshot operation was failing because it calls
VirtualDiskManager.CopyVirtualDisk with a destination disk spec, which
is not supported when called through VC. The fix is to not supply a spec
when calling through VC, in which case the disk is consolidated and
copied without type transformation.

While the fix is to use spec-less CopyVirtualDisk in VC, doing so in ESX
too will result in unintended transformation (because it ESX will
default to busLogic/preallocated), so the use of the spec was retained
in ESX-mode instead.

Another issue found and fixed is that the name of the snapshot image is
incorrectly set when uploading to glance.

The following tempest tests are now unbroken against the VC and ESX
nodes:
  tempest.api.compute.images.
     test_images_oneserver.ImagesOneServerTest{JSON,XML}.
        test_create_delete_image
        test_create_second_image_when_first_image_is_being_saved
        test_delete_image_of_another_tenant
     test_list_image_filters
  tempest.api.compute.test_authorization.AuthorizationTestJSON
  tempest.api.compute.test_authorization.AuthorizationTestXML

Fixes bug 1184807

Change-Id: I7ec49859fb2842cc02cdc87a6434aa58612a2964
Fix problem with starting Windows 7 instances using VMware Driver

The default controller for a Windows 7 virtual machine is the
LSI Logic SAS. When the disk adapter type is specified as 'lsiLogic'
via glance image metadata, VMware driver defaults to LSI Logic Parallel
controller. With this fix the driver will honor a property 'lsiLogicsas'
to distinguish the right adapter and enable booting Windows instances.

Fixes: bug #1187853
Change-Id: Idb36a784a31e4938e8951adeb83335b3890dac85
Add V3 API samples for quota-sets/class-sets,inst-usage-audit-log

Partially implements blueprint v3-api-unittests

Change-Id: I6c21e5dffc5669bb6ab2bba091b97725cc19fd69
xenapi: Make rescue safer

If rescue setup fails, detach the root disk from the rescue VM so it
doesn't get nuked by the undo stack logic in spawn()

bug 1227898

Change-Id: I8864b4c524f04f7b387be1018fea9919a461c48b
Remove two unused config options in baremetal

baremetal.injected_password and injected_network_template are not used
anywhere, so just remove them.

The actual injection config options used, such as net_config_template,
are in baremetal.pxe.

Change-Id: I93b4d2c2303a1ce954c45fc7e9842b18615bd56f
VMware: handle exceptions from RetrievePropertiesEx correctly

The commit below did not update the exception handling correctly:

  e331287cdd1300878bfb9bbb3630889370e5fa72

The fault checker should be retrievepropertiesex_fault_checker instead of
retrieveproperties_fault_checker.

Fixes bug: 1216961
Change-Id: I8be959fc2ef941f89347245a3077eba623824760
VMware: datastore regex not honoured

Commit 9408d79e7413aadcba52a61b7a33164090785e4f did not pass the
datastore regular expression to the VMOps class. This resulted in the
configured parameter being ignored.

Fixes bug: 1222349

Change-Id: I0c7619b281662121f353c04e07331404d747b28b