More consistent libvirt XML handling and cleanup

Fixes bug 1081373

The overall goal of this effort is to make handling of libvirt XMLs
more consistent. First, the on-disk XML file in the instances
directory is never to be used by the libvirt driver. It will be
generated via to_xml(). Second, anytime it is safe to re-define the
XML using the version we programatically generate, we do so.

Extended to_xml() to support a new write_to_disk argument. When true,
this the resulting XML will be written to the instances directory.
Renamed _get_domain_xml to _get_existing_domain_xml, as it should only
be used when we need the XML for a defined domain. It will continue to
fall back to using to_xml() if the defined version is not available.

Hard reboots will now assume nothing about the defined state within
libvirt. Rather, we generate and define the domain every time. This
eliminates the possibility of the hypervisor and Nova database going
out of sync (i.e. volume attached in defined XML with Nova having no
knowledge). We no longer need to pass an xml argument into
_hard_reboot() since it is always generated.

Resume state on boot has been updated with logic similar to that of
_hard_reboot. Again, after a hypervisor reboot (or detection of downed
VMs on compute start), we should not assume the defined XML is valid.
The state or configuration of the VM, from Nova's perspective, may
have been changed while the system was down.

The post_live_migration_on_destination() method used to call to_xml()
without block_device_info. This would result in an on-disk XML without
any volume mappings. The compute manager has been updated to pass bdi
so that this XML can be generated and written correctly. The Mox stub
for this function has been replaced by a stub in the fake virt driver.

Change-Id: I4aa1068fa3aa54fdb7e690d46b6cf2e41bb20bc9
fix floating ip test that wasn't running

the associate_floating_ip negative test wasn't running because
the indent was wrong. This was uncovered when looking for unknown
names with pyflakes.

This makes the test run, and fixes the mispelling of floating to
make it actually pass.

Change-Id: I74397b8592d51a7fed249c96f17d3e71cdf82a7e
Fix get Floating ip pools action name to match with its policy

Get Floating IP Pools is always responding 403 (Forbidden) cause its method
name, which is also being used as action name, doesn't match with the name in
policy.json file.
I opted for this approach cause it also fixes the different names between the
extension (which is named floating **ip** pools instead of floating pools) and
the backend.
Another good practice would be change the default_floating_pool option to
default_float_ip_pool, but that would require change the conf file and possibly
break some compatibility.

Fixes bug 1091668

Change-Id: I2627e8b0f45c5c39bbbf1a4a12b448e1992fa4b4
fix mysql race in tests

because of testr, we can't assume the migrations tests run in
sequence, so they make run all at the same time. This is fine for
our in memory sqlite db, but when talking to a real external
database, not so good.

Since a second mysql test was added, we started racing on these
migrations them often hitting at the same time causing random fails
in gate.

Fix this by moving all the mysql tests into 1 test function, so we
won't race.

Fixes bug #1101874

Change-Id: I7627f3bd510266c99af018d355f960b352573759
Unpin testtools.

Change-Id: If760a7b6f8771d9f9ac2722c300032e715e34151
Fix incorrect use of context object

As in nova/availability_zones.py, the method get_host_availability_zone()
expects "context" as a module rather than a RequestContext object.
But for our preference, the argument "context" is better to be a
RequestContext object. So fix this by passing an context object into the
method.

* Fix the usage of argument "context"
* Add unittest for the module "availability_zones"

Fix bug lp:#1100598

Change-Id: I5886ba26131261d97be65f18e9492c40401c5a7f
Merge "Fix get Floating ip pools action name to match with its policy"
Merge "fix floating ip test that wasn't running"
Merge "Fix incorrect use of context object"
Merge "Unpin testtools."
Drop volume API

When volumes were removed from nova, api-paste.ini was not updated.
This removes the outdated sections of api-paste.ini.

Change-Id: I6dcc792ed87f6b02e5fdffb0af46a3fbf6b37404
Merge "fix mysql race in tests"
Merge "More consistent libvirt XML handling and cleanup"
Merge "Drop volume API"