xenapi: Do not retry snapshot upload on 500

If Glance returns a 500 response on an initial attempt to upload
a snapshot image, it will set the image status to killed.  Any retry
attempts will fail with a 409 response.

Hence, Nova should not attempt to retry the upload in this case, which
will eliminate many pointless retries.

Closes-Bug: 1349933

Change-Id: I1a8f2416923a368b02cf8963c747ebbb24d749a1
Remove translation for debug message

Remove translation for debug message in neutron api layer.

Change-Id: I5b3ce1115d8f2c46f6c144f21e735a45f338cb32
Add valid method check for quota resources

ReservableResource and CountableResource comes down to
the method used to count the in-use
resources.  For ReservableResource, the count is based on the number of
database objects matching the project ID, whereas with
CountableResource, a counting function has to be specified; otherwise,
the classes are identical and designed to be used identically.indeed,
CountableResource extends ReservableResource and only overrides the
constructor.

This patch add some sanity-checking to limit_check() and
reserve() that ensure that they only work with the correct resource
type(s)

Change-Id: Ibec048a5d8c2c4a8685f5f3cc2076c64b39654a3
Partial-Bug: #1301532
Deprecate scheduler prep_resize

Scheduler prep_resize is no longer necessary as now the retries
from compute are going to the conductor.
Deprecating this method is also a prerequisite for the split
of the scheduler as it was issuing calls to computes.

Change-Id: I1092bbf7f541bb8cd7e33317f33b8c02761f284e
Clean nova.compute.resource_tracker:_update_usage_from_instances

Use cleaner if else statement.

Change-Id: I287eae65873e34cc115768fd5361cd56e6444fc4
API: Enable support for tenant option in nova absolute-limits

When querying for the absolute limits of a specific tenant,
the tenant option is ignored. There are no attempts to extract
the tenant from the request. Instead, nova uses context.project_id
as the project_id in QUOTAS.get_project_quotas. The following
patch extracts the tenant_id from the request (if any) and passes
that to QUOTAS.get_project_quotas to obtain the proper quota.

Change-Id: If5f91de020ed8a40fa04fc001c7c4c92681f4ad1
Closes-Bug: #1334278
libvirt: fill in metadata when launching instances

When generating the guest XML config, fill in the nova
specific metadata whose schema was previously defined.

Blueprint: libvirt-driver-domain-metadata
Change-Id: I3e1f0eb5bb0e71732a18609ff11f8ee6deb1a8da
Extend API schema for "create a server" extensions

Some v2.1/v3 APIs(create/update/rebuild server) contains the API
extension feature, it searches extension methods with its method
name and operates them automatically.
It is necessary to change the API schemas also automatically based
on the API extension loading condition, because the API extensions
add API parameters.

This patch adds API schema extensions which are implemented with the
same mechanism (stevedore library) as the API extension for "create
a server" extensions. As a sample of API schema extensions, this
patch adds the schema of keypair extension.

Partially implements blueprint v3-api-schema

Change-Id: I972d648546b1fcb37c6ad5e12a0a49ce810a35f9
Improved error logging in nova-network for allocate_fixed_ip()

When a Nova deployment runs out of fixed IP addresses, allocating
another IP ends with stack trace without clear explanation.
To prevent such behavior this patch introduces few try-except blocks
that writes appropriate error message to the log file and return
better error code via API instead of stack trace.

Change-Id: I8111ae883719ad693113e1d3bfedc8685427c55f
Closes-Bug: #1218572
Change LOG.warn to LOG.debug in _shutdown_instance

Change LOG.warn to LOG.debug for detaching volume related exceptions
in _shutdown_instance in compute/manager.py, since as the log message
said the exceptions should be ignored. It's probably not worth a
warning in the log.

Change-Id: Ibe216b9bccf590e64aa1b966753bd1ec67c8dbdf
Handle FloatingIpPoolNotFound exception in floating ip creation

If an invalid pool is specified when creating a floating ip
with neutron as the backend a FloatingIpPoolNotFound exception
can be raised. This change handles the exception at the API level.

Change-Id: Iac46d86a11f2c1da0ed7e7861cdb87fd4d4b4c6c
Closes-Bug: 1352141
Diagnostics: add validation for types

When creating diagnostics the calling application is able to pass
cpu, nic and disk diagnostics. This patch validates that those are of
the correct type.

TrivialFix

Change-Id: Id76c37e2f3ff50b0029bb1fa26348e43aee432f1
Removes unnecessary instructions in test_hypervapi

Lines have no actual effect on the tests. Removing them
will facilitate further unit tests.

Partial-Bug: #1220256

Change-Id: I805aba5e75f2640221b2dc0034950c0832841247
Migrate test_glance from mox to mock

A few tests in test_glance.py are still using mox. Update these
remaining tests to use mock, as this is the general direction in
which the project is moving.

Change-Id: I81fc36467b158625f29593c7173542f843244311
Add expire reservations in backport position.

Change-Id: If0e58da50ebe9b50b414737a9bd81d93752506e2
Related-bug: #1348720
Add method for deallocating networks on reschedule

The original call to dhcp_options_for_instance() is not a great way to
check whether deallocation of networks should happen on reschedules.

This adds a new virt driver method 'deallocate_networks_on_reschedule'
which can be used by a virt driver to say whether reschedules should
deallocate networks first. This defaults to False and modifies the
baremetal virt driver to return True. Ironic virt driver will also need
to return True.

Closes-Bug: 1342919
Change-Id: I54a3252ab15e2d8b596ccc90eb4755405021f1da
Merge "Add expire reservations in backport position."
Merge "Migrate test_glance from mox to mock"
libvirt: saving the lxc rootfs device in instance metadata

Currently, nbd/loop device, to which lxc image has been
connected, is being saved as instance root device, which causing
the attached bug.
Saving the device name in instance system metadata instead.

Closes-Bug: #1330981
Change-Id: I3a0533a89ea8af61349118a39b822f4af146cc04
Merge "Diagnostics: add validation for types"