Utilizes assertIsNone and assertIsNotNone - tests/virt

Using assertTrue and the 'is None' operator to test if an element is None
is too python2.4. Our unit testing framework 'testtools' supports
assertIsNone and assertIsNotNone, included from python 2.7,
which were created for these types of tests.

Change-Id: Iee1379b941f93388900e89388676000b845fc8fc
Replace assertEquals with assertEqual - tests/api

The method assertEquals has been deprecated since python 2.7.
http://docs.python.org/2/library/unittest.html#deprecated-aliases

Also in Python 3, a deprecated warning is raised when using assertEquals
therefore we should use assertEqual instead.

This is part of blueprint assertequal

Change-Id: I72f612cc62f90a079c9c53747e3bcbfebfb8eb96
Make unshelve use new style BDM

Unshelving an instance requires recreating it, and since change
I5b9c3e2d959c602fa22f49db681da918ae0adcea, it is necessary to call
compute manager's _prep_block_device with new style BDMs.

This patch makes the conductor return new-style BDMs when unshelving the
instance.

Closes-bug: 1246412
blueprint: clean-up-legacy-block-device-mapping

Change-Id: I0ba9f53c31c4d5238319cfd09600ad64f298629e
Add network handling to build_and_run_instance

Allocates requested_networks and returns network_info to pass on the
virt driver spawn method so that networks can be set up on the instance.
If there's a failure during the instance creation the network will be
deallocated.

A failure to allocate requested_networks will abort the build because
the instance can't be built as desired.  And rescheduling to another
host is not likely to increase the chance of success.

This is one part of a series of patches to build up the
build_and_run_instance method.

Part of bp remove-cast-to-schedule-run-instance

Change-Id: I83e562845f07a76fa3365d46f1bb4a44dbda6bc1
Add updates and notifications to build_and_run_instance

Adds instance updates and notifications to match the updates coming from
run_instance()

This is one part of a series of patches to build up the
build_and_run_instance method.

Part of bp remove-cast-to-schedule-run-instance

Change-Id: I8807fc15be54eaf93ecbfcc12382cfa5fcddc81f
Use elevated context in resource_tracker.instance_claim

There's no requirement that the resource tracker be used by an admin
context, but the db updates for compute nodes won't work without an
admin context.

This updates instance_claim to match how resize_claim,
abort_instance_claim, drop_resize_claim, and update_usage function.

Needed by bp remove-cast-to-schedule-run-instance

Change-Id: Ib5b11ee6009f910966fbb849f020eb86c55de319
Make non-admin users can unshelve a server

If non-admin users try to unshelve a server, nova-compute fails due to
"User does not have admin privileges" while getting hypervisor_hostname.
This patch changes the user context to admin's one temporarily to get the
hypervisor_hostname.

Closes-Bug: 1245312
Change-Id: I84dce1f7694d09c1281da13c6008bb3aa5940f85
Add V3 API samples for config-drive

Adds api sample tests and api samples for config-drive

Partially implements blueprint v3-api-unittests
Partially implements blueprint v3-api-specification

Change-Id: Id589ddced8c30089bacbb3eca81d4b9238901a91
Merge "Add network handling to build_and_run_instance"
Merge "Add updates and notifications to build_and_run_instance"
Merge "Use elevated context in resource_tracker.instance_claim"
ensure we don't boot oversized images

Since we can't generally shrink incoming images, add extra checks
to ensure oversized images are not allowed through.
All cases when populating the libvirt image cache are now handled,
including the initial download from glance, where we avoid
converting to raw, as that could generate non sparse images
much larger than the downloaded image.

* nova/virt/libvirt/utils.py (fetch_image): Allow passing through
of the max_size parameter.
* nova/virt/images.py (fetch_to_raw): Accept the max_size parameter,
and use it to discard images with larger (virtual) sizes.
* nova/virt/libvirt/imagebackend.py (verify_base_size): A new
refactored function to identify and raise exception to oversized images.
(Raw.create_image): Pass the max_size to the fetch function.
Also enforce virtual image size checking for already fetched images,
as this class (despite the name) can be handling qcow files.
(Qcow2.create_image): Pass the max_size to the fetch function,
or verify the virtual size for the instance as done previously.
(Lvm.create_image): Pass the max_size to the fetch function.
Also check the size before transferring to the volume to improve
efficiency by not even attempting the transfer of oversized images.
(Rbd.create_image): Likewise.
* nova/tests/virt/libvirt/fake_libvirt_utils.py: Support max_size arg.
* nova/tests/virt/libvirt/test_libvirt.py (test_fetch_raw_image):
Add a case to check oversized images are discarded.
* nova/tests/virt/libvirt/test_imagebackend.py
(test_create_image_too_small): Adjust to avoid the fetch size check.

Fixes bug: 1177830
Fixes bug: 1206081
Change-Id: I3d47adaa2ad07434853f447feb27d7aae0e2e717
Merge "Make non-admin users can unshelve a server"
Merge "Add V3 API samples for config-drive"
Merge "Make unshelve use new style BDM"
Merge "Replace assertEquals with assertEqual - tests/api"
Merge "Utilizes assertIsNone and assertIsNotNone - tests/virt"
Add compatibility for InstanceMetadata and primitives

Since the virt drivers instantiate InstanceMetadata manually,
this adds a bit of compatibility for primitive instance objects
until we have all of compute manager converted.

Change-Id: Ifb9ae7838300280895d63ffbd13337529b6d883c
Merge "ensure we don't boot oversized images"
Merge "Add compatibility for InstanceMetadata and primitives"