Fix incorrect root partition size and compatible volume name

When using rbd backend, it needs to resize volume size if size presents. Else
we will get wrong image size.

Rbd volume always uses uuid as the main pattern of volume name, now change to
it is necessary.

Fix bug 1219658

Change-Id: I3dc8d639b066eac35d190b8d4687c41c9f4d5824
(cherry picked from commit 1b66a47b5f4cbcdf1a9a1ec38532474588a3fee2)

Upstream-review: https://review.openstack.org/#/c/87455/
Not-in-upstream: yet
Partial-rally-bug: DE727
Partial-rally-bug: DE642
make rbd usable for ephemeral storage

Currently when using rbd as an image backend, nova downloads the
glance image to local disk and then copies it again into rbd.  This
can be very slow for large images, and wastes bandwidth as well as
disk space.

When the glance image is stored in the same ceph cluster, the data is
being pulled out and pushed back in unnecessarily. Instead, create a
copy-on-write clone of the image. This is a fast, and does not depend
on the size of the image. Instead of taking minutes, booting takes
seconds, and is not limited by the disk copy.

Add a direct_fetch() method to the image backend, so backends
like rbd can make optimizations like this. Try to use direct_fetch()
for the root disk when it comes from an image, but fall back to
fetch_to_raw() if direct_fetch() fails.

The majority of this code was taken from the cinder rbd driver.
The only new parts are the direct_fetch() method for the image
backend, and the small backwards-compatible interfaces changes
needed to make use of it.

fixes bug 1226351

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>

Change-Id: Ic9b9fbcb6e133cc9315581354f1b70ed7c9909ad

Closes-Bug: 1226351
Abandoned-upstream-review: https://review.openstack.org/#/c/46879/
Not-in-upstream: true
Partial-rally-bug: DE727
Partial-rally-bug: DE642
imagebackend: make verify_base_size() behave for rbd

verify_base_size() calls disk.get_disk_size(), which assumes the disk
is stored locally.

Instead of calling disk.get_disk_size() directly from
verify_base_size(), add a new method that is overridden by the Rbd
subclass to get the disk size.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>

Not-in-upstream: true
Partial-rally-bug: DE727
Partial-rally-bug: DE642
Add max_size to direct_fetch

Not-in-upstream: true
Partial-rally-bug: DE727
Partial-rally-bug: DE642
Improve shared storage checks for live migration

Distinguish cases that require shared instance drive and shared libvirt
instance directory. Reflect the fact that RBD backed instances have
shared instance drive (and no shared libvirt instance directory) in the
relevant conditionals.

Not-in-upstream: true
Partial-rally-bug: DE727
Partial-rally-bug: DE642

Note that a derivitive of this has been committed to upstream/master
in Juno and it should therefore be safe to drop this patch
after Icehouse: https://review.openstack.org/#/c/91722/
Fix dictionary update and key issues, update tests

Not-in-upstream: true
Partial-rally-bug: DE727
Partial-rally-bug: DE642
Pass rbd_user id and conf path  as part of RBD URI for qemu-img

Unlike rados.py, qemu-img does not use id from CEPH_ARGS and has to be
given a ceph user id and conf path explicitly in RBD URI

Closes-Bug: #1261675
Change-Id: I9226515f2a860ed45d12012fd5b6bc7e842f6d32
(cherry picked from commit 9e7e8daa66f0c05ac7ce3927562d246baf70067f)

Upstream-review: https://review.openstack.org/#/c/62592/
imagebackend: import rbd options

This makes unit tests happy

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>

Not-in-upstream: true
Partial-rally-bug: DE727
Partial-rally-bug: DE642
imagebackend: handle iso images correctly with rbd

iso images are raw from qemu's perspective, so
allow cloning them. They just need to be exposed to
the guest as cdroms instead of disks.

This is handled by the disk config's source_device
attribute, not device_type. Use the correct attribute
in libvirt_info().

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>

Not-in-upstream: true
Partial-rally-bug: DE727
Partial-rally-bug: DE642
Merge pull request #10 from CiscoSystems/cis-havana-rbd-eph

Cherrypick RBD commits
Network: ensure that ports are 'unset' when instance is deleted

Commit a141206e9dfd31955b9b31d9e5a7f73bbd8510ca ensured that user defined
ports were not deleted when an instance is deleted or rescheduled. The
problem with this commit is that it did not reset the 'device_id' and
'device_owner' of the port. This leads to port leakage and eventually a tenant
is unable to launch any instances as their port quota has exceeded the
allocated amount.

The solution is for the deallocation to reset the 'device_id' and the
'device_owner' of the port. This is allocated when the port is actually assigned
to an instance.

In the case of minesweeper (which runs on OpenStack), the tenant was leaking ports.
The root cause was that the user defined ports were assigned to a specific instance,
which was deleted, as a result of a failed reschedule (which is legitimate).

When an instance is deleted all artificats of that instance should be reset on the
port.

Change-Id: Ie1516c299ce6d79faf2d5103a14d6d8931d3ede2
Closes-bug: #1321381
(cherry picked from commit 803d59e9f409a59403b2ce55040acc02e14eee28)

Conflicts:
	nova/tests/network/test_neutronv2.py
Merge pull request #11 from CiscoSystems/bugs/1276510

Network: ensure that ports are 'unset' when instance is deleted
Merge remote-tracking branch 'origin/cis-havana-staging' into cis-havana

Conflicts:
	nova/virt/libvirt/imagebackend.py