Remove admin context which is not needed.

_get_guest_config use admin context to read deleted flavor, it's
not needed because flavor function in db layer didn't require that.

Change-Id: Idbf6a7d712d432da5a5919c28e988870ead0d4b2
maint:Don't translate debug level logs

Our translation policy
(https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls
for not translating debug level logs. This helps to prioritize log
translation.
There were some commits that fixed it but ignored the the style like
msg = _('this is debug info'); LOG.debug(msg)
This commit fixes this style of LOG.debug.

Change-Id: I2cc3fe563456ba0906f74262ab1ba6967301d6d1
Fixed typos in nova.objects.base docstrings

Change-Id: I1d485a2ca2fca58262bc023e5c9f273c6632e4a6
Deduplicate some INFO and AUDIT level messages

I'm trying to debug a problem where the last thing in the logs is
"Starting instance...".  Unfortunately this occurs twice in the same
source file, so it's hard to figure out a priori which log statement
it came from.  Audit and info messages don't disambiguate their
function/line number, all you get is the logger name like:

2014-04-06 19:51:01.871 8288 AUDIT
  nova.compute.manager [req-...] [instance: ...] Starting instance...

I think it doesn't hurt to to make sure all logs at this level are
unique, even if upstream were to log the function (see [1]).  Most
duplicate LOG.info and LOG.audit level messages are in separate files
so we can disambiguate by the name, but there are a few that overlap.

For reference, the less-then-perfect but useful check I used was:
 $ grep -r 'LOG.audit' * | sed 's/:\s*/ /' | sort -k1 | uniq -f1 -c

[1] https://review.openstack.org/#/c/85638/

Change-Id: If1ff573ffed1d12fcadfbdfd3365aae68a5fb977
Truncate encoded instance message to 255

In nova/compute/utils.py function exception_to_dict truncates unicode
message to 255. However, in non-English locales, instance message may
be longer than 255 after encoding the unicode message to byte message.
Need to truncate the encoded byte message to 255, in order to ensure
db insert operation succeed.

Change-Id: I70cd2d6e4590ea95510c1ea3d51287f0dea14956
Closes-Bug: 1389102
Raise HTTPNotFound in V2 console extension

In case requested instance is not found, console extension does not catch
InstanceNotFound, which results to internal server error (500).

This patch handle InstanceNotFound exception and raise HTTPNotFound
like V3 console plugin.

Change-Id: Ia982049451f2c529f123da714e994476d4610491
Share console-auth-tokens tests between V2 & V2.1

As V2 and V2.1 'os-console-auth-tokens' extensions are same,
unit tests can be shared between those.

This patch share the tests between V2 & V2.1

Partially implements blueprint v2-on-v3-api

Change-Id: I9c1ff61ff73fee551a60a0ff684dd73a1bbad72e
Compute: Add start notification for resume

The resume operation did not have a 'start' and 'end'. This has
been updated. Notifications should be sent at the start and end
of each opertaion. The support should be consistant throughout
the driver.

Change-Id: I3354d1d9c01b13bc2fed70ee06875f6d49ff1d16
Virt: create an object InstanceInfo

The virt driver method get_info returns a distionary. This patch
introduces an object for the InstanceInfo.

Change-Id: Ia4e4639ec1a593380b48f8f6e4962dd22ab8fc0b
Virt: make use of the InstanceInfo object

This ensures that all drivers and the compute manager make use of
the instance info object and do not pass around random dictionaries.

Complete the blueprint instance-info-objects

Change-Id: Idab57d33e8612fcf40f54f73d5f73d813629bddf
Convert v3 console plugin to v2.1

This patch changes v3 console plugin to v2.1 and makes v2
unit tests share between v2 and v2.1.

The differences between v2 and v3 are described on the wiki page
https://wiki.openstack.org/wiki/NovaAPIv2tov3.

This patch also fix below issue in V2.1 console plugin-
 -  Remove try catch of 'InstanceNotFound' exception from V2.1
    console->index. This returns empty dict if non-existent server
    is specified. DB does not raise 'InstanceNotFound' exception.

Partially implements blueprint v2-on-v3-api

Change-Id: I306712f47457843c94e6441c4b9db7bf477c394c
Create instance_extra items atomically with the instance itself

This cleans up how we create instance_extra items by making them
go as part of the db.instance_create() call and be created according
to the instance.extra backref. It should basically eliminate the need
for .create() methods on the individual objects. Since this also makes
the Instance object create pci_requests the way it was doing for
numa_topology, this updates (and freshens) the test for that to make
sure that pci_requests get created properly as well.

Related to blueprint flavor-from-sysmeta-to-blob

Change-Id: I01c490c3cb731133caa8c2c93824458a694e9630
Merge "Raise HTTPNotFound in V2 console extension"
Remove unused db.api.flavor_extra_specs_get_item

Change-Id: I5fc89d35820ffc5a77e2152ba1bfa3b82474be89
GET servers API sorting compute/instance/DB updates

This change is to support updating the v2 and v3 /servers and
/servers/detail APIs to support multiple sort keys and sort directions
(using the 'sort_key' and 'sort_dir' parameters); these parameters can
be specified multiple times to create a list of sort keys and
directions.

Contains the changes that will be used by the REST API layer:
* Compute API updates on the get_all function to support sort keys
  and directions
* InstanceList updates on the get_by_filters function. The new
  'sort_keys' and 'sort_dirs' kwargs are added but the existing
  'sort_key' and 'sort_dir' kwargs must remain for backward
  compatibility.
* DB API has a new 'instance_get_all_by_filters_sort' function that
  supports multiple keys/directions. The existing
  'instance_get_all_by_filters' remains for backward compatibility
  and calls the new sort function with the single sort values
  wrapped in a list.

Note that the defaulting of the sort keys and directions is done in
the dependent patch set in the new 'process_sort_params' function
(invoked in db.sqlalchemy.api); by default, the sort keys are
'created_at' and 'id' in the 'desc' direction.

The REST API changes that consume these updated will be pushed in
another change set.

Change-Id: Iec2bba18c8894302e3ba35af69379ea9c1da04fc
Partially implements: blueprint nova-pagination
Don't make a no-op DB call

drivers_uuid can be empty, but we are still doing a DB call. This is causing
a sqlalchemy SAWarning.

SAWarning: The IN-predicate on "instances.uuid" was invoked with an
empty sequence. This results in a contradiction, which nonetheless can
be expensive to evaluate.  Consider alternative strategies for improved
performance.

Change-Id: Ib8c9b85e84800c9e2ddcdf204851f1b51101926c
Closes-Bug: #1383617
Merge "maint:Don't translate debug level logs"
Allow passing columns_to_join to instance_get_all_by_host_and_node()

This allows us to specify which columns should be loaded during this get
call. It is needed for the next patch which adds support for extra items
in the expected_attrs lists.

Change-Id: Id7d8fae9b0d3c7cf1f0f7debbe5d851696759c2c
Merge "Remove unused db.api.flavor_extra_specs_get_item"
Fix usage of BandwidthUsage.create()

The _poll_bandwidth_usage periodic task was attempting to use
BandwidthUsage as a classmethod even though it is not defined as a
classmethod.  It has been updated to be used properly and a test was
added to ensure there is no error.

Change-Id: I96709675a952857da5121da29acd1ab2e6726fd0
Closes-Bug: #1392423