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
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>
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 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
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
VMware: fix instance lookup against vSphere

Modifies the logic to search the vsphere vm for a given
instance. The change now makes use of the config.extraConfig
property to search for the instance.

Change-Id: Id11f44b9792f196ad627879d082ad829869efcdf
Closes-Bug: #1257038
Remove broken quota-classes API

It turns out os-quota-classes-sets never worked
(http://lists.openstack.org/pipermail/openstack-dev/2014-February/027574.html). Since this doesn't work no need to keep it around.

V3 removal: Id1f288baa723df825151bd84aa27089271c2b8e4
Original commit: I6b6477481187d16af225d33c1989430e4071d5a8

This patch just removes the API it doesn't remove the quota-class
internals, that will be done in a subsequent patch.

Change-Id: I1110022d6f628d03aaf363da707f2d2ef1600437
Fix comment typo in nova/compute/api.py

'NODE' should be 'NOTE'

Change-Id: I47b9d8d796882b09350ec241a8f5d95b4ea9dd28
Closes-bug: 1285519
Cleanup v3 test_versions

This commit removes duplicate codes for clarifying what this test
verifies.

Change-Id: I5f6e06dbb0e612981528d89b61b2a8a025e984f1
Use image from the api in run_instance, if present

When booting an instance, the API layer already fetches the image
from glance and passes it to the compute manager. Right now, that
info is ignored and the compute node has fetches the image metadata
again from glance if booting from an image. This is a problem when
booting from a volume, because most of the properties that the volume
keeps when it has been created from an image won't be considered.

With this patch, the image metadata passed to run_instance from the API
will be used if present instead of asking glance again.

Change-Id: I4680d9d309d7a09f64d52ef0fb105282ace79e5f
Closes-Bug: 1281973
Catch HostBinaryNotFound exception when updating a service

When updating a service with a wrong host or binary name,
HostBinaryNotFound exception is raised. However this exception
isn't caught and the ServiceNotFound exception which won't happen
here is caught instead.
This patch fixes this bug.

Change-Id: I64b138bad74c39d087addcd766b890c4076a2ce8
Closes-Bug: #1273139
libvirt: setting a correct driver name for iscsi volumes

Setting LibvirtISCSIVolumeDriver class to be identified
as a block device to determine the correct driver name.

Change-Id: Idfb89d051ccadab1d4c4b05b817b085e094ff992
Closes-Bug: #1273496
libvirt: remove explicit /dev/random rng default

libvirt (or rather qemu) will default to /dev/random if no rng device
path is specified i.e.

  <rng model='virtio'>
    <backend model='random'/>
  </rng>

It's preferable for us to not duplicate this default to allow for a
future where libvirt or the hypervisor needs to make more intelligent
decisions about the default device to use.

Also, improve the unit tests to catch this issue.

Change-Id: Ia0f922f7de575496972b4dfa9d56aa22205f1758
Clean up _make_*_list in object models to use base.obj_make_list

There are a lot of places where _make_foo_list()s are implemented.
Actually base.obj_make_list() can be used to make the list.

The patch is to clean up the redundancies and make the code clean.

Also, in order to make _from_db_objects()s the same format, we add
'context' into the parameter list in instance fault object.

Related to blueprint icehouse-objects.

Change-Id: I1a68b6e9dc402d4e30a06f94b068233e2afa713f
Rewrite InstanceActionEvent object testcase using mock

This is a refactor change of rewriting InstanceActionEvent testcase
using mock for several follow-up changes to instance action objects.

Please Note 'test_finish' case against InstanceActionEvent object's
'finish' method has to be removed, as the action event object model
doesn't hold 'instance_uuid' information for now.

This is a part of: blueprint make-instance-action-use-objects

Change-Id: I0f4284995cd7afb4c5d1940a54996183be4eef8f
Remove trailing comma from sample JSON

The etc/nova/cells.json sample configuration file contains a trailing
comma on some elements. This is a syntax error, this change corrects the
problem.

Change-Id: I7a8200e8b7704e4377ce597d6beba91b42286469
Closes-bug: #1283718
Remove blank space after print

Check nova code, remove blank space after print.

Change-Id: I0d7f1ebe6e83189a51bf714a2f03afd8a91d515c
libvirt: image property variable already defined

A variable image_meta_prop with properties from a glance image
is already defined and can be used.

Change-Id: I5a3bab2d944c60ed744bbfc79fb9d5ad195c0d69