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
Minor changes to make certificates test cases use HTTPRequestV3

The existing certificates test in v3 API version test correctly
but it use HTTPRequest keyword inside its test cases and has v2
keyword. Though it will not affect the test, change to HTTPRequestV3
will be helpful in the future.

Change-Id: I0992152e56a3f5b5972e48cb6cda16ef39cacdd2
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
Add missing translation support

A log message was missing the translation support.

Change-Id: Ib4320a7fe1609c6cf33835f9873a2ddbda211c8c
V2 Pause: treat case when driver does not implement the operation

Some virt drivers may not support this operation.

Same change will be added to V3 when https://review.openstack.org/#/c/58432
is merged.

Change-Id: I7763f462dd8f61c29c79038d881dc015482a9b5c
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
DB: logging exceptions should use save_and_reraise

Commit 384cce84fde784f9e2f39db49502c66e20ff0b4c added logging of an
exception. This should be done under save_and_reraise.

Change-Id: Ib0d29ac8c51c6df9ad27d75a06b2c8ce66182e0c
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
Emit message which merged user-supplied argument in log_handler

Sync from Oslo, change-id: I91289cc4a60f5dab89bca852e6f52b4b83831e47

When using PublishErrorsHandler, it will missing user-supplied arguments.
For example, do LOG.info("blabla %s", "foo"), the payload only contains
"blabla %s", but we expect it like "blabla foo". This patch fix it.

Change-Id: I375b0d83783b1866d3bf30ff3ade27e746bb856b
Closes-bug: #1278291
Fix import order in log_handler

Change-Id: I206adc29163a6e36501bf1d157f50ca2d0867507
Remove unused variables in the xenapi.vmops module

The local variables "current_chain" and "ctx" are assigned to but
never used.

Change-Id: I25bacd728bc5e00d768656c0b2aa657a2effda73
Make webob.exc.HTTPForbidden return correct message

Currently HTTPForbidden is using wrong parameter 'detail'
somewhere, while the correct parameter should be 'explanation'.
This patch fixes this bug.

Change-Id: I69bc3249f88e9cbf9add954571c21b07cf58f7c6
Closes-Bug: #1283872
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
Update ubuntu dev env instructions

I just set up an environment to run unit tests on Ubuntu and had to install a
couple of additional packages to make it work.  Update the instructions to
reflect that.

Change-Id: I2ceb1b130111991fa1b34b4636b8ece115e54084
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
Hyper-V log cleanups.

There were some cases where we could do a better job of passing the
instance through to the logging engine in a more consistent manner.

Change-Id: I4f97a04a24cd935d8bebe56d9984c54f84f9fb20
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