Policy check for forced_host should be before the instance is created

Move the policy enforcment for force_host and force_node into the
_handle_az() method so that any violation of policy is detected before
the DB entry for the instance is created.

Fixes bug: 1220220

Change-Id: Iaf6df4f8df6cca71fcb860244ccf758d7908b8f1
VMware: Fix volume detach failure

The VMwareVCDriver method "detach_volume" is missing the "encryption"
argument and thus does not conform to the driver API. Adding the missing
argument solves TypeError being thrown when detaching a volume.

Change-Id: Ib785c2b2cf4c25deed272f8e3f0f47abe6139d1c
Closes-Bug: #1226826
Replace OpenStack LLC with OpenStack Foundation

Change-Id: I5203554989bc7244cff2899d52c5764360bba60c
Fixes-Bug: #1214176
Add tests for pre_live_migration

Add tests to ensure retrying plug_vifs in pre_live_migration works.

Closes-bug: #1228749
Change-Id: I80d4cdc27836511c55b2555556edd7a1964c7158
Make Instance.refresh() extra careful about recursive loads

This simply makes sure that the instance copy that we fetch to
refresh an instance can not trigger lazy loads itself due to
a bug in get_by_uuid() or below. This hasn't actually been the
cause of any recent bugs, but this makes it much more careful.

It also makes sure that obj_load_attr() refuses to do its work
if self._context is None, which was previously only being
enforced for remoted calls.

Change-Id: I76f433af34620045b079e0a2c30c60b28a4ce525
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
Add notification for pause/unpause instance

When pause/unpause instance, there are no notifications, this
will cause someone cannot know when pause/unpause operation
would be finished.

All other instance operations do have notifications. We should
also add notification support for those two operations.

Change-Id: I5b8cc33a5992f5f028a3220217dcf7a0288d150d
Closes-Bug: #1043861
Skip test if sqlite3 not installed

The test is attempting to run the sqlite3 binary during its test run.
Since there's no guarantee that it's installed it should catch an
execution error and skip.

Change-Id: I9f4ed1872fcfe3b8393644a77692dbfcce8ecab2
Closes-bug: 1227868
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
Full sync of quota_usages

Migration 203 added a user_id column to the quota_usages table.  Now
some usages are incremented/decremented on a per user basis but there
are preexisting usages stored with a NULL user, and some usages are
tracked per project but there are usages stored with a user_id.  These
quotas are never decremented leading to invalid quota limits being
enforced.

This migration performs a full sync of quotas, and removes the incorrect
rows for each resource type.

Change-Id: Iff96f81e36b135df94a6f25c9443d0e9333bd18f
Closes-Bug: #1212798
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
Fix indentation in virt.libvirt.blockinfo module

Fixes confusing indentation in is_disk_bus_valid_for_virt function where
leading 8 spaces were used instead of 4.

Change-Id: Ic320dc6860b1efa7464d631c4c649be13d7206a1
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
Merge "Full sync of quota_usages"
Merge "Policy check for forced_host should be before the instance is created"
VMware: fix bug for invalid data access

Ensure that propSet exists prior to reading the propSet value.

Closes-Bug: #1233161

Change-Id: I667d6fb7618b09f6e43f3b3e7f69d5db914324fc