Make exception message more friendly

Exceptions that get returned via REST api
should have more user friendly message,
users shouldn't have to know backend concept.
more detail,see bug.

Change-Id: Idc20680e46c36fa3441838177ce61b6f5e1d2979
Closes-Bug: #1263204
Catch NotImplementedError in get_spice_console in v2/v3 API

Currently get_spice_console doesn't catch NotImpelementedError
and it will lead to inaccurate information returned back
to API caller. This patch adds the catch exception routine and
returns a HTTPNotImplemented excpetion.

Closes-Bug: #1279195
Change-Id: I16cb0a83c0e1aa9a041dd21af324a39388ca3bb8
Clean IMAGE_SNAPSHOT_PENDING state on compute manager start up

There is a slim possibility that an instance will make it into the
state IMAGE_SNAPSHOT_PENDING  and get to the compute host just prior
to the stopping/failure of the compute service, this will result
in the instance being stuck in this state after the service resumes
and will prevent further actions on the instace by the user.

This change clears this state on start-up. Worst case it may result
in the request to snapshot being lost which will require the user to
re-request but I think this is preferable to leaving the instance in
a transitional state that the user cannot clear.

Related to blueprint recover-stuck-state

Change-Id: I8a4867f1f96d61e7d614d7d27c91f3d3e46f2400
Remove unused methods

 o nova/cells/messaging.py
   - def _at_max_hop_count(self, do_raise=True):

     This method was added in the following commit.

        commit f9a868e86ce11f786538547c301b805bd68a1697
        Author: Chris Behrens <cbehrens@codestud.com>
        Date:   Fri Apr 13 05:54:48 2012 +0000

            Cells: Add the main code.

     But there is no evidence that was used.

 o nova/virt/disk/mount/nbd.py
   - def _read_pid_file(self, pidfile):

     This method was added in the following commit.

        commit e4377fdb0ef2087a36d2b1fbee96543f735040de
        Author: Michael Still <michael.still@canonical.com>
        Date:   Wed Dec 12 17:13:53 2012 +1100

            Stop nbd leaks, remove pid race.

     But there is no evidence that was used.

 o nova/virt/hyperv/imagecache.py
   - def _validate_vhd_image(self, vhd_path):

     This method was removed in the following commit.

        commit 689e9e3e3d48928fe950b26745a7df6fee2f0718
        Author: Alessandro Pilotti <ap@pilotti.it>
        Date:   Mon Mar 4 11:34:42 2013 +0200

            Fixes disk size issue during image boot on Hyper-V

 o nova/virt/hyperv/vmutils.py
   - def _clone_wmi_obj(self, wmi_class, wmi_obj):

     This method was removed in the following commit.

        commit d1a2e108695690b66376d406d4a5038c09c84335
        Author: Alessandro Pilotti <apilotti@cloudbasesolutions.com>
        Date:   Tue Jul 30 03:58:11 2013 +0300

            Improves Hyper-V vmutils module for subclassing

 o nova/virt/libvirt/firewall.py
   - def _define_filters(self, filter_name, filter_children):

     This method was removed in the following commit.

        commit b4fae4821fd2d4f31c0c03bdf2e65c984f42e01d
        Author: Yaguang Tang <heut2008@gmail.com>
        Date:   Tue Feb 14 10:43:39 2012 +0800

            remove unused nwfilter methods and tests.

 o nova/virt/xenapi/volume_utils.py
   - def _get_volume_id(path_or_id):

     This method was removed in the following commit.

        commit 503d5729547f135951d75d5237b398fe1700aaf2
        Author: Armando Migliaccio <amigliaccio@internap.com>
        Date:   Fri Dec 7 21:06:43 2012 +0000

           Fixes KeyError: 'sr_uuid' when booting from volume on xenapi

Change-Id: I216f7c4ff3546c41e1fb0813a71a6c7ff9498584
Typo in the name 'libvirt_snapshot_compression'

Typo was introduced in 1c5048b2d73289283d062066d94cee30e19db717

Change-Id: I79ded4a517072b551280fe487a672bd396c2e44d
Serialize the notification payload in json

When a notification payload is passed to the oslo.messaging the
payload must be correctly serialized.

This change encode the payload into json as the old rpc did.

Closes bug: #1279881

Change-Id: I99fc2a4b0e0146c9faa6abeddbd15cb24169e024
libvirt: adding a random number generator device to instances

In order for the virtio-rng device to be added to KVM instance,
hw_rng=virtio property should be set in Glance image metadata:

glance image-update \
       --property hw_rng_model=virtio \
       [image]

The cloud administrator will have the option to limit
or disable the use of this device by setting the following flavour
extra_specs:

hw_rng:allowed=True - Allow virtio-rng to be added to instances.
hw_rng:rate_bytes - The allowed amount of bytes for the the guest
                    to read from the host’s entropy per period.
hw_rng:rate_period - Sets the duration of a read period in seconds.

DocImpact
Partially implements blueprint libvirt-rng-device

Change-Id: I022e322a7c414e9d618e60c2879aee903732581d
Use instance object for delete

I was just checking to see where db.instance_destroy() was used and it appears
that this is the last case of using the db api directly for an instance destroy.
Convert it over to use the instance object method.

This patch also includes a unit test fix.  A stub had to be updated to account
for this change.  It turns out that the test wasn't actually verifying that the
stub was being called, though.

Part of blueprint icehouse-objects

Change-Id: Iaea4e8b46c90f3762b5f458acee024e14bfa974e
VMware: fix the VNC port allocation

There is small chance for VNC port collisions with the current
implementation which choose the port number based on the MoRef id
of the VM.
This patch fixes this by running a query for all allocated ports
and then selects one which is not taken.

Change-Id: If7c3b14dd49ed05c5fde819c5a36d5608650cbbc
Closes-Bug: #1255609
compute: invalid gettext message format

The message passed to gettext has an invalid format.

Change-Id: Id87659499ef7e73f3d60b458959ba06d4838273d
VMware: add a test for driver capabilities

Check the values of the driver capability flags.

Change-Id: If1b18c0a48efd90d6b3c113f73457c1d0f552bb1
libvirt: host specific virtio-rng backend

Users will be able to select an alternative source of entropy on the host,
by providing a path to the alternative device in nova.conf, instead of the
default /dev/random:

    rng_dev_path=/dev/hwrng

DocImpact
Partially implements blueprint libvirt-rng-device
Change-Id: Ibc2d1e9839ae2f5aeca14fbe966e8bc7c4427714
Merge "compute: invalid gettext message format"
Merge "Use instance object for delete"
Merge "libvirt: adding a random number generator device to instances"
Merge "VMware: fix the VNC port allocation"
Pass instance object to soft_delete() and get_info()

This makes compute manager pass an instance object to the
virt driver's soft_delete() and get_info method instead of a
dict primitive.

Related to blueprint virt-objects

Change-Id: I52aae532c08596d7a78a3e75f8b0869951fc8991
Make interface attach and detach use objects

This makes the api pass instance objects to interface attach and
detach calls.

Related to blueprint virt-objects
Related to blueprint compute-manager-objects

Change-Id: Iddb21fb5c733b06a7ceba67ae4e48a3bf6e157fb
Document virt driver methods that take Instance objects

This catches the virt driver base class' docstrings up with the
current state of support in manager for passing objects.

Related to blueprint virt-objects

Change-Id: Ifc358b5e513a3194785fa83ffe7660b88de6e10a
Merge "Make exception message more friendly"