attach/detach interface should raise exception when instance is locked

when instance is locked, exception should be raised if attach and
detach an interface operation is performed. This patch add instance
lock check for the 2 APIs, catch and process the exception at API layer.

Change-Id: I6c0b05dafb9d480c8f0002bcc8306cb65a32aaf7
Closes-Bug: #1275741
Add test cases for validate_extra_spec_keys

There is no unit test cases for function flavors.validate_extra_spec_keys,
this patch adds for it

Change-Id: I689aad1ce7428687c723ecd2eba243fccb3342bf
Closes-Bug: #1292316
Check for None or timestamp in availability zone api sample

test_availability_zone_detail depends on the services not having an
updated_at time set in the database.  This is set by a periodic task so
it's not guaranteed to be set, or not, shortly after the service starts.
On a fast system the test reliably passes, but adding a delay causes the
test to start failing.  Introducing a time.sleep(5) in the test seems to
make it reliably fail for me.  The test should pass if updated_at is set
to None or a timestamp.

Change-Id: I976ddf5354a52ca06a6419a92abcacb7d2379a37
Closes-bug: 1300810
Check image exists before calling inject_data

os.stat removal is needed for network-based image backends

Partly revert Change-Id: I264540de736c2bcb92567826fe5ba672e1244ba2
Partly fixes bug #1257674

Change-Id: I83e95fec6f08bc36f0e2b299fb269ceaa3500243
compute: using format_message() to convert exception to string

We probably need to use format_message when converting a
NovaException to a string.
As well we can remove the cast to unicode of the parameter msg
from the local method notify since this method will only get
message in a string format.

Change-Id: I6fddfb9e124b4096f0ebc3da81c3044b1b24cedf
Avoid the possibility of truncating disk info file

Commit dc8de42 makes nova persist image format to a file to avoid
attacks based on changing it later. However the way it was implemented
leaves a small window of opportunity for the file to be truncated before
it gets written back to effectively making it possible for data to get
lost leaving us with a potential problem next time it is attempted to be
read.

This patch changes the way file is updated to be atomic, thus closing
the race window (and also removes the chown that we did not really
need).

It is worth noting that a better solution to this would be
to allow the code calling the imagebackend to write the file (once!)
and make it impossible to update after the boot process is done. This
approach would require more refactoring of the libvirt driver code, and
may be done in the future.

Partial-bug: #1221190
Change-Id: Ia1b073f38e096989f34d1774a12a1b4151773fc7
Update user_id length to match Keystone schema in volume_usage_cache

Update the maximum length to match the Keystone schema for maximum
user_id length in volume_usage_cache. In the case that Keystone were
to leverage the full varchar 64, there would potentially be data loss
and/or collision of user_ids across records.

This change originates from the conversation about increasing the
length of user_ids in Keystone:

http://lists.openstack.org/pipermail/openstack-dev/2014-February/028125.html

Even with the length not changing, it is important to ensure there is no
loss of data/resolution when relying on user_id to identify users uniquely.

Closes-Bug: #1226171
Change-Id: I05a5644a29d6e2432311c2ee5331970d5e8b0683
Allow user to specify image to use during rescue

This commit includes the compute changes to accept a parameter
rescue_image_ref in the rescue_instance method.
If specified, this image_ref will be used to rescue the instance.
If the image is not specified, then the base image ref is used by default.

Partially Implements: blueprint allow-image-to-be-specified-during-rescue

DocImpact

Change-Id: I59311fcfcb8eb54701618e92e5cdada109235b38
Merge "Allow user to specify image to use during rescue"
Merge "Update user_id length to match Keystone schema in volume_usage_cache"
Merge "Check for None or timestamp in availability zone api sample"
Merge "Avoid the possibility of truncating disk info file"
Merge "compute: using format_message() to convert exception to string"
Merge "Add test cases for validate_extra_spec_keys"
Merge "Check image exists before calling inject_data"
Merge "attach/detach interface should raise exception when instance is locked"
Create the image mappings BDMs earlier in the boot

Refactor the processing of BDMs defined in the image (either as a block
device mapping in the properties or mappings of blank devices) and move
it to the same method where the rest of BDMs are processed.

Partial-bug: #1297325
Change-Id: Ida0ddb6efcb0014890762df000eaea679f9b1d7b
Add the swap and ephemeral BDMs if needed

After preparing the block device mapping for creating new instance(s),
check if any ephemeral and/or a swap disks have been already defined. If
that is not the case and the instance type requires them, create the
needed ephemeral and/or swap BDMs.

Closes-Bug: #1297325
Change-Id: I44b30625cf1023d20ebec5e38f46b7b8dab325f6
Set root disk's size if it is a local image BDM

While preparing the block device mapping for creating new instance(s),
before sending the request to the manager, try to guess the size of the
root BDM if it is not set. The disk size will be taken either from the
base options (inherited from the instance type) or, if it is not present,
from the image size.

Change-Id: I05144bbf0cef8d69a6ca61b7d95561822a5cf886