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
low hanging fruit oslo-incubator sync

Sync modules from oslo-incubator without changing files outside of
directory 'openstack/common'.

Synced Modules:

Patch logs were generated by 'git log --abbrev-commit --pretty=oneline
{file}'

config:
0e98afd Re-raise exception of unloadable library
1a6dfb9 Sanitize FQDN in config generator
e839886 Config generator fails with lazy messages
763eedf Fix DictOpt support in config sample generator

context:
c0d357b Add model_query() to db.sqlalchemy.utils module
13eb01c Adding domain to context and log
12bcdb7 Remove vim header
bdabd51 Remove uuidutils imports in oslo modules
44e8222 Revert "Removes generate_uuid from uuidutils"
571a78a Removes generate_uuid from uuidutils
36859e5 Adding instance_uuid to context and log
b21fc56 Fix bad default for show_deleted

eventlet_backdoor:
fcf517d Update oslo log messages with translation domains
ad17a69 Fix filter() usage due to python 3 compability
8b2b0b7 Use hacking import_exceptions for gettextutils._
12bcdb7 Remove vim header
1dcc747 Fix stylistic problems with help text

excutils:
33a2cee save_and_reraise_exception: make logging respect the reraise parameter
fcf517d Update oslo log messages with translation domains
8b2b0b7 Use hacking import_exceptions for gettextutils._
6d0a6c3 Correct invalid docstrings

fileutils:
fcf517d Update oslo log messages with translation domains
e71cd1a Merge "Trivial: Make vertical white space after license header
consistent"

gettextutils:
fd33d1e Fix gettextutil.Message handling of deep copy failures
047b2e4 Change lazy translation to retain complete dict
6d55e26 Add support for translating log levels separately

importutils:
885828a Deleted duplicated method in cliutils

jsonutils:
e3a1d9c Use six.moves.xmlrpc_client instead of xmlrpclib
3a31bba Python3 support for xmlrpclib

log:
da6d713 Revert setting oslo-incubator logs to INFO
0d18381 Set default log levels for oslo.messaging and oslo-incubator
346884d Add default user_identity to logging record
3570f44 Merge "Remove None for dict.get()"
bf6d71d Merge "Rename Openstack to OpenStack"
86707cd Remove None for dict.get()
61ff7a6 Rename Openstack to OpenStack
5b5068e Merge "Fix deprecated messages sent multiple times"
dda47c9 Use ContextFormatter for imparting context info
52b6446 Fix deprecated messages sent multiple times
d6e1ba7 Merge "default connectionpool to WARN log level"
7f4ad99 Merge "Small edits on help strings"
8c3046b Merge "Backport 'ident' from python 3.3 for Oslo's
SysLogHandler"
1978114 default connectionpool to WARN log level

loopingcall:
fcf517d Update oslo log messages with translation domains
8b2b0b7 Use hacking import_exceptions for gettextutils._
12bcdb7 Remove vim header

memorycache:
12bcdb7 Remove vim header
5e765b2 python3: Fix traceback while running tests

network_utils:
897aa7c urlsplit issues with IPv6 addresses in python26
35dc1d7 py3kcompat: remove
fb738d4 Merge "Use py3kcompat urlutils functions instead of urlparse"
12bcdb7 Remove vim header
4c22556 Use py3kcompat urlutils functions instead of urlparse

processutils:
fcf517d Update oslo log messages with translation domains

service:
e2634a7 Add missing _LI for LOG.info in service module
0150ad7 Merge "Reap child processes gracefully if greenlet thread gets killed"
53e1214 notify calling process we are ready to serve
fcf517d Update oslo log messages with translation domains
1e70078 Revert "service: replace eventlet event by threading"
0644073 Simplify launch method
6b4d255 Merge "service: replace eventlet event by threading"
a4f145e Merge "Allow configurable ProcessLauncher liveness check"
8b2b0b7 Use hacking import_exceptions for gettextutils._

systemd:
53e1214 notify calling process we are ready to serve

threadgroup:
5f8ace0 Merge "threadgroup: use threading rather than greenthread"
2d06d6c Simple typo correction
4d18b57 threadgroup: use threading rather than greenthread
25ff65e Make wait & stop methods work on all threads
12bcdb7 Remove vim header
9d3c34b Add a link method to Thread

timeutils:
d815087 Merge "Fix spelling errors in comments"
63d5ba6 Merge "Fix typo in parameter documentation (timeutils)"
71208fe Fix spelling errors in comments
7013471 Fix typo in parameter documentation (timeutils)

versionutils:
8b2b0b7 Use hacking import_exceptions for gettextutils._
a5ae087 fixed typos
45658e2 Fix violations of H302:import only modules
db29de0 Merge "Adds decorator to deprecate functions and methods"
37ea814 Adds decorator to deprecate functions and methods
12bcdb7 Remove vim header

xmlutils:
12bcdb7 Remove vim header

Co-Authored-By: ChangBo Guo(gcb) <eric.guo@easystack.cn>

Change-Id: Ic8e47cb037683338f972df880b51921c1f9f98d8