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
Remove unnecessary imageRef setting from tests

In setUp(), a default imageRef is set already and it is not necessary
to set it in each test if that is not the purpose of the tests.
This patch removes such unnecessary imageRef setting for cleanup.

Change-Id: I2dcf79112d1e6adfbb634bf4c957bbb1238232d8
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
Vmware:Add support for ParaVirtualSCSIController

This fix allows us to use ParaVirtualSCSIController
adapter type as 'paraVirtual' for 'vmware_adaptertype'.

DocImpact: Add vmware_adaptertype parameter paraVirtual
Change-Id: Id25287310e2aab27808d4be0b6b47303404e4fae
Closes-Bug: #1339462
libvirt: avoid changing UUID when redefining nwfilters

libvirt >= 1.2.7 enforces that when you re-define a network
filter you can't change the UUID. ie name + uuid must match.
Since Nova was not including any UUID in the XML it sent, it
would always get a random UUID generated, which would cause
failures when re-defining an existing filter. The result
was that Nova would fail to start up and fail to migrate
if there was an existing guest running. The fix is to query
libvirt to see if the nwfilter already exists, and extract
the UUID from its XML and use that when re-defining it.

Closes-bug: #1360119
Change-Id: I9d4b2c6c8f0c9a23ed79ed8e0b5ac0d4418851a4
Refactor test_get_port_vnic_info 2 and 3

This patch addresses the comments left on review 121939 for
nova/tests/network/test_neutronv2.py, it removes duplicated code from
the added unit tests and corrects an identation issue.

Change-Id: I02c004297d4ee78e5695c3ca265052020f2fcfa3
Related-Bug: 1370077
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
Revert "libvirt: support live migrate of instances with conf drives"

This reverts commit ecce888c469c62374a3cc43e3cede11d8aa1e799.

Using the image cache is the wrong way to move an image into the same
storage as other instance disks. We should just call into the relevant
backend store directly.

Change-Id: Id867b89d959c26d067cb06b52a496e2b98573289
Sync network_info if instance not found before _build_resources yield

If instance is deleted before _build_resources yield, there won't
waiting for network_info sync finish.

So there is race case, when the exception catching for
'InstanceNotFound' in do_build_and_run_instance invoke
'_cleanup_allocated_networks', the '_allocate_network_async' didn't
create port yet. After '_cleanup_allocated_networks' finished,
'_allocate_network_async' create new port for the instance, but there
isn't any cleanup for the new port anymore.

Change-Id: I5027a1aaeb9a2106f7982fd0422f88c4caa20ffb
Related-Bug: #1357055
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
Fix start/stop return active/stopped immediately in EC2 API

start/stop action is async. But the EC2 API is hard code the status
as start/stop finished immediately.

This patch fix start action return pending status, and stop action
return stopping status.

Change-Id: I0cf6db1dcb17c48a12fd62b0d707afd124b96b26
Closes-Bug: #1373230
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
remove test_multiprocess_api

This test suite should be removed for the following reasons.

1) it's not a unit test

2) it's failing randomly, a lot, and depends on timing of the host for
process start and signal handling which are provably not predicable on
slower machines

3) it's triggering testr bugs in the ways that it fails which means we
don't actually get any subunit in the fail scenario, which makes it
actually impossible to move forward on fixes.

Change-Id: Ieb7c02115c12cd9f6c9fa67691a643aed7632784
Closes-Bug: #1357578
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