Remove unnecessary passing of task_state to check_instance_state

Remove cases where task_state=[None] was passed to check_instance_state
when that is essentially the default value anyway

Change-Id: I49b6449b9ae43a5cfcf5a1ccac5ee9a64d2b3f3c
Update block_device_info to contain swap and ephemeral disks

An ephemeral or swap disk is attached to an instance on boot
as follows: nova boot --flavor FLAVOR --image IMAGE_ID
--swap 512 --ephemeral size=2 INSTANCE.  When a hard reboot is
performed on the instance, nova fails to recreate the
appropriate libvirt XML definition, containing the ephemeral
disk.  This is because the correct block_device_info dict that
is passed to the compute manager's reboot_instance method does
not contain swap or ephemeral disk key values that are necessary
to recreate those disks.  In addition to nova boot, the correct
block_device_info dict is also needed by nova rebuild, reboot,
resize, and migrate to recreate those disks.  This patch updates
_get_instance_volume_block_device_info (renamed
_get_instance_block_device_info) to return the swap and ephemeral
disk key values, in addition to the block_device_mapping it
already returns today.

Change-Id: Iec329d1c12a48ea90ba9d57decd0996fde6544f0
Closes-Bug: #1305423
Add x-openstack-request-id to nova v3 responses

x-openstack-request-id is the common header name for request ID going
forward. Nova, cinder, and neutron return this header. Using the
request_id middleware is a convenient way to ensure this header is in
the response. We will also be using the middleware to generate the
request ID.

The ID will be generated by the middleware and is inserted into the
request environment. The current code generates the request ID in the
constructor of RequestContext; with this change, the ID is generated
beforehand and passed in to the RequestContext constructor. Not much
different here: a request ID is generated and is available for use in
the handling of the request.

On the response end, the middleware is again used, this time to
attach the x-openstack-request-id header, using the value of the
generated request ID.

For v3, we will be using the request_id middleware provided in oslo.
For v2, nova-specific middleware (compute_request_id.py) is used.
Therefore, v3 responses will have the header x-openstack-request-id,
and v2 responses will have the header x-compute-request-id (no
change). It is necessary to move the existing code out into
middleware, so that the old header is not attached to v3 responses.

UpgradeImpact: api-paste.ini is modified

DocImpact: v3 responses of the API will only include x-openstack-request-id

Implements: blueprint cross-service-request-id
Change-Id: I5e370fd3de5ee2f8a8d13553015d88910ff5ea87
Add fault wrapper for rescue function

we might need to record the unsuccessful action for instance,
rescue function currently don't have this method. This patch add
it so that it will record failed rescue action into db.

Change-Id: I615089e7562262dc286a55a2c7228be3201d6d94
objects: remove unused utils module

The nova.objects.utils module appears unused since commit 91a89f4 when
we finished refactoring the code into nova.objects.fields.

Change-Id: I1468172f823e362eca7f152ba282982fb5b41f35
Make live_migration use instance objects

Since live_migration moved to the task API, we've been passing
instance objects down to compute/rpcapi, but then converting them
to primitives at that point. This removes that, enables compatibility
with older code, and makes the live_migration() use objects.

Note that live_migration() is different from all the other calls
we use the object_compat decorator on, since instance is not the
first parameter. Because of this, and because it's called from a
single place where we know what expected attributes we should have,
this just adds the compatibility code directly into the method,
instead of trying to complicate the decorator for this one-off
case.

Related to blueprint compute-manager-objects-juno

Change-Id: Ibbad57569c67db6ddc2e6cc41ea49f77c46d761e
Don't translate debug level logs in nova.compute

Our translation policy
(https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls
for not translating debug level logs. This is to help prioritize log
translation. Furthermore translation has a performance overhead, even if
the log isn't used (since nova doesn't support lazy translation yet).

Continuation of Ie1068d2d2c7c37f27c62d0e4e5a64a1a504af9f5

Change-Id: Id6ed926df97fe31b4d553546818de5356e3a4cbb
Don't translate debug level logs in nova.objects

Our translation policy
(https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls
for not translating debug level logs. This is to help prioritize log
translation. Furthermore translation has a performance overhead, even if
the log isn't used (since nova doesn't support lazy translation yet).

Change-Id: I8bdc66c0711539b373884dc35a84ee8143e6de67
Don't translate debug level logs in nova.cmd and nova.db

Our translation policy
(https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls
for not translating debug level logs. This is to help prioritize log
translation. Furthermore translation has a performance overhead, even if
the log isn't used (since nova doesn't support lazy translation yet).

Change-Id: I8fa50e469384f4b626ae6aa47e9ca0b8e29da404
Don't translate debug level logs in nova.cert, console and consoleauth

Our translation policy
(https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls
for not translating debug level logs. This is to help prioritize log
translation. Furthermore translation has a performance overhead, even if
the log isn't used (since nova doesn't support lazy translation yet).

Change-Id: I9a0c718fc71e456baf87d1d28827654a015c62a6
Don't translate debug level logs in cloudpipe, hacking, ipv6, keymgr

Our translation policy
(https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls
for not translating debug level logs. This is to help prioritize log
translation. Furthermore translation has a performance overhead, even if
the log isn't used (since nova doesn't support lazy translation yet).

Change-Id: Icdae100d5a506fdaa56fd124dc9860cdfddbe288
Don't translate debug level logs in objectstore, pci, rdp, servicegroup

Our translation policy
(https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls
for not translating debug level logs. This is to help prioritize log
translation. Furthermore translation has a performance overhead, even if
the log isn't used (since nova doesn't support lazy translation yet).

Change-Id: I4c8e7365e1e3bae52956249f1c7d97c7729aebc3
Fix broken version responses

The version responses link to non-existing PDF and WADL files.
Remove the WADL link and replace the PDF link with a HTML link to
docs.openstack.org.

Change-Id: I200e0fa268c4357403ca6c158fbbe682080c13d1
Closes-Bug: #1313119
Raise descriptive error for over volume quota

If you attempt to create a new instance booting from an image and you
were over your quota on cinder, the nova manager would see that as an
invalid block device. This raises a more descriptive error message in
the logs.

Closes-bug: #1013417
Change-Id: Ie50b97c31580da7fc38c6891d1f3646b91f8aa10
Don't translate debug level logs in nova.spice, storage, tests and vnc

Our translation policy
(https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls
for not translating debug level logs. This is to help prioritize log
translation. Furthermore translation has a performance overhead, even if
the log isn't used (since nova doesn't support lazy translation yet).

Change-Id: I5964d2f6a4328b91d67c0d8fd514e1eb7c6048bb
Updated from global requirements

Change-Id: I0c090aead369f8592539303bb067478dfc8897fa
libvirt: Stub O_DIRECT in test if not supported

`os.O_DIRECT` is only defined on platforms that support direct I/O. On
Macs, which don't support direct I/O in this way, `os.O_DIRECT` will
raise an `AttributeError`.

We can still test the code-path, however, by just stubbing out the
value on platforms where it's not supported.

Closes-Bug: 1286958

Change-Id: I8f10d6dfc4a63b6a961006b029b828e703870e46
Make cells use Fault obj for create

Add support into InstanceFault.create() to handle where we need to
duplicate any faults in the API cells. Convert the cells code to use
InstanceFault.create()

NOTE: This happens to fix an oversight where we accidentally left the
update_cells=False kwarg off of the db call in the cells code.

Change-Id: Iec11b8259aaecba055a6d5636ab60dfa0dbb6c83
Include pending task in log message on skip sync_power_state

To better understand why sync_power_state is being skipped include the
pending task name in the log message.

Change-Id: I832a3d5820efab301e12610b28ca2a1e5cfd946a
Remove duplicated import in unit test

A couple of unit tests were importing twice mock or mox.
This patch just remove the duplicated import.

Change-Id: I0c66746348e184a3846cadd40d7d7cbb7d594564