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
Baremetal driver: remove unused states

NULL and INIT were not used since commit c20110d15be37948ddd9ef5f38001328aabf5b1d

Change-Id: I25c34872b100807d691e7e15f7b70be7ad1912b9
Skip none value attributes for ec2 image bdm output.

Fix crash in _format_block_device_mapping when there are None values
for formatting attributes in the mapping.

Change-Id: I0ebdb844d75cdf1580cc88e1ff40fc21aff96f21
Closes-Bug: #1323403
Do not fail cell's instance deletion, if it's missing info_cache

Currently the methods in cell messaging are trying to refresh the
instance. However, in some corner cases info_cache is not being
created for instances in ERROR state. This makes the delete
operation, of such instances, to fail, while it should not.

Handling the InstanceInfoCacheNotFound exception and not
re-raising it, for delete operations.

Closes-Bug: #1316373
Change-Id: I33c33e3ac1180e8293d950d60fb126e325a2c0cf
Make compute api use util.check_string_length

Make some string variables check in compute use util.check_string_length
instead of checking by itself

Change-Id: I9a5d4f647611aa00bed44afdeda5763f8fa9c35b
Prepend '/dev/' to supplied dev names in the API

Make sure that all user input device names end up in the database with
the '/dev/' prefix. This will make things more consistent and avoid
issues when attempting to parse device names.

This includes two main sources - block device mapping that can be passed
as part of a request or as image metadata, and root device name, passed
as image metadata.

Closes-bug: #1337821
Change-Id: Ibda82f511be99f1a68f2f77c72601a1b006be7a0
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
Security groups: add missing translation

Commit d562012f34eadfe6b68dd5ebe06a2fa565de3b2e added exceptions
that were not translated.

Change-Id: I06dbd32a9bc6d99068e06576e4ea7a8594764db5
Add instance to debug log at compute api

Add instance info to 2 debug logs at compute api layer.

Change-Id: Icbe8e45ace74b8bf0282cf6d6dd1ead792532961
Implement methods to modify volume metadata.

There are four methods in nova/volume/cinder.py which are
NotImplemented. They are as follows:
  1. get_volume_metadata
  2. delete_volume_metadata
  3. update_volume_metadata
  4. get_volume_metadata_value
These methods are required in cases where nova needs to modify
a cinder volume's metadata, e.g. attach and detach time. It also
completes the cinder.API class.

Change-Id: I360076ae28db43e661466f556425947813c9040e
Closes-Bug: #1296164
Remove translation for debug message

Remove translation for debug message in neutron api layer.

Change-Id: I5b3ce1115d8f2c46f6c144f21e735a45f338cb32
Remove rescue/unrescue NotImplementedError handle

There are 2 kinds of RPC call from API layer to compute layer,
one is cast and another is call. For cast, the RPC message will
be posted and the API service will not wait for the message to
be processed. So it won't be able to catch the exception raised
in compute layer and catch and handle the exception is useless
and error leading. This patch removes code in API layer for
rescue and unrescue functions.

Change-Id: Iab8070c25a9dee505c0602efad85c41c21c2aa58
Keep Migration status in automatic confirm-resize

function in compute/manager.py _poll_unconfirmed_resizes
will translate the migrate status from finished to error
whenever finds a problem ,Consider the following case

1) _poll_unconfirmed_resizes runs and founds several migrations to be confirmed
2) user deletes the instance, so its task state will be changed to DELETING
3) _poll_unconfirmed_resizes will find the task state is not None,
it will make the migration error status
4) following code in _delete
if instance.vm_state == vm_states.RESIZED:
self._confirm_resize_on_deleting(context, instance)
will fail because migration status already updated

User is able to do the migration operations when they found error
so we don't need to handle this kind of error for them

Change-Id: Ia79dd56c9c1fa8add7dc138d838cbfbac4523ac3
Closes-Bug: #1301696
Adjust audit logs to avoid negative mem/cpu info

we might have following audit info in the log:
AUDIT nova.compute.resource_tracker [-] Free ram (MB): -1559
AUDIT nova.compute.resource_tracker [-] Free disk (GB): 29
AUDIT nova.compute.resource_tracker [-] Free VCPUS: -3

which is really confusing to operater and useless
This patch adjust the log to print phy info and virtual cpus.

DocImpact

Change-Id: I2bc63e1aae0787bf976660eed8fd8899bfffe593
Closes-Bug: #1316916
Add debug log for availability zone filter

Sometimes operator need information why the host doesn't pass
the check of scheduler, this patch adds information for available
zone filter if the host doesn't belong to required available zone
and modify the logic a little to make it less nested.

Change-Id: Icb45182fa58d69e7c5e3a77ea31eddc492ac46ec
Partial-Bug: #1301830
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
Correct InvalidAggregateAction reason for Xen

Currently the xenapi will report InvalidAggregateAction
when add aggreate under some conditions. But the reason
didn't use the pre-defined reason list.

Change-Id: I2cd65f26097f154f1a4f794916c74cd1730ae142
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
Rollback quota in os_tenant_network

when we call API with 'os_tenant_networks' to delete an existing network
it might fail due to unexpected reason, we should rollback the
quota we reserved otherwise we will face no quota later.

Change-Id: Ic74a7a8df337070f17b1ea6916809fa93880a287
Closes-Bug: 1296489