Remove admin auth when getting the list of Neutron API extensions.

Currently _refresh_neutron_extensions_cache() always authenticates
with Neutron using the configured Neutron admin credentials because
it doesn't have access to the calling context.  But it's actually
always called when a valid context exists, and the call to get the
list of extensions is not itself an admin operation.  By passing
the context down we can avoid this additional authentication step.

Change-Id: I9e7d9c5e424a6b39c8f8ee1c79f5fd8f48ad81a2
Closes-Bug: 1250850
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
Fix cache lock for image not consistent

Currently 2 external (file) locks with different name
are created to protect image concurrent access for libvirt driver.
This may lead to image corruption in rare case. This patch change
the lock file name from nova-_var_lib_nova_instances_base_xxxx
to nova-xxxx to make the lock name consistent

Change-Id: I3e60c3bcf456d2392409aa56ba05f4ad8fdc0444
Closes-Bug: #1265452
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
Call get_pgsql_connection_info from _test_postgresql_opportunistically

The _test_postgresql_opportunistically method was calling the method to
parse the mysql connection URL which is wrong when there is one
specifically for postgresql, so call the right method.

This wasn't causing issues obviously but is something that needs to be
cleaned up regardless.

Closes-Bug: #1274718

Change-Id: Ic572e612c7ce31d854dc7258aa9c8b89a197260e
Add missing translation support

A log message was missing the translation support.

Change-Id: Ib4320a7fe1609c6cf33835f9873a2ddbda211c8c
Add super call to db Base class

Without this call, multiple inheritance involving the db Base
class does not work correctly.

Change-Id: Iac6b99d34f00babb8b66fede4977bf75f0ed61d4
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
Guard against oversize flavor rxtx_factor float

We now check that rxtx_factor provided is not greater than
the Float type to be stored in the db. While the check is not
100% accurate due to float approximation it will be very
close to the max allowable. A 400 error is returned if the
provided value is too big.

Closes-Bug: 1259213
Change-Id: I72c52fa46d75275c45e72b6f5a36106d5abf8220
Co-authored-by: Takashi Natsume <natsume.takashi@lab.ntt.co.jp>
Objectify instance_action for cell scheduler

This is a refactor change to make cell scheduler use InstanceAction
class method instead of compute_utils, so that all instance action can
be manipulated through object model and instance action related code in
compute_utils can be deprecated.

This is a part of: blueprint make-instance-action-use-objects
Change-Id: I920c8bf809200e6fc2c0329c11ea4be94dc71158
Refactoring metadata/base

- Extracted out methods from get_openstack_item for handling version, content and path
- Replaced the if else style route configuration with a route configuration dict
- This will help adding new apis easier and be maintainable

Change-Id: Ie1885c439f3d119032dd1c7c7af070142987ba7f
Partially implements: blueprint metadata-service-callbacks
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
Replace detail for explanation msgs on webob exceptions.

When using detail=msg, a default msg is set and returned.
To let the user know the real cause of the error explanation arg
shall be set with the appropiate error message.

[For example]
$nova --os-compute-api-version 3 service-disable --reason 'A...' host srv
"The server could not comply with the request since it is either malformed
or otherwise incorrect."

By setting the explanation we get:
$nova --os-compute-api-version 3 service-disable --reason 'A...' host srv
ERROR: Disabled reason contains invalid characters or is too long

Change-Id: I380916b110cd021aefcbedd2f943155329860fe7
Fix the sample and unittest params of v3 scheduler-hints

The API samples of scheduler-hints contains "hypervisor" and "near"
attributes, but the attributes do not exist in the scheduler-hints
parameter of "create a server" API. This patch changes them to the
existing "same_host" attribute.
This patch also changes the attributes of some unit tests of the v3
scheduler-hints by the same attribute.

This nonexistent attributes are found during bp/nova-api-validation-fw
works. The implementation needs this change because it will deny the
unexpected attributes, which are not defined with API schema, in API
parameters.

DocImpact
Closes-Bug: #1278279

Change-Id: I8542f44b325ba909fdff8b569146c0015b150291
Prefix private methods with _ in docker driver

Private methods should be prefixed with a _ for
clarity. Although most private methods were
marked this way, a few were not.

Renames and marks private:
 is_daemon_running
 find_container_by_name
 get_available_resource

Closes-Bug: #1267664

Change-Id: Ifc6818b7620af972cc0eec6f9ef43610456895f1
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
Add mkfs to the baremetal-deploy-helper rootwrap

The nova-baremetal-deploy-helper uses the mkfs command to
format the ephemeral partition (if configured). The
command works today because it is also defined in the
compute.filters file but we should be explicit here.

Change-Id: I79c31ffd26ff92d35d3d9836f2a8954a9a07c2c0
Add comment/doc about utils.mkfs in rootwrap

We call mkfs in nova/utils.py as well. Updates
the rootwrap file so we document this.

Change-Id: I58a3f4686735f45ee1aafe698f6662ff9d70e1f1