Prevent file injection writing to host filesystem.

Fix bug 1015531, CVE-2012-3360, CVE-2012-3361

This patch prevents the file injection code from writing into the host
filesystem if a user specifies a path for the injected file that
contains '..'. The check is to make sure that the final normalized path
that is about to be written to is within the mounted guest filesystem.

This is a backport of Russell Bryant, Pádraig Brady and Mark
McLoughlin's Folsom patch.

Change-Id: Id8bd6ffb4d878467ba2086d341fce23f2ff5aa0a
Stop nova_ipam_lib from changing the timeout setting

 * Fixes incorrect logic for when timeout should be used. We
   want to timeout along with dhcp, and release immediately
   without dhcp
 * Also makes ipam_lib release fixed_ips after floating ips, as
   this is the way that the internal network managers do it.
 * Fixes bug 1014769

Change-Id: I687fac314264b8a89da128ed77c02d9b1ca140ff
(cherry picked from commit 45e98d415ec661ba7772ed2513f2a24ebe68f1dd)
ensure atomic manipulation of libvirt disk images

This pattern could probably be used elsewhere,
but only libvirt disk images are considered for now.
This change ensures there are no stale files left
anywhere in the path from glance, through the libvirt image cache.
These could cause subsequent operational errors either
directly or indirectly through disk wastage.

* nova/utils.py: Add a new remove_path_on_error() context manager
that is used to remove the passed PATH on a raised exception.
* nova/virt/images.py: Ensure temporary downloaded and
converted images are protected.
* nova/virt/libvirt/connection.py: Ensure all the images in
the image cache and instance dirs are protected.

Change-Id: I81a5407665a6998128c0dee41387ef00ebddeb4d
Ensure we don't access the net when building docs

(Note, this has not been sent upstream)

Change-Id: I9d02fb4053a8106672aded1614a2850e21603eb2
fix useexisting deprecation warnings

Fixes deprecation warnings when using sqlalchemy >= 0.7.0
Fixes bug 941951

Change-Id: Iaa57153f99c60c67a14c1dca849188937bdc5dee
support a configurable libvirt injection partition

This is useful if all guest images have the same structure,
and the root partition is not the first partition.

This is also handy to enable inspection in libguestfs,
which can handle disparate and complicated image layouts.

In future we may change to a StrOpt to support
searching by partition label.

Change-Id: Ie94d61bec8fe4b41d6d2d6d3efa9a4364cf027fe

Conflicts:

	nova/virt/libvirt/connection.py
repeat fusermount to avoid business

Fix bug #1013689

Change-Id: I8ae786e105c08e1b5011a1b2a1dac048a710a1cb
only mount guest image once when injecting files

Previously we could incur the costly guest mount operation twice,
if injecting files with any of net, ssh keys, password, metadata.
Instead now inject files in the same operation.

Change-Id: I228da2229a19d9097507f67b697595616fa601fe
set correct SELinux context for injected ssh keys

Instruct guests to ensure at boot, that the correct
SELinux context is set for /root/.ssh/.
This will cater for keys injected by nova from hosts
without SELinux (enabled) or using libguestfs which
currently doesn't support setting extended attributes.

Suggested-by: David Naori <dnaori@redhat.com>
Change-Id: Ibf3869e3ee477e91623e0c030838c1ec8a6128a6
Distinguish over-quota for volume size and number.

Fixes LP 1020634

Ensure that exceeding the allowed number of volumes is not
mis-represented in log messages and exception handling as
excessive space usage.

Change-Id: I71ec995c77bc447bfc9221084b057bd8d69a4513