Use disk image path to setup lxc and uml container

fix bug 1079113

Change-Id: I9b9b10e77728d4d7863f49efc048c8a37b06953b
nova-manage doesn't validate key to update the quota

nova-manage doesn't validate the key value supplied to
update the quota, as a result unnecessary records will be
created in db and user will be under the impression that
quota value got updated.
This patch validates the input value given to the key.

fixes bug 1064359
Change-Id: I9928f30881aa2780a23005b5f69aa67a44f314c5
(cherry picked from commit 82d8ffec5b5220039e57685fe4359950d1209b14)
Set instance host field after resource claim

Set the 'host' field on the instance after the resource tracker
on the compute node has accepted the build.

The field is set after resources are confirmed to be available while the
COMPUTE_RESOURCES_SEMAPHORE is held.  The semaphore ensures the
resources usage values will be consistent even if the
update_available_resource periodic task audit runs.

bug 1060255

(cherry picked from commit 5fd7a9dba127bae812333196a5fa48a933212aeb)

Also includes the following bugfix to the original patch:

Set host prior to allocating network information.

Make sure 'host' field on the instance is set before allocating
network information.

bug 1065004

(cherry picked from commit 2649f14673f8ef5ca257583f1cdf5fe57d4734b9)
Change-Id: I92105ec14924960ac8ef7ca8c810783085314e10
Deallocate network if instance is deleted in spawn

If the instance is deleted while the virt driver is spawning, an
InstanceNotFound exception is raised and caught in compute to prevent it
from being rescheduled. This also deallocates the network to prevent
leaking interfaces/mac/ips.

* Fixes LP1068716

Change-Id: I991f5956facf7b105faea137d4a5b48897e68ae6
(cherry picked from commit c27558518800322bd13de5d6bd58bffba4e1a92f)
Update kernel_id and ramdisk_id while rebuilding instance

While rebuilding an instances if kernel_id and ramdisk_id associated
with new image_ref then update instances table for instance_id
with the new kernel and ramdisk.

Fixes bug 1060925

Change-Id: I07dfdbed8580411adea14fd6c5be1a9569a7a021
(cherry picked from commit c781e90929a6b3c39c0528a864cf560a5a8999e2)
Save exceptions earlier in finish_resize

Fixes bug 1071595

When catching exceptions, _quota_rollback is called before we save an
exception for re-raising later.  Also: we should ignore any possible
exceptions from _quota_rollback so we are sure to set instance to error.

Change-Id: I50cb4879f7dcc13f99fa23a45030b4140dfc326a
(cherry picked from commit 50a0f3efb6cc4ae9c94439eea346828d35080d6c)
Fix typo so setting volume_tmp_dir works

apply the same change that was applied to cinder
https://review.openstack.org/#/c/14863/

Fixes LP bug #1071536

Change-Id: I4cfdb38debfcb4a890c2d7fd7405ac9dc755f0ec
(cherry picked from commit 3f1af292f4771a384230ec80c32f2d253cef8bc1)
Always use bdm in instance_block_mapping on Xen

It doesn't seem that Xen will set the 'root_device_name' property on
instances.  This is causing instance_block_mapping to return early
without evaluating the bdm before returning the list of device_names
in use.  I'm not sure why instance_block_mapping does this
(optimization?) but on Xen at least it seems that it should not.

Added a check for Xen compute_driver flag in instance_block_mapping to
"guess" the root_device_name (similarlly to what is done in
compute.utils for swap and ephemeral).

fixes bug #1061944

Change-Id: If5b1a2b7377232c78f0629a3624552ecf6ceb0ee
(cherry picked from commit 07845ad68f83952bbae36b4b115ff6c433e81fa3)
Fix live migration volume assignment.

In pre_live_migration volumes should
get assigned (self.volume_api.initialize_connection)
to the live migration target host.
In post_live_migration the volumes should get
unassigned (self.volume_api.terminate_connection)
from the live migration source host.

Fixes bug 1066887

Change-Id: Ic2db456cd5efbdf15db92f843c92230489efc551
(cherry picked from commit 2543705986789658725aac808e85e2cb638ea3dd)
libvirt: persist volume attachments into config

When you attach a volume to a running instance, only the running
xml is updated in libvirt. This is due to the usage of the
VIRT_DOMAIN_AFFECT_CURRENT flag passed to attach device. What we
really want is to affect both the config and the running xml. There
is no combination of flags that works in all states, so we explicitly
set the right combination of flags depending on the running state
of the vm.

Includes a test to test_virt_drivers to ensure the flags are passed
correctly.

Fixes bug 1071069

Change-Id: I1992748b08daf99cf03dfeb0937ad42457fff1a3
(cherry picked from commit 814e7f8c827aa21a87a62594d5b6413bb49e31e1)
Pass elevated context to confirm resize

The actual fix for bug 1071600 is a bit too invasive to backport,
so this is a simpler fix that only changes one line.

Change-Id: I8901056b6216d3d1b945dbc06a66b5354c185076
Read deleted flavors when using to_xml()

Fixes bug 1073736

Extend get_instance_type to accept an optional flag to return inactive
flavors and use this within to_xml().

Change-Id: Id01724a85d9aff3b32b3502be06a84578fa8f4df
Cherry-Picked: d8970d6b780898b2a7f099af3a251b3f3a52010b
Encode consoleauth token in utf-8 to make it a str

Fix for lp:1057279.

Change-Id: I9da0fd42e919aca0075613c4930ebfc3cf425349
Compute doesn't set the 'host' field in instance

When an instance starts, compute ask the resource manager to check the
compute capabilities. If the compute resources are sufficient, the
resource manager updates the 'host' instance field in the database. But
the local variable 'instance' use by compute manger isn't updated.
So, when compute manager asks the network manager to allocate a network
for the instance, the 'host' instance field is null.

Some compute tests doesn't update the local variable instance when
they change some parameter on instance and failed with this patch.

Fixes LP bug #1073600

Change-Id: I842d4814b9eabc6222c68118d8a244b20bb68164
(cherry picked from commit d32d5b252fc6c71a19b5372defb468fee9c57d3a)
Merge "Use disk image path to setup lxc and uml container" into stable/folsom
Truncate large console logs in libvirt.

Resolves bug 1081436 where they were returning a 5.5gb console log
to the user.

Change-Id: I0d98c83e801f8936d35789b5e8f8283f49483c4e
Merge "Encode consoleauth token in utf-8 to make it a str" into stable/folsom
Merge "Truncate large console logs in libvirt." into stable/folsom
Merge "Pass elevated context to confirm resize" into stable/folsom
Merge "Save exceptions earlier in finish_resize" into stable/folsom