Fixes messages logged on Glance plugin retries

Retry logic is now being used for both upload_vhd and download_vhd,
but nova/virt/xenapi/client/session.py still had 'upload_vhd'
hardcoded in its logged messages. This change causes it to accept the
function being used as an argument and display that.

Fixes-Bug: #1265054
Change-Id: I6203aef81960078f92fa7839e47ee1c84df95745
Fix invalid facilities documented in rootwrap.conf

The values user0 and user1 do not map to valid facility values.
local1, etc.  Using user0 results in a  pri value that does not map
back to a facility of the same name in syslog.

RFC5424 suggest values values of local0 through local7.  Setting
syslog_log_facility to one of those values results in a message with a
priority that can be mapped back to the original string value.

This fix adjusts the comment in rootwrap.conf to suggest the local
prefix instead of the user prefix.

Closes-Bug #1280879

Change-Id: Ibefffb5619641b75b4f8ac8ce8112a34cf03f0ce
Catch InstanceNotFound exceptions for V2 API instance_actions

Use the common.get_instance method to get the instance object
in the V2 API instance_actions extension rather than call
the compute api directly. The utility function
handes InstanceNotFound exceptions and tranlsates them to HTTPNotFound
rather than letting them propagate up causing a traceback.

Co-Authored-By: Michael Still <mikal@stillhq.com>

Change-Id: I1e69fed0c7c0c611fcfd48abbd4b4e0b1c8b403f
Closes-Bug: 1271146
attach/detach interface should raise exception when instance is locked

when instance is locked, exception should be raised if attach and
detach an interface operation is performed. This patch add instance
lock check for the 2 APIs, catch and process the exception at API layer.

Change-Id: I6c0b05dafb9d480c8f0002bcc8306cb65a32aaf7
Closes-Bug: #1275741
Add return value to some network API methods

Add return value to api methods add_fixed_ip_to_instance() and
remove_fixed_ip_from_instance(). This allows the @refresh_cache
decorator to use returned nw_info model for updating instance
info cache instead of needing to make another rpc call to get
that same information.

Tests are added to make sure return values are used by the
refresh_cache decorator for methods where the rpc call returns
with the necessary nw_info model.

Change-Id: I748e4db9de62d82e4dbcb0b9c444b16dabf0ec5d
Partial-Bug: #1284345
VMware: remove unused code (_delete method in vmops.py)

This code was added in commit 24d609447399e468937f8a278854690864ffabcd and
never used.

Change-Id: I5ad022113666e7be32b512c05165999de2d0c267
Remove PciDeviceList usage in pci manager

Pci manager keeps a PciDeviceList and even try to append
object to the list. This is not correct, as the ObjectList
is designed as immutable, although the objects in the list is
mutable. We should simply use a list to keep devices.

Closes-Bug: #1273803

Change-Id: Ie80b6f5f47a1d2d2e20aadb4779be142c17b5b38
InvalidCPUInfo exception added to except block

When a live migration between two nodes with different
CPU info features is launched, an InvalidCPUInfo exception
is raised and not captured. That lets the vm in an
unusable state because the task_state rollback is not
executed.

Change-Id: Ib418fa324964cabd5f342d1b764f9ac7608b7ade
Closes-Bug: #1294210
Include proper Content-Type in the HTTP Headers

Nova Metadata Service was not setting the Content-Type
in the HTTP Response headers. Because of this, clients
were receiving the default Content-Type which is "text/html".
The changes done in this patch will include proper Content-Type
in the HTTP response headers.

Closes-Bug: #1243878
Change-Id: Ia65cdf8099c85f63d7f44f93835c606d679a7ab3
Bypass the database if limit=0 for server-list requests

Not all database engines handle fetching 0 rows the same and there isn't
really a point in going to the database to return nothing, so bypass the
DB query if limit=0.

The Nova API is explicitly checking if limit >= 0 so we can't make any
changes there since they would be backwards incompatible, i.e. to start
enforcing limit > 0.

Closes-Bug: #1296929

Change-Id: Ib3d0318bec972af5f1f25202101e76066f930f34
Sync oslo imageutils, strutils to Nova

Changes in imageutils:
===============================
b455fac Enable decimal value input in imageutils.QemuImgInfo
bec3a5e Implements SI/IEC unit system conversion to bytes
8b2b0b7 Use hacking import_exceptions for gettextutils._
aad179d Fixing misspelled encryption key in QemuImgInfo
12bcdb7 Remove vim header
2bd46eb Refactors byte size extraction logic

Changes in strutils:
====================
bec3a5e Implements SI/IEC unit system conversion to bytes
e53fe85 strutils bool_from_string, allow specified default
8b2b0b7 Use hacking import_exceptions for gettextutils._
84d461e Fix a bug in safe_encode where it returns a bytes object in py3
12bcdb7 Remove vim header
3970d46 Fix typos in oslo
1a2df89 Enable H302 hacking check
67bd769 python3: Fix traceback while running python3.
b0c51ec Refactors to_bytes

Change-Id: I3e887756af37823dc6486d1496222825ddc20f0c
Related-bug: #1189635
Related-bug: #1193765
Related-Bug: #1257829
Use instance data instead of flavor in simple_tenant_usage extension

The simple_tenant_usage extension gets the flavor data from the instance
and then looks up the flavor from the database to return usage information.
Since we now store all of the flavor data in the instance itself,
we should use that information instead of what the flavor currently
says is right. This both (a) makes it more accurate and (b)
avoids us failing to return usage info if a flavor disappears.

Change-Id: I1472d78e8e920013a1db5c76e04715fa04b696c2
Closes-Bug: #1276731
Use osapi_glance_link_prefix for image location header

When an image is created the location header returned is generated based
on the request url that nova-api receives.  If SSL termination happens
upstream the request url is an http request, and the location header is
wrongly generated with that.  The osapi_glance_link_prefix config option
is available for almost precisely this purpose, so let's use it.

Change-Id: I24e46ed8fc0763f9ddeec65e0d79590dd7b86bef
Closes-bug: 1298005
Catch InstanceInLocked exception for rescue and instance metadata APIs

When VM is locked by nova, VM API should not execute.
There are so many api that cannot be executed when vm is locked.
rescue/unrescue
update_instance_metadata/delete_instance_metadata
the above APIs should be updated to catch InstanceIsLocked exception

Change-Id: Ic88f3d190894d4b65f54b34660efd9ae83fb0ee4
Closes-Bug: #1266960
Add test cases for validate_extra_spec_keys

There is no unit test cases for function flavors.validate_extra_spec_keys,
this patch adds for it

Change-Id: I689aad1ce7428687c723ecd2eba243fccb3342bf
Closes-Bug: #1292316
Remove unnecessary check for CONF.notify_on_state_change

Already checked CONF.notify_on_state_change at beginning, no
need to check it again

Change-Id: I757ff7b71bafdee9e2e6009e7489db520704c8cc
VMware: remove double import

"import mock" was done twice.

Change-Id: Ibc38d27d7fd8b57b193cbe37d2abd89b823ed43f
Added test cases in ConfKeyManagerTestCase to verify fixed_key.

ConfKeyManagerTestCase sets the fixed_key option, but does not
perform checks to verify it was used.  This patch adds the
appropriate unit test cases to verify the fixed_key option.

Change-Id: I686b095eeb86b67271dc0e3cb5b6acd5a24d3d03
Closes-Bug: #1226228
Fix description of ServerGroupAffinityFilter

ServerGroupAffinityFilter was used instead of
ServerGroupAntiAffinityFilter in the filter description.

Change-Id: I16721db5a7dcf90e72047dd5ca5a4f55088c147d
Change errors_out_migration decorator to work with RPC

This decorator in nova/compute/manager.py was written to work with
positional arguments, but at run time the decorated methods are
called via RPC with keyword arguments.  This change fixes the
decorator and the associated test cases.

Closes-Bug: #1300380

Change-Id: I9f87151a71e5217e7eff97cdc5cad2c85b620fa5