Fix NoopQuotasDriver.get_settable_quotas()

get_settable_quotas() always failed with KeyError. While this driver
is not really useful, we still want it to be working.

Closes-Bug: #1363014

Change-Id: Ia6986453338cee05f28ff081c6bb1279072c3d80
Fix 'createImage' server actions for V2.1 API

'createImage' server actions was missed for V2.1 API.
This patch converts 'createImage' server action for V2.1 API

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

Change-Id: I5490365c72082b1652ddda2fed97c754fceeed22
Closes-Bug: #1367633
VMware: Fix usage of assertEqual in test_vmops

Ensure usage is assertEqual(expected, got)
Convert assertEqual(boolean, ...) to assertTrue/assertFalse

Change-Id: If61e604673a016420bfb23aafd559b1f753906f8
VMware: Remove host argument to ds_util.get_datastore()

Since the removal of the ESX driver, we no longer pass host to
ds_util.get_datastore(), and we always pass a cluster. This change
removes the host argument, and assumes we always get a cluster.

This is a relatively simple change, but it has 2 knock-on effects to
tests. Firstly, almost all tests using get_datastore were passing host
and cluster as None, None, which excercised a code path which only
made a single vim call. This meant that passing in
fake.FakeObjectRetrievalSession() worked well. That code path was
removed (because it was never actually called), and the new code path
makes either 2 or 3 vim calls. This requires more complex faking of
vim calls, which we do in _mock_get_datastore_calls(). Note that this
is only faking the vim calls, so we're still testing get_datastore,
not the fake function.

The second knock-on effect is to the incredibly fragile
test_spawn_mask_block_device_info_password in test_vmops. This test
has to allow enough of spawn() to run to generate a debug log message,
as it is testing that log message. This change caused an irrelevant
exception to be raised in _get_vm_config_info, which prevented it
getting as far as the log message. We poke the test a bit so it
doesn't break any more.

Finally, we entirely remove test_get_datastore_no_host_in_cluster
because:

1. the previous code did 'if datastore_ret:' so returning '' and None,
   as returned by test_get_datastore_without_datastore, were
   previously functionally identical. Incidentally, this change also
   fixes that.
2. its purpose wasn't clear anyway.

Change-Id: I37f1ea126ae2e7f86cfd29d399fba1c527f18dc0
Return None from get_swap() if input is not swap

If a non-swap parameter is passed to get_swap(), return None,
rather than returning the parameter itself.

Change-Id: Icfb0eb0e4d721522160d0b7a4fd9b98c1871a10a
Closes-bug: #1214406
fix_typo_in_heal_instance_info_cache

refersh is inappropriate

Change-Id: I284d9e9231da79967c12e7af80ab028a0301daba
Fixes server list filtering on metadata

In order to specify filtering of returned servers based on
metadata or system metadata a key/value pair string is passed to
the API. However, the string is never converted to a separate
key/value dictionary. This results in the db failing to filter
correctly and causes a stack trace.

This change correctly converts the string values for system
metadata and metadata to dictionaries and fixes the compute api
unittests which previously erroneously assumed that the compute
api layer would be passed search opts in dict format when
required.

Change-Id: I886d5e770fe16fc2194b33c563a131b550f13f59
Closes-Bug: 1372218
Reduce the log level for the guestfs being missing.

There are platforms where we can never reasonably expect libguestfs
to be functional (FreeBSD, libvirt / lxc, etc). Reduce the log
level of the message recording that libguestfs is unavailable to
reduce operator confusion.

As discussed on openstack-dev at:

  http://lists.openstack.org/pipermail/openstack-dev/2014-September/046910.html

Change-Id: I4bd7ed4fbffb8ac22aea4285fe74ee0d78e1581c
Return vcpu pin set as set rather than list

The current implementation of the libvirt driver makes mixed assumptions
about the vcpu pin set returned from hardware.get_vcpu_pin_set(). Most
places in the code assume its a set and perform set operations on the
structure. However a few  places assume it's a list. Given the mixed
assumptions about the structure type, the existing code was trying
to perform set operations on a list.

This patch changes the get_vcpu_pin_set() method to return a set
rather than a list and handles any edge cases where consumers need
a list. It also updates any relevant unit tests accordingly.

Change-Id: I66d5cbc0e2d370d9d2d2ab2bad2c5b348bedba6c
Closes-Bug: 1372829
XenAPI: clean up old snapshots before create new

Before taking a new snapshot, we now inspect the VDI chain to check for
old snapshots.

Those old snapshots can be left behind from resize, migrates, and
snapshots that get interrupted if you kill the nova-compute process.

If you leave these snapshots behind, the hypervisor disk will get too
full, as VDI chains grow much bigger than you would expect. In addition
snapshots start to grow in size, causing issues copying the snapshot
into storage.

Closes-Bug: #1371072

Change-Id: Ice3741213438c7b4a7fda1e3e0a6dd7faca0fd04
add time to logging in unit tests

It's quite difficult to debug unit test failures when you don't have
any idea when the log messages happened relative to each other. Update
the logging fixture so that we are actually writing out time into our
log messages.

Change-Id: I704792f10d77345246d528bd9abf2e0c46b6df72
Reduce the scope of RT work while holding the big lock

This makes the RT.update_available_resource() method do what it
can in the way of prep work before grabbing the lock to update
the database stats.

Change-Id: I1132e2ab99427688529566c1a1fffb33eab07f3f
Related-Bug: #1371677
Neutron: Atomic update of instance info cache

In the Neutron network API implementation, there is a race condition
between a thread performing periodic task to read and heal instance
network info cache and another thread servicing interface-attach or
interface-detach calls. This patch ensures that instance info cache is
read and then updated in a synchronized block to ensure atomicity.

Please see the bug report for more details.

Change-Id: Ifc76f2b1cce834b3c9927359ac9b957bc9f9c65f
Closes-Bug: #1326183
Co-Authored-By: Dan Smith <dansmith@redhat.com>
Merge "Fix 'createImage' server actions for V2.1 API"
Merge "Reduce the scope of RT work while holding the big lock"
Merge "XenAPI: clean up old snapshots before create new"
Merge "add time to logging in unit tests"
Merge "Return None from get_swap() if input is not swap"
Merge "Return vcpu pin set as set rather than list"
Merge "Fixes server list filtering on metadata"