Move volume_clear option to where it's used

The `volume_clear` and `volume_clear_size` option are used in `lvm.py` so we
should move the definition there.

Change-Id: Ic619c2db0bb1b5ccc7dcbec1a500c3dcb1110b26
Correct a maybe-typo in pci_manager

the variable 'dev' in set_hvdevs are only used for list comprehension,
it does not make sense to use 'dev' again for updating self.stale.

Change-Id: I03f31bfcfc56a43e43eb88845e1d562f19a3a09e
Add decorator expected_errors for ips v3 extension

Add decorator expected_errors for ips v3 extesion, that's required
for all the v3 extension.

Change-Id: Iad071fd77bd3571087badc1d836275bd64d8dfc8
baremetal: Remove depenency on libvirt's fetch_image method

It's messy for virt-drivers to depend on each other, so this patch alters
baremetal to use the cross-driver fetch function, instead of the libvirt
version.

Change-Id: I910c621452fa7eb9add417a8738e5757aeb1a48c
libvirt: Fix kwargs for _create_image

Rescue uses the `suffix` and `disk_images` kwargs of `_create_image`, but
passes them in as positional args. We should use explicit kwargs here to be
clear that rescue depends on both of those parameters being present.

In addition, disk mapping was being passed in as kwarg, but is actually a
positional arg, so we should pass it in as a positional arg to be clear that
it's required.

Change-Id: Iaa990729b4bb3569f4c71ceaf1adabed58f73026
Add test for get_instance_disk_info to test_virt_drivers

Commit 2bed16c89356554a193a111d268a9587709ed2f7 added
get_instance_disk_info to the base ComputeDriver class
but didn't add a test for it in test_virt_drivers, so
it's added here.

This also fixes the wrong method signature in the fake
virt driver.

Note that this wouldn't have found the problem for the
hyperv or vmware drivers due to bug 1209421.

Change-Id: I5765720d8c3e0a7962b493fa49359514f3136544
Related-Bug: #1358719
Remove libvirt legacy LVM code

The Change-Id Ib36b962971fd1f66ea9a0818e91fec59e118e686 fixed an
issue which could have caused volumes no longer being able to be
cleaned up due to it's reliance on the instance_name_template
configuration option.

There was code in place to handle both disk formats which are
the legacy format (volume name prefixed by instance name) and
the new one (volume name prefixed by instance uuid).

This commit removes the legacy format which was due to be
removed from the code.

UpgradeImpact - this removes support for really old lvm names that
could have been created in Havana clouds. That means there is a
possible failure to cleanup of lvm volumes that existed uniterupted
since Havana.

Change-Id: I28497a650fbd012643080951f7d86ab8780fd59c
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 swap_volumes

The attach and detach calls to cinder are better handled by cinder this
patch removes them. There is another patch against this bug to modify
cinder.

The attach call is being made against the new volume after the
migrate_volume_completion request. This means it may be done after the
new volume ID in the db has been deleted.

The detach call is being run at the end on the old ID and so may end up
detaching the migrated volume from cinder's perspective.

Change-Id: I3f2d98e9e473905a3de2f02e00c92ae3065e6ae7
Partial-Bug: 1316079
Clean up LOG import in floating_ips_bulk v2 api

Remove useless code of LOG in floating_ips_bulk.py

Change-Id: I66f20a23d75b2c9c2e7cc2425f015a95fefb62d8
VMware: prevent race condition with VNC port allocation

When spawning some instances, nova VMware driver could have a race condition
in VNC port allocation. This fix ensures that the lock is done on the
actual setting in the VM configuration spec.

Co-authored-by: Marcio Roberto Starke <marcio.starke@serpro.gov.br>

Change-Id: I70fab021bbf2df418df53e5f47e19cf16dbe45ac
Closes-bug: #1357372
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
Add warning to periodic_task with interval 0

In Ia227f4c4e69ecf361ab02d1d17a3010303650104, warnings were
added for several options but instance_delete_interval was
left out by mistake.

Closes-Bug: #1188226
Change-Id: I20b396d664e40252743cac4f2a49f4f34882b32f
Fix "revertResize/confirmResize" for V2.1 API

"revertResize/confirmResize" server actions were missed for V2.1 API.

This patch converts "revertResize/confirmResize" 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: I24bdb5b28fafeb60ea7b4ff044b12a519498e592
Closes-Bug: #1367642
Fix 'os-interface' resource name for Nova V2.1

V2 and V3 diff for this resource name is below-
V2 - '/servers/os-interface'
V3 - '/servers/os-attach-interfaces'

V3 resource name needs to be changed to work that for V2.1

Change-Id: I37bd7cee7e8879b01a8aee739d74c2dd6e033dc4
Closes-Bug: #1368035
Ironic: save DB calls for getting flavor

The commit bceb6342994fc9d38a51a19e5b07652a5fdfd503 would read
the flavor a number of times instead of passing a flavor as a
a parameter.

This save an unnecesary DB access.

Change-Id: I4dc8739129a694d6ddae1ed9f1998663a2204d89
Add unit test for add_floating_ip API

Currently, add_floating_ip API has no unit test for body's key test,
this patch adds the test cases.

Change-Id: I32a32514c68fcd8717011d37724a20993aa8ed20
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
Fix `confirmResize` action status code in V2

In server`s action `confirmResize` status code in @wsgi.response
decorator is set as 202 but this is overridden/ignored by return
statement (return exc.HTTPNoContent()) which return 204 status code.

This is very confusing and we should have expected status code in
@wsgi.response decorator as consistence with other APIs.

NOTE- There is no change in API return status code. API returns the
same 204 return code as previously.

Change-Id: Id8033fb8880306babebc14b319bce5b3b8798774
Closes-Bug: #1368597
Fix test_create_instance_invalid_key_name

In test_create_instance_invalid_key_name, there were the duplicated
negative factors. One is nonexistent image-id, the other one is non-
existent keypair.
This patch removes nonexistent image-id for the test purpose.

Change-Id: I90ff4e9ca0eeb149aa0db7be2d171561586724e9