Refactor work with TaskLog in sqlalchemy.api

Add _task_log_get_query() private method
It is used to remove from task_log_get() and task_log_get_all() session.
parametr and save performance.

task_log_get() method
Remove session parameter from public method.

task_log_get_all() method
Remove session parameter from public method.

task_log_begin_task()
Remove session parameter from public method.
Remove unused return value.

task_log_end_task()
Remove session parameter from public method.
Use 1 db request instead of 2.
Remove unused return value.

blueprint db-session-cleanup

Change-Id: I2c8252de7978e8fddd800e903f18a73ee9a95034
Remove baremetal-compute-pxe.filters

The baremetal PXE driver doesn't seem to run dnsmasq at all, so remove
the rootwrap filter which allows it to do so. This was introduced by
commit a2f260f.

Change-Id: I4cc1127222b73af218a6a8808d0ad54478878af1
Tests for PXE bare-metal provisioning helper server.

a part of blueprint general-bare-metal-provisioning-framework.

The deploy helper was landed without tests. This patch reinstates the
tests.

Change-Id: I690ec077e175dc37c2cc5f18170513b0e5bca103
Co-authored-by: Mikyung Kang <mkkang@isi.edu>
Co-authored-by: David Kang <dkang@isi.edu>
Co-authored-by: Ken Igarashi <igarashik@nttdocomo.co.jp>
Co-authored-by: Arata Notsu <notsu@virtualtech.jp>
Co-authored-by: Devananda van der Veen <devananda.vdv@gmail.com>
Fix state sync logic related to the PAUSED VM state

A VM may get into the paused state not only because the user request
via API calls, but also due to (temporary) external instrumentations.
Before the virt layer can reliably report the reason, we simply ignore
the state discrepancy. In many cases, the VM state will go back to
running after the external instrumentation is done.

Fix bug 1097806.

Change-Id: I8edef45d60fa79d6ddebf7d0438042a7b3986b55
Implement Quantum support for addition and removal of fixed IPs

Fixes bug 1099378

Change-Id: I696d1f702cf99ef15af47c261844febd8a6e7ffc
Correcting improper use of the word 'an'.

Change-Id: I032509539c61f2f5fda2001e2db5a3298e30c561
correcting for proper use of the word 'an'.

Change-Id: Ib6180284d806a00c520df378e651fba947e2397a
Use common rootwrap from oslo-incubator

Make Nova use common rootwrap code from oslo-incubator.
Implements bp nova-common-rootwrap

Change-Id: I3282d65940375589fceb8485829097380d84d946
PXE driver should not accept empty kernel UUID.

Baremetal PXE driver was aborting only if the kernel and ramdisk
specified in image metadata were None, but not if they were another
non-true value, such as "". Now, exception is raised if they are any
non-true value.

Fix bug 1100589.

Change-Id: I9783a14cc242e1b9db04d797c61d54b06d52c680
Clean up db network db calls for fixed and float

Use a join instead of a subquery for fixed_ip_get_by_floating_address
and floating_ip_get_by_fixed_address. Adds test to verify behavior
is the same.

Change-Id: Iab00142d477308c354777a2c64b6d03a21184585
Ignore auto-generated files by lintstack

Part of blueprint lintstack

Change-Id: I6ca0ec71c7fa083a86920a7ae055ef8e9d19c512
Go back to the original branch after pylint check

Previously we save the current commit hash before running lintstack.
This is no problem for Jenkins but not very friendly if we run
lintstack locally. Every time after it's done, git is in detached
HEAD mode. This patch remembers the current branch name and
automatically go back to the branch if available. Otherwise we fall
back to the commit hash.

Part of blueprint lintstack

Change-Id: I145df3027022fc9a8302bc6da9ab300f677f3386
Refactor: extract method: driver_dict_from_config

Related to blueprint xenapi-volume-drivers

Extract method to create driver registries, so that it could be re-used
in xenapi for a similar purpose.

Change-Id: Ifd25d12335ac96a15dfea4c5ab7f315ff7ddfd8b
Remove restoring soft deleted entries part 1

There is no need to reuse deleted entries, because they will be archived after
db-archiving implementation. And restoring soft deleted entries produce some
problem with db-unique-keys implementation. So the best way is to remove it.

instance_type_access_add() method
Remove restoring soft deleted instance_type_access entries

instance_type_extra_specs_update_or_create() method
Remove restoring soft deleted instance_type_extra_specs entries
Add missing transaction

aggregate_host_add() method
Remove restoring soft deleted aggreagate_hosts entries
Add missing transaction

blueprint db-session-cleanup

Change-Id: Ida7db95233c40faacac55105650f52d42ad360c2
Remove restoring soft deleted entries part 2

There is no need to reuse deleted entries, because they will be archived after
db-archiving implementation. And restoring soft deleted entries produce some
problem with db-unique-keys implementation. So the best way is to remove it.

instance_type_access_add() method
Remove restoring soft deleted instance_type_access entries

Add missing tests for instance_type_access_add

blueprint db-session-cleanup

Change-Id: I82ee56b50a8422a4b620f4e58967258bac7c01c6
Directly copy a file URL from glance.

That patch allows nova to use shutil to copy a file directly from the
glance store.  For this to work glance needs to enable direct_url
descriptions in the image metadata.  This is done by setting
show_image_direct_url to True in glance-api.conf.  The path used to back
glance also must match the path used to back nova instance storage.  This
should be a large performance increase for the cases where both glance
and nova instance storage are backed by a shared file system like gluster
or ceph.

A new option has been added to nova: allowed_direct_url_schemes
This option is set to a list of schemes that can be directly accessed.
For this first simple patch only file:// is valid, and the
implementation is simple and inline.  In the future it would be better
to make this into propagation modules which are dynamically loaded
according to the scheme.

DocImpact
Implements: blueprint direct-file-copy
Change-Id: I041b5524f8a0ea59e89ece0202f0503abf2f9d8e
Refactor EC2 keypairs exception

According to the following document:

http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/api-error-codes.html

The EC2 API sends specific error codes when keypair listing or
keypair generation fails, specifically the error codes are

InvalidKeyPair.Duplicate - duplicate keypair
InvalidKeyPair.Format - keypair format invalid
InvalidKeyPair.NotFound - keypair not found
ResourceLimitExceeded - keypair quota exceeded

Refactored create_key_pair and describe_key_pair so that
it throws the correct EC2 error codes according to the
public EC2 API specs.

Also removed some duplicate exceptions as well.

Fixes LP: 1072318

DocImpact

Change-Id: Ib7045e49211d9300e9cb6ca0bfe80e569d635c9b
Signed-off-by: Chuck Short <chuck.short@canonical.com>
libvirt: Fix typo in configdrive implementation

libvirt configdrive implementation
references 'instane' instead of 'instance'.
Also, add a test for adding configdrive block device
that would catch such an error

fixes bug 1101352

Change-Id: I36cba4487ad9d78d4e0366c8c2550603ba155c47
Run_as_root to ensure resize2fs succeed for all image backends

Unlike other file based image backend, operation over LVM
logical volumes requires root to functioning correctly. Resize2fs
on logical volumes also need run_as_root.

Otherwise, when running nova-compute as non-root user, instance
creation with flavor disk size larger than image size would fail.
Caused by resize2fs failure.

Fixes LP# 1101137

Change-Id: I16a2aa4382be58843270ff23e11bfb1e20c568d2
pick up eventlet backdoor fix from oslo

eventlet backdoor had a misnamed variable in it (found by pyflakes).
The fix was already in oslo, sync to pick up this new fix.

Change-Id: Iede6443fd1a3f04d99607278d9afbb41bc9acdbf