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
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
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 super call to db Base class

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

Change-Id: Iac6b99d34f00babb8b66fede4977bf75f0ed61d4
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>
correct the bugs reference url in man documents

All the bugs reference in nova man documents are incorrect.
Nova bugs are managed at launchpad, not the nova.openstack.org

Change-Id: Id5bbf09ad8ba079d4de959314123437031ded3ab
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
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 run_tests.sh lockutils when run with -d

Change I007bd39e4d9aad7539b4b7389eb5189b5d1f10e2 fixed how the test
runner was called, but did not take into account that a different
command line is used when -d flag is passed to the script. We fix that but
accounting for the lockuitls change even when -d is passed.

Change-Id: I7462b70a707fff281fabe9d9f20cbb7bf8d037ef
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
Explicity teardown on error in libguestfs setup()

Previously, in the setup method of the libguestfs driver
for Nova's VFS, on an error the handle object was simply
dereferenced (set to None), and then an new error was thrown.
This relied on an implicit close() on the handle being called
by GC.  However, in some cases the setup progresses far enough
that the implicit close is not enough, and leaves an "orphaned"
libguestfs VM.

Now, the teardown() method is called explicitly, which ensures that
no "orphaned" VMs are left around in case of an error.

Change-Id: I7fbe470046ce6c76bc13d77d8df360351a3ef715
Fixes: bug #1270304
changed quantum to neutron in vif-openstack

Change-Id: I50c14066584527a6fbc25c59b0bf03a321a5f1f5
Fix upper bound checking for flavor create parameters

Fix flavor-create upper bound checking so it uses platform-independent
32-bit max signed integer value instead of sys.maxint, which causes
problems on 64-bit platforms.  The DB int type is a 32-bit signed
integer, regardless of platform.

Change-Id: I82624121a45f6385d3ea9ae9c032109834584fac
Closes-bug: 1278939
Fixes the Hyper-V VolumeOpsTestCase base class

The VolumeOpsTestCase base class inherits incorrectly from
HyperVAPITestCase, with the unwanted side effect of executing all
base class tests as well.

This patch generalizes a common base class from HyperVAPITestCase
and fixes the inheritance issue.

Closes-Bug: #1280379

Change-Id: Ic81beb8397138c16c8d2d88a9c9d05d2b76e0e83
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
Ensure parent dir exists while injecting files

Currently, if we inject a file to a not existing path,
the injecting will be failed with error 'No such file
or directory'.
Nova will firstly execute `mkdir -p` in folsom before injecting,
but this operation is lost from commit
72918415f2b6a241d6097a563aba55a849936591

This patch fix this bug by adding the `mkdir -p` operation as folsom.

Closes-bug: #1272829

Change-Id: If33a79c538e07cb25300db64ac7a9dee3d3b19c2
Fix InstanceNotFound error in _delete_instance_files

Currently the cleanup_running_deleted_instances peroidic task
failed with InstanceNotFound exception, this is because the
db query is not including the deleted instance while
_delete_instance_files() in libvirt driver.

Closes-bug: #1280140

Change-Id: Ie65ff255ad3c582a71db93b07304a21d4976a193
Fix incorrect kwargs 'reason' for HTTPBadRequest

webob.exc.HTTPBadRequest doesn't have attribute 'reason', and its
__init__ method doesn't have such parameter too, so if we use such
kwargs, it will not be accepted by constructor of base class
WSGIHTTPException, then the http response body will format message
using default explanation instead of what we expected.

We should use kwargs 'explanation' instead of wrong 'reason'.

Change-Id: I02619164176a723e313ae274e527948d45fa6cad
Closes-Bug: #1264223