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
Add support for user_id based authentication with Neutron

Keystone v3 supports non-unique project/user names, so until
the Neutron client provides support for the V3 API and domain
based authentication Nova should allow user ID for admin
authentication.

Change-Id: Idad27ff4206d6ba0bb9aedbbff5172c3144ad3c6
DocImpact: Adds new flag, neutron.admin_user_id
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
Remove pause/unpause NotImplementedError API layer

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, so catch and handle the exception is useless
and error leading. This patch removes code in API layer for
pause and unpause functions.

Change-Id: I7cbb8179b3eec8496b90ff5cf07397522d52c5de
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
Add instanceset info to StopInstance response

Currently stopinstance response missing the instanceset
information with InstanceID, current state and previous
state details. It just returns the "True".

As per the AWS EC2 API reference document, the StopInstance
response elements should include the instanceset information
as below:
<StopInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
  <requestId>req-a7326465-5ce2-4ed6-ab89-394b38cca85f</requestId>
  <instancesSet>
    <item>
      <instanceId>i-00000001</instanceId>
      <currentState>
        <code>80</code>
        <name>stopped</name>
      </currentState>
      <previousState>
        <code>16</code>
        <name>running</name>
      </previousState>
    </item>
  </instancesSet>
</StopInstancesResponse>

Included the instanceset into stopinstance response elements
and updated the test cases for stopinstance response elements
in nova/tests/api/ec2/test_cloud.py file.

Closes-bug: #1321239

Change-Id: I4d8a6faf2689a7df71920183682fd1e403ce2a42
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
Send compute.instance.create.end after launched_at is set

Downstream consumers of notifications want to know when an instance was
launched from the compute.instance.create.end notification.  This value
was previously set in the notification but commit
70196c4854e6cc1cb566dc9fc5b1a3397a4b69ab changed things so that it was
no longer set.  It will now be set, and is tested to be set.

Change-Id: If5ac00529d52e3898cda7fd942535ed3ba2039d5
Closes-bug: 1338736
Don't remove delete_on_terminate volumes on a reschedule

When cleaning up volumes before a reschedule if delete_on_terminate is
True the volume would be deleted.  That's not the desired behavior so
the volume cleanup has been moved to take place when a build is aborted.

Change-Id: I142370c0555495b4d51736f4f6b8070a3c112a59
Closes-bug: #1336127
Add instance to debug log at compute api

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

Change-Id: Icbe8e45ace74b8bf0282cf6d6dd1ead792532961
Remove translation for debug message

Remove translation for debug message in neutron api layer.

Change-Id: I5b3ce1115d8f2c46f6c144f21e735a45f338cb32
Commit quota when deallocate floating ip

It seems that when you allocate a floating-ip in a tenant with nova-network,
its quota is never returned after calling 'nova floating-ip-delete'
even though 'nova floating-ip-list' shows it gone.
This behavior applies to each tenant individually. The gate tests are passing
because they all run with tenant isolation.

The root cause of the problem is cooperation between
commit 23a27e47 and cbbb9de5. db layer code return floatingip_ref
but object layer didn't. This patch fixed the problem by adding return
value from object layer.

Change-Id: Ide1a338b6c33676311028e8738150e146324a8ee
Closes-Bug: #1347156
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
Downgrade the warn log in network to debug

Downgrade the log from warn to debug for overquota.
Didn't remove it because it's called internally and it might
be helpful for operater to take a look.

Change-Id: I1d3c27a8d97085d9919180a28018b234392f28e4
Add context as param to cleanup function

In nova-network, when we start
to cleanup the stuffs it did when handle exception
but the function is following in objects/fixed_ips.py
def disassociate(self, context):
so the context param is lost and it can lead to problem.

Change-Id: I66a1681f47fc69bf0fd92137ee27481659833bef
Closes-Bug: #1350268
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