get_all_flavors uses id as key to be unique

Change I1b0c93b3e12714a5c0798aa87c9e3fe9bc14519a fixed returning
deleted flavors by changing the get_all_flavors dictionary key
away from 'name' to 'flavorid'. However flavorid is also not unique.

This patch fixes get_all_flavors to work properly using the 'id' as
the dictionary key. This allows flavors to be created with flavorid's
that were previously deleted and then have them all returned when
get_all_flavor(inactive=True) is used.

Fixes bug 1215295 properly

Change-Id: I357a804fe9f012143c996d66b9719c4f46f60e86
xenapi: reduce impact of errors during SR.scan

There are some race conditions in SR.scan leading to errors similar to:
* The SR scan failed [opterr=['MAP_DUPLICATE_KEY', 'VDI', 'sm_config',
  '$UUID', 'vhd-blocks']]
* The SR scan failed [opterr=['UUID_INVALID', 'VDI', '$UUID']]

This seems to be happening because an SR.scan is happening when a xenapi
plugin is modifying the SR at the same time.

To reduce the likely-hood of this error, I have added a mutex around
calls to SR.scan to ensure nova-compute never makes more than one call
at once, because XenServer will join any extra SR.scan requests to
listen to the result of any current SR.scan that may be running.

In addition, when and error occurs during an SR scan, I have added a
retry loop, to attempt to stop these races from impacting users.

Fixes bug 1221293
Change-Id: Ib83e6e0f4f7fab2058fe137e32934606c4fe8f7e
Update attach interface api to use new network model

Remove legacy network, mapping network info usage, use new
network model, update related unit tests for this change.

Closes-Bug: 1229517

Change-Id: Ibe4cbd025700aa0d73a6d4d19fbf8f0005509428
Use system locale for default request language

Remove en_US as the default language when no header is provided, and use
None instead. Upon translation None will be defaulted to system locale
as it was before API translation changes.

fixes bug 1214476

Change-Id: Ic33c94c29993ceb944d7c22d2e754cb938db7503
Refactor test cases related to instance object

After the blueprint unified-object-model, all of the instances
should be represented by an instance object but not a db
instance dict.

In some test cases, they are still using db instance dict,
we should change those test cases to use instance object.

The fix include three parts:
1) Add a new stub method fake_fault_obj in
nova/tests/fake_instance.py to help convert a dict fault to an
object fault.
2) Add a new stub method fake_instance_obj in
nova/tests/fake_instance.py to help convert a dict instance to
an object instance.
3) Make sure all test cases related to "fault" and "instance" passed.

Closes-Bug 1230125
Partial-Bug 1212915

Change-Id: Ie54fface139e4ad042b9a748c7409c3698875413
Fix loading instance fault in servers view

If VM schedule failed, then VM will be set to ERROR state,
but "nova show" does not show the fault of the VM.

The fix use lazy load to get instance fault if the instance
went to ERROR state.

Closes-Bug: #1212915

Change-Id: If286fd0176be8307c50b2a7c3534fff33fa5c10f
Update jsonutils.py from oslo

This fix is related to oslo-incubator commits:
3d7504b7d131fd506304c00e131ffbe821f5f992
bdef862c7b196fd6aceb081b30778a2562180264
ded9bd6d7ca88f775c0a82b8a0b7f8a1603bc1cb

Related-Bug: #1229204

Change-Id: I212c777cb8c3ca35c2f83508bd762fe31e6b9c10
VMWare: Disabling linked clone doesn't cache images

This fixes an issue when use_linked_clone is false and the image is
already in the cache.  The problem was that the image would be
copied from glance into the instance directory even if it was already
in the cache.  This change checks if the file is in the cache, only
copies from glance if it is not, and copies the image from the cache
into the instance directory if use_linked_clone is false.

Fixes: bug #1207064
Change-Id: Idfa59eb0eb26cce52ff59f97e433deeab6510215
VMware: fix bug for invalid data access

Ensure that propSet exists prior to reading the propSet value.

Closes-Bug: #1233161

Change-Id: I667d6fb7618b09f6e43f3b3e7f69d5db914324fc
Make Exception.format_message aware of Messages

Many API extensions are casting NovaExceptions
directly to unicode with format_message(),
which results in a loss of localization information
from the possibly wrapped Message objects.

This change lets Messages be returned from
NovaException.format_message() if possible, which
will then be translated and resolved to unicode
later when needed.

fixes bug 1229410

Change-Id: I818a35b1d7d910c4f058d870e69c5ff73e45c6bb
Merge "Refactor test cases related to instance object"
Merge "Fix loading instance fault in servers view"
Merge "Update attach interface api to use new network model"
Merge "get_all_flavors uses id as key to be unique"
Merge "VMware: fix bug for invalid data access"
Merge "Update jsonutils.py from oslo"
Merge "Make Exception.format_message aware of Messages"
Merge "Use system locale for default request language"
Merge "xenapi: reduce impact of errors during SR.scan"
Merge "VMWare: Disabling linked clone doesn't cache images"