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
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
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
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
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
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
Fix description of ServerGroupAffinityFilter

ServerGroupAffinityFilter was used instead of
ServerGroupAntiAffinityFilter in the filter description.

Change-Id: I16721db5a7dcf90e72047dd5ca5a4f55088c147d
Make example 'entry_points' parameter a dictionary

Change-Id: Idad5a1b2d6aaee456cdc3a52554c1d7ddd51a696
Reduce config access in scheduler

Caching the configuration appears to make a impact on the time spent
in the scheduler. These config values reduce the time spent down from
around 5ms to around 4ms per request, when with 200 hosts.

Change-Id: I433cbbdbef4ac3c01a3e2b6ed5cf092a5cce6372
Fix Jenkins translation jobs

The jobs nova-propose-translation-update and
nova-upstream-translation-update do not update from
transifex since our po files contain duplicate entries where
obsolete entries duplicate normal entries.

Remove all obsolete entries to fix the jobs.

Change-Id: I7f51922472f12f3a13feb71a6fb344076781d7e9
Closes-Bug: #1299349
Add tests for remaining expected conductor exceptions

This fills out coverage of our expected exceptions on conductor
methods, which helps ensure we don't drop an expected exception
class during a refactor.

Change-Id: Iacd5315d47ad97c8aad43d2f6a23674529775e63
remove redundant copy of test_cache_base_dir_exists

Second copy of RbdTestCase.test_cache_base_dir_exists was accidentally
introduced in https://review.openstack.org/82840.

Change-Id: I16b2e472b2499f01379fdca9c860da0b95e291d8
Closes-bug: #1302211
Signed-off-by: Dmitry Borodaenko <dborodaenko@mirantis.com>
Require admin context for interfaces on ext network

Currently any user can attach an interface to a neutron
external network, if the neutron plugin supports the port
binding extension.
In this case, nova will create neutron ports using the admin
client, thus bypassing neutron authZ checks for creating ports
on external networks.

This patch adds a check in nova to verify the API request has an
admin context when a request for an interface is made on a
neutron external network.

Change-Id: I5fb0bdcbf19eb82746ea3b192c1f65899bfb3c0b
Closes-Bug: 1284718
Refactor Network API

Base network API class to have all the methods that can be implemented
by specific network api's.

 * Move common logic and decorators to network/base_api.py
 * Base class base_api.NetworkAPI with current methods from
   nova & neutron, that will raise NotImplementedError()
 * Refactor some tests with mock

When this get merged, every review adding new methods to neutron or
nova network, must have the same methods added to the base NetworkAPI.

Implements: bp refactor-network-api

Change-Id: Ia507e80dfd1e0b7552c5d50e84ac9e642ca8c9fe
Revert object-assuming changes to _post_live_migration()

Change I140bfec2a52bf659a725a7dbe78ba5c527ed26de converted the
_post_live_migration() call to assume it was passed an object
because the post_live_migration_at_destination() method uses them.
However, it is also called from live_migration() on the source,
which clearly is still using instance dicts.

This patch reverts the changes that assume an instance object,
as well as the tests that were changed as a result. It also
changes the clear_events_for_instance() call to use dict syntax,
since that is called from the live migration path currently.

(cherry picked from commit 887d214186631d3d1f49451fa72feb11251d2176)
Change-Id: I6e915035bc2c1b890e606d17a4195b88c3f26b13
Closes-bug: #1302334
Fix anti-affinity server-group boot failure

When the second instance is booted to an anti-affinity group
the scheduler fails with an exception due to a missing type conversion.

Closes-Bug: #1301982
Change-Id: I87b2a8d8c7d04b781c789374d6e9c7f4c8567e5d
VMware: Fixes the instance resize problem

The fix includes separating out methods for
associating/disassociating a vsphere vm from the
openstack instance. Modifying the resize workflow
to use the above mentioned methods.

Closes-Bug: #1295381

Change-Id: I92acdd5cd00f739d504738413d3b63a2e17f2866
Merge "remove redundant copy of test_cache_base_dir_exists"
Merge "VMware: Fixes the instance resize problem"
Merge "Catch InstanceNotFound exceptions for V2 API instance_actions"