Fix 202 responses to contain valid content.

Using a webob.exc to generate 202s makes the response return plain
text in the body, which breaks things that expect to be able to
parse data according to the content type. Using a webob.Response
object makes sure the body of the 202 response is empty.

Change-Id: Ifca3081f573407808a2196e71ac1db87180db6ec
Resolves-bug: #1356058
Add unit tests for libvirt domain creation

Tests for:
nova.virt.libvirt.driver.LibvirtDriver.get_guest_config
nova.virt.libvirt.driver.LibvirtDriver._create_domain

Partially implements: bp libvirt-lxc-user-namespaces

Change-Id: I4aada9ac06cd423b04a4c6136165c65e64e378aa
Raise Not Implemented error from V2 diagnostics API

In case any driver does not implement functionality of providing VM
diagnostics, HTTPNotImplemented error will be raised from driver.
Nova V2 API should catch the same and pass it with proper error message
for better debugging.

This patch catch & raise  HTTPNotImplemented exception for
V2 "os-server-diagnostics" API.

Adding UT also for the same.

Change-Id: I485d3487d01eba07e3c34f6ef9b5c707af54ebb7
Image caching tests: use list comprehension

Use a list comprehension for creating a list of instance objects
for the tests.

Change-Id: If25d024eeeb1503d7a7dc2dbc895b2bf3152c7db
VMware: ensure test case for init_host in driver

Commit 1deb31f85a8f5d1e261b2cf1eddc537a5da7f60b caused a regression.
This patch ensures that there is a unit test validating that the
driver implements the method.

Change-Id: I6086aeb1e9a8937d13aae41d8a4b74c25bb802f6
Support reserving ips at network create time

It is horribly inefficient to create a network and reserve a large
swath of ips, so allow the network creator to specify which ips
he wants to be available in the network by specifying allowed_start
and allowed_end.

Something like:

network-create foo --cidr 10.0.0.0/24 --allowed-start 10.0.0.5 \
    --allowed-end 10.0.0.250

would ensure that 10.0.0.0-10.0.0.4 and 10.0.0.254-10.0.0.255 are
marked reserved so instances would be assigned addresses from the
middle of the range.

Partially-implements blueprint better-support-for-multiple-networks

Change-Id: I5427e1a2d202658d374292559fc7054f2fa51124
Use real exceptions for network create and destroy

In order to provide reasonable error messages to the user, we
need real exceptions instead of a bunch of random value Errors.

Partially-implements blueprint better-support-for-multiple-networks

Change-Id: Id725afbdde40cba879608d15de9aa2753a256d10
Add api extension for new network fields.

This uses the existing api extension to implement the actual control
of the fields, but the check is based on a new dummy extension
called os-extended-networks.

Api sample tests added for new extension.

DocImpact: Adds an extension that enables extra fields for network
create. The new fields are:
  mtu: int (default flag) if set, nova sets the mtu on bridge. This
       allows network_device_mtu flag to be set per network.
  dhcp_server: ip (default == gateway) if different from gateway, sets
                nova to assume gateway is external.
  enable_dhcp: bool (default true) false will disable dhcp on network.
  share_address: bool (default flag) if specifed, network will have
                 the same dhcp ip on every host. This allows
                 share_dhcp_address flag to be set per network.
  allowed_start: ip if specified, reserves all ips before allowed_start.
  allowed_end: ip if specified, reserves all ips after allowed_end.

Partially-implements blueprint better-support-for-multiple-networks

Change-Id: I577fe5f6560be50106f345a42a826e97d5e7d64c
XenAPI: Remove interrupted snapshots

Currently the VDI chain can grow very long when a snapshots happen at
the same time as nova-compute being terminated.

While we now clean up the instance state, the VDI chain is left in a bad
state, it has an extra snapshot that is no longer required.

This change improves that by looking at when we detect a failed
snapshot, we go back and tidy up the VDI chain.

Partial-Bug: #1331440

Change-Id: I9bae82048910d8c45bc2a4093064c1ac68f15750
Add QuotaError handling to servers rebuild API

Commit 718a3f057cee0b1163c40fbcbedda29bd2ef9dfe made
nova.compute.api.API._check_injected_file_quota raise more specific
over-quota exceptions but the rebuild API was never updated to handle
the QuotaError exceptions and translate to a proper HTTP error.

This change does a few things:

1. Makes the specific file path/content limit exceeded exceptions
   extend the more generic OnsetFileLimitExceeded exception.

2. Adds the OverQuota checking to the rebuild APIs with tests.

3. Adds unit tests for the three different exceptions raised from
   _check_injected_file_quota in the compute API since those did not
   exist before.

Closes-Bug: #1358380

Change-Id: I9c72dea6075fcf554abb8e669cf4dd3129176912
Merge "Support reserving ips at network create time"
Merge "Use real exceptions for network create and destroy"
Merge "Add api extension for new network fields."
Merge "XenAPI: Remove interrupted snapshots"
Merge "Raise Not Implemented error from V2 diagnostics API"
Merge "Image caching tests: use list comprehension"
Merge "Fix 202 responses to contain valid content."
Merge "Add unit tests for libvirt domain creation"
Merge "VMware: ensure test case for init_host in driver"
Merge "Add QuotaError handling to servers rebuild API"