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
Don't mask out HostState details in WeighedHost

WeighedHost's __repr__ was poking under the HostState hood to use
.host in its own __repr__ but this hides some important details.
Specifically it hides the hypervisor_hostname, which is important for
Ironic as one 'node' can have thousands of hostnames. The other
details such as available RAM and so on are also useful for ops trying
to debug scheduling issues, so rather than add hypervisor_hostname, I
am just delegating to the underlying __repr__.

Change-Id: I79e55c32b3d0768430132275ebe050f38c63bc87
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
servers list API support specify multi-status

Currently the service list API allows the user to specify an optional status
value to use as a filter - for example to limit the list to only servers with
a status of Active.

However often the user wants to filter the list by a set of status values,
for example list servers with a status of Active or Error,
which requires two separate API calls.

Allowing the API to accept a list of status values would reduce this to a
single API call.
Allow to specify status value for many times in a request.
For example::
    GET /v2/{tenant_id}/servers?status=ACTIVE&status=ERROR
    GET /v3/servers?status=ACTIVE&status=ERROR
V2 API extension::
    {
        "alias": "os-server-list-multi-status",
        "description": "Allow to filter the
            servers by a set of status values.",
        "links": [],
        "name": "ServerListMultiStatus",
        "namespace": "http://docs.openstack.org/compute/ext/
            os-server-list-multi-status/api/v2",
        "updated": "2014-05-11T00:00:00Z"
    }

DocImpact: Adds os-server-list-multi-status extension.

blueprint servers-list-support-multi-status

Change-Id: Id0109c56070e2f920be0f95738749aa969258bc1
Fix duplicated images in test_block_device_mapping

In test_block_device_mapping, each test can select to specify
image_ref, block_device_mapping or both. The "both" should be
negative tests because nova API gets image_id from either image_ref
or block_device_mapping.
However, there are some "both" tests which are not their purposes.
This patch fixes these tests for their purposes by passing True as
no_image.

These bugs were found through jsonschema validation framework
development, because the schema could detect "both" cases fastly
and these tests could not get their purposes.

Change-Id: I73f1a15d8e08a3eda3190e660338e274358ddd33
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
Add extensible resources to resource tracker (2)

A resource plugin extension point is added to the resource
tracker to allow the types of resources allocated at the compute
node to be extensible. Information maintained by these plug-ins
is written to the compute_nodes table in the database. The
scheduler uses the information in the compute_nodes table to
determine scheduling decisions.

A plugin that implements vcpu resource tracking is included
and all other code for tracking vcpu has been removed. This
example ensures the plugins are tested in gate jobs.

This was previously merged and reverted due to a bug affecting
ironic CI. The bug was pre-existing but was exposed by the
that patch. This change is based on the bug fix here:
Icb19148660bca542a8120ecab064551d67ac28af and the previous
version of this change is here:
I64108338e3c958ba1276aaf113a68861cbe286f5

Co-Authored-By: Andrea Rosa  <andrea.rosa@hp.com>
Co-Authored-By: Paul Murray  <pmurray@hp.com>
This is part of: blueprint extensible-resource-tracking

Change-Id: If1381f99fd7db420380288faf7b2f57553f69136
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
Remove ESXDriver from Juno.

1. Removes the VMwareESXDriver code in nova/virt/vmwareapi/driver.py
by either deleting the redundant methods or moving them to
VMwareVCDriver.
2. Changes the test cases to use VMwareVCDriver and also removes
duplicate test cases which were previously being testing both
VMwareESXDriver and VMwareVCDriver to just the latter.

DocImpact
Closes-Bug: #1346637
Change-Id: I718fc0ee67dbd625af00c20fa4e34b8a35015437
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
Make network/api.py use Network object for associations

This makes the network/api.py module use the Network object for
network host and project associate/disassociate operations. There
was very little testing of this, so this patch adds/corrects tests
to verify object behavior.

Related to blueprint compute-manager-objects-juno

Change-Id: I5c0d61be35fc4edf647e572c746515988651bcc0
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
Code change for nova support cinder client v2

Use v2 volume endpoint to attach/detach volume would be failed,
due to nova not supporting cinder client v2 yet. This patch is for
nova support cinder client v2.

Implements bp support-cinderclient-v2
Closes-Bug: #1215772
Co-Authored-By: Mike Perez <thingee@gmail.com>
Co-Authored-By: Yaguang Tang <yaguang.tang@canonical.com>

Change-Id: Id8abbbb4d9b0c8c49ab51fc3d958ef0d487467f8
Fixes wrong usage of mock.assert_not_called()

There is no method assert_not_called in mock, use
assertFalse(mock.called) instead of that.

Change-Id: I846c37fe79931c85384950f6ad6ecd79d4071fec
Optimize db.floating_ip_deallocate

'select for update' and 'update' operations
were combined into a single 'update' operation

problems with 'select for update' relate to
spec https://review.openstack.org/#/c/97310/1

now 'floating_ip_deallocate' function returns
number of updated rows in db

Partial-Bug: #1343613

Change-Id: I60f5a8f3e1541983dea1589783927107c00c5fa4
Merge "Add valid method check for quota resources"