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
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
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
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
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
move dict copy in prep for object-ify flavors

This change is to help split up the patches for object-ifying flavors.
It moves a dict copy of instance_type from the tests to
get_flavor_by_flavor_id().

Change-Id: I0082a56aa637169fd6e1db3aad56877c9f745bc5
refactor flavor db fakes in prep for object-ify flavors

This change is to help split up the patches for object-ifying flavors.
It refactors db fakes to provide default values for fields that are
not nullable in flavor objects.

Change-Id: I18575703cd5c52d4f446c9bca1edd7baf33b416f
refactor flavor manage tests in prep for object-ify flavors

This change is to help split up the patches for object-ifying flavors.
It refactors flavor manage tests to provide default values for fields
that are not nullable in flavor objects.

Change-Id: I59f0254269379ace2186ed90810c5d1a9f09fed7
Update InstanceInvalidState output

Update InstanceInvalidState output because the original format
is not valid and will lead to none readable output.

Change-Id: I8481facd8100ce9a6f87ea208c06d99016a89534
consistently set status as REBUILD when rebuilding

Consider an instance is in SHUTOFF status(stopped). When a rebuild
is issued on this instance, the status does not display as REBUILD.

Similarly, when a rebuild is issued on an instance and the operation
fails, the instance turns to ERROR state. Now if we issue a rebuild
again, the status does not display as REBUILD.

This patch fixes the above mentioned issues by displaying the correct
status i.e REBUILD.

Change-Id: Id11c9d31683a049c61fd751dc0ddabaf22c96cb9
Closes-Bug: #1362733
xenapi: deal with reboots while talking to agent

The latest version of the agent has started changing the hostname
through the official windows APIs, when resetnetwork is called. This
means a reboot might happen after resetnetwork.

A reboot happens when polling for the version. Until now we wait for the
call timeout, before fetching the new dom id. This change ensures that
if we spot a reboot, the plugin exits early rather than keeping polling
the wrong dom id.

Turns out its best to wait for the dom_id to change, before trying
to poll the agent again. Once the dom_id in xenapi has been updated,
the xenstore keys are always in place.

Trying too early leads to lots of reboot detections because we are
retrying with the old dom_id. XenServer continues to return the old
dom_id for a little while after the reboot.

Closes-Bug: #1370999

Change-Id: Id0bf5b64f2b271d162db5bbce50167ab1f665c87
VMware: remove unused variable from tests

Commit 6c4b89a2ad51f92707acc01908b63bc507ad8fe7 added a variable
which was never used.

Change-Id: I6d9391359f25feedbdf822a606c07b0ae9a735be
Add developer policy about contractual APIs

Document what APIs nova considers to be public contracts, anything not
in this list should be considered a private API.

Clarify the 'API' section to make sure its clear we are talking about
the REST API.

Change-Id: If71adc7a9d5dc1bde79f75d10e67500f6f92b81f
Enhance  V2 disk_config extension Unit Test

disk_config extension extends the request/response
for server's create, update, rebuild & resize operation.
However, unit tests of the extension are not enough now.

This patch adds more tests to increase code coverage.

Change-Id: Ibdc9a931fac7501a9f8326bae16f3b41d51be9bb
console: introduce a new exception InvalidConnectionInfo

Introduces a new exception InvalidConnectionInfo used when
an effectively connection_info is invalid.
Updates the code to take advantage of this new one.

Change-Id: I21940a14017b8aab5c3ee04c597cb05742a621eb
VMware: remove unnecessary deepcopy

The rescue and unrescue methods had an unnecessay call to deepcopy.
This code was deleted.

TrivialFix

Change-Id: I288ec4620e3d2c16ac17e4664dfb9764c357877e
VMware: remove _get_vim() from VMwareAPISession

This method has side-effects which are not needed and brings only
clutter in the driver. The vim object should be accessed as a standard
property of the session object.
This patch is mostly a mechanical replacement and doesn't change any
existing functionality.

This is part of blueprint use-oslo-vmware

Change-Id: I1e86a2e5afc5c0b5921c0248806f434df0cdef2a
console: make unsupported ws scheme in python < 2.7.4

Due to a bug in python < 2.7.4, urlparse won't parse a query string
in a URL where the scheme is not recognized:

http://bugs.python.org/issue9374

Commit 1dda5ef75a5c141c316639716820b0c37773a9e3 added some tests for
websocketproxy that uses urlparse to get a token but these don't work
on python < 2.7.4 since the scheme in the tests is "ws://".

In the actual code, raise an exception if python < 2.7.4 and an
unsupported URL scheme is used.

DocImpact: The "getting-started-with-vnc-proxy" page in the
"admin-guide-cloud" docs should be updated with a note that the web
proxy console URLs do not support the websocket protocol scheme (ws://)
on python versions less than 2.7.4.

Change-Id: Ib6e0fc4e50c1ea144a9c538099e23597d66b429b
Closes-Bug: #1376078