Ensure live-migrate reverts if server not running

When the check to ensure a VM is running before attempting the
live migrate fails, it raises InstanceNotRunning. It should really be
treated in the same way as MigrationPreCheckError.

Along with fixing this bug, I have ensured the expected exceptions in
migrate_server are in sync with the except clause in _live_migrate.

This goes through to the API, ensuring the errors are not treated as
internal server errors, but are given a slightly more appropriate error
return value.

Currently the API returns 400 for all these kinds of errors. While other
error codes may be more appropriate, this change is concentrating purely
on ensuring we treat all the exceptions in the same way.

Change-Id: Iafe5026ef5a095d76e9864b489571e7bcfeb55f0
Closes-Bug: #1312132
versions API: ignore request with a body

Update the OS API versions controller so it ignores requests
with a body. Previously an incoming (unauthenticated)
request to the versions API would log a TypeError trace
in the nova-api.log file with the following message:

TypeError: index() got an unexpected keyword argument 'body'

Change-Id: Icc3ccfc537b13627b8d5ba43ae3ba91e34e08c9e
Closes-bug: #1306727
Fix for multiple misspelled words

In Nova code, few misspelled words have been found.
The misspellings python library has been used to scan
all nova code and find misspelled words.
This commit fixes all misspelled words found with this library.

Change-Id: I5919dddbbe812d8d32ecd8b249c1312249cd2a66
Closes-Bug: 1323730
Sync periodic_task from oslo-incubator

We have not updated periodic_task in over six months and we should have
commit 47c9d60657be4ad58afa3c7e3ef88885a595c4c3 in nova.

Note that this does not include the gettextutils and log dependencies
since there are not functional changes in those modules needed for the
periodic_task changes synced in *and* more importantly, the changes
to gettextutils and log require pervasive changes to nova which should
happen when nova integrates with the oslo-i18n library for
blueprint i18n--messages.

Further note that this does not include jsonutils due to some
issues introduced with a change for python 2.6 that impacts some of
the unit tests in Nova and how strings are encoded with simplejson.
The details for that issue are in bug 1314129.  The jsonutils changes
are not related to the periodic_task changes being synced in so the
dependency is not functionally required.

periodic_task:
c63fd5a Make unspecified periodic spaced tasks run on default interval
f0dd798 Remove rendundant parentheses of cfg help strings
fcf517d Update oslo log messages with translation domains
051b9f3 Refactor unnecessary arithmetic ops in periodic_task
674cdaf Refactor if logic in periodic_task
b6b82c5 Use timestamp in periodic tasks
47c9d60 Don't share periodic_task instance data in a class attr
8b2b0b7 Use hacking import_exceptions for gettextutils._
c5a1088 Typos fix in db and periodic_task module
12bcdb7 Remove vim header

Related-Bug: #1319232

Change-Id: I5534e85ae8791c7c464357f7fd57b986ff74d092
Add unit test trap for object change detection

This adds a test that compares each object to a known hash that
covers the list of remotable method signatures and the field
definitions. Storing this in the code helps us assert that our object
definitions have not changed without a version bump. If someone
adds or changes a field or method to an object, this test will
fail, reminding them to bump the version and update the hash.

This adds a 'remotable' attribute to the methods decorated as such
so that we can detect them separately from local methods which
do not need a version bump.

Change-Id: I3e8bd387e36cec406baf4c6933baca9e1663d122
Change conductor to cast to build_and_run_instance

With build_and_run_instance taking over for run_instance in the compute
manager, this switches over to calling it.  With this change the build
process will not cast back to the scheduler on a build retry.

This is the final part of a series of patches to build up the
build_and_run_instance method.

bp remove-cast-to-schedule-run-instance
Change-Id: Iefab71047996b7cc08107794d5bc628c11680a70
Deprecate run_instance and remove unnecessary code

This begins a deprecation path for the compute manager run_instance
code.

For now the scheduler run_instance rpc method is being removed as it is
unused.

In the K cycle the scheduler schedule_run_instance methods can be
removed which means that the run_instance compute rpc method can be
removed.

In the L cycle the run_instance compute method can be removed.

This also removes cells schedule_run_instance methods which have been
unused since Havana.

bp remove-cast-to-schedule-run-instance

Change-Id: I284ac124fe2ec952db0feab61206eda2a20e40c8
Use objects through the run_instance() path

This removes the use of dict-based instances for the run_instance
path when called from conductor to compute manager.

Related to blueprint compute-manager-objects-juno

Change-Id: I8a206f63cab1e4f939d2c97c258312a8fa540aff
Refactor test_rescue_unrescue into compute api/manager unit tests

As part of converting the rescue/unrescue compute API flows to using
objects, i.e. dot notation for accessing attributes on the instance
object and updating the database via instance.save() rather than
compute_api.update, we want to move some of the integration-style tests
found in test_compute.py to test_compute_api.py and test_compute_mgr.py.

This is to help with the conversion so we don't have to use exotic stubs
in the cells API flows to make integration tests work.

This change is mainly concerned with moving test_rescue_unrescue out of
test_compute.py and into the api/manager specific test modules and then
later changes will build on top of the new tests.

Part of blueprint compute-manager-objects-juno

Change-Id: I2a9b1c6b5a1f41272e26c20de134a2a8b71c88f3
Treat instance objects as objects in rescue API flow

The compute API and manager are getting instance objects now but
treating them like primitive dicts still in several places, so this
cleans that up.

Also adds the instance to the warning log message in _get_rescue_image
since (a) I'm already in there and (b) it adds context for the message,
which is useful.

Cleans up the related tests so they are using objects as well to verify
the changes to compute api/manager are correct.

Part of blueprint compute-manager-objects-juno

Change-Id: Ibe4473fc08fd68676aaa1e1c9ba69161fc5f527e
Treat instance objects as objects in unrescue API flow

The compute API and manager are getting instance objects now but
treating them like primitive dicts still in several places, so this
cleans that up.

Cleans up the related tests so they are using objects as well to verify
the changes to compute api/manager are correct.

Part of blueprint compute-manager-objects-juno

Change-Id: I81fa858a821a2137fce5970905b9b1c71c95304b
Merge "Sync periodic_task from oslo-incubator"
xenapi: tidy up volumeops tests

Remove the old attach volume tests, as they are no longer required, and
tidy up the dead code left behind.

Change-Id: Iadd3741ddf87974dc79d2fe5986083b082f7e314
Merge "versions API: ignore request with a body"
Merge "Change conductor to cast to build_and_run_instance"
Updated from global requirements

Change-Id: Icdb6e17edab010bef272dd0bf5b20973ba759282
Merge "Add unit test trap for object change detection"
Merge "Ensure live-migrate reverts if server not running"
String-convert IPAddr objects for FixedIP.attach()

This fixes a couple places where we pass a (non-serializeable)
IPAddr object to the FixedIP.attach() method, which blows up.
We probably need a more generic solution to this problem, as it
keeps coming up. However, for the moment, this is less problematic
than the patch reverted just before this.

Change-Id: I716c558a3535b3ed5c9b10f5788a4463a3daa3d3
Fix docstring typo in need_legacy_block_device_info

Change-Id: I9aaec5f73f3001c0926aba2fba4165f3a66319f1