Push 'Error' result from event to instance action.

Currently a failed event stores an 'Error' result but in order to see
which actions have failed it would require grabbing each one through the
api to see the events.  This patch adds 'Error' to the message field of
the instance action so that any actions with failures can be seen from
the initial listing of actions on an instance.

Change-Id: Ieeb798c47211ab00fe5b767dc1f18a665549ba01
sync oslo log updates

this helps address the issue where syslog gets overloaded and we
loose the ability to figure out what's going on in clients like
nova-manage

Change-Id: Iedde5ed4e8e23e204be4fa7a19e9514acf2ebf86
Standardize the coverage initializations.

Now when we measure coverage repeatedly, the coverage data of
nova-api is accumulated but the ones of other nova services are
reset each time.
This is due to create new "coverage" class each time
"_start_coverage_telnet" method is executed.

This patch limits creating "coverage" class the first time
the method is executed.

Fixes bug 1122720

Change-Id: Ia900c96113bee65362ccb7c4c1975535d814d835
Remove unused nova.db.api:instance_get_all_by_reservation

Change-Id: I55192773eaa18eb81ffb2b5ec3567b09116b0d1e
Unpin routes dependency version

Fixes bug #1133258

It looks like we should be fine with 1.13 and have no reason to expect
future versions will break us.

Cinder and Quantum both require >=1.12.3 too.

Change-Id: Ice0649d98e2a46505503072c07509fe274f195b6
Unpin PasteDeploy dependency version

Fixes bug #1133262

There are no newer releases of PasteDeploy than 1.5.0 and we have no
reason to believe newer versions will break us. Indeed, if an
incompatible version is released, we will want to know about it quickly.

Change-Id: I331b33b16ea50202886b19bf5c4060d9fa46d5ec
Make allocate_for_instance() return only info about ports allocated

Previously, the compute manager was filtering the results based on the
port id that the user requested. However, if they do not pass one (which
is valid) then we can not do the filter and we fail. This makes the
allocation function do the filtering, which should not affect the normal
use case where it is only called once, since all the ports returned were
allocated at that time.

The manager filter behavior is thus removed and a test is added to
verify that the allocate method does the right thing the second time
around.

This fixes the fallout found after fixing the actual cause of bug 1131264

Change-Id: I8f3af96051268503596007491af365e8ce28f5b3
Use min_ram of original image for snapshot, even with VHD

When snapshotting an instance there seems to be no reason that min_ram
can't be set based off of the original image in all cases.  This relaxes
the restriction that VHD backed instances set min_ram for snapshots
based on the current instance.

Bug 1133524

Change-Id: I3779c48d7325f3f0bde496f43a70017fe79d2835
Make sure no duplicate forward rules can exist.

Some failure conditions can cause floating forwards to not be properly
removed. We know that duplicate floating rules will never work, so
even if we have had other failures there is no need to create duplicate
forward rules. This patch fixes the issue by removing all existing
forwards for a floating ip before adding new ones. It adds a method
to IptablesTable to remove rules by regex and includes tests for new
method and the specific case of a duplicate forward.

Fixes bug 1133527

Change-Id: Iaf5df8406fc49e92bac328cd81ffda1969b77d68
Improve hackings docstring detection

Previously: def foo():\n    a = '''This is not a docstring'''
would be counted as a docstring even though it isn't.

Fix this and add docstring tests.

Fix bug 1100912

Change-Id: Id4d4aa382713eea340720e166e418262ba68eaaf
Improve output msgs for _compare_result

In case of errors, the messages are now more detailed.
Fixes bug 1133621

Change-Id: I7747d7c4dcaf2199dc55139ee0235f6adca1ad36
Adds retry on upload_vhd for xapi glance plugin

Add a retry for the xapi glance plugin to handle transient issues
when uploading the vhd.

An example issue we're seeing is a connection timeout:

['XENAPI_PLUGIN_FAILURE', 'upload_vhd', 'error',
		"(110, 'Connection timed out')"]

To work around transient issues such as a connection timeout, we
should retry based on glance_num_retries before outright failing.

Change-Id: Ice6fdd3dd39ef40e5997d69209aaafa66bff5d6e
Fixes: bug #1134493
Return proper error messages while disassociating floating IP

Currently, when a floating IP is not associated with an instance, and if we try
to disassociate it, a response likes "HTTP/1.1 404 Not Found" will be returned,
it is not proper, so change it to "HTTP/1.1 422 Unprocessable Entity" with body
likes '{"computeFault": {"message": "Floating ip 172.24.4.225 is not associated
with instance a33857af-b18b-4b88-a5cc-7d84c7fd41c8.", "code": 422}}'.

Fixes bug: #1129719

Change-Id: I18194ccf59edb5eb2bcd52a65f38d5632fef95d3
Ensure that FORWARD rule also supports DHCP

The previous fix only addressed the INPUT rules and not the
FORWARD rule.

Adds FORWARD rule to ensure that DHCP traffic is forwarded correctly.

Fixes bug 1131223

Change-Id: Ie0d365ba1ba1014bdd2bfc944123c17c4e415d6e
Make compute manager revert crashed migrations on init_host()

This should provide a path to cleanup partial migrations by reverting
them back to the original state instead of leaving them in limbo. Note
that libvirt needs a change to make this work, in the case where the
unconfirmed instance's directory is still present and needs to be
removed before the rollback.

The libvirt, xenapi and powervm drivers are modified here, and tests
are added to confirm their compliance with the proper behavior.

Addresses bug 1131588

Change-Id: I85bc0f6e9cda10aa85328199d107a3ff6e240b96
Add instance_type_get() to virt api

...and remove the use of instance['extra_specs'] from the libvirt and
baremetal virt drivers. Also remove the hack in instance_update()
which places them there in the first place.

Fixes bug 1133572

Change-Id: I39e9fabb28b48dc52ec47f58d76b0bf2c6ee0204
Fallback coverage backdoor telnet connection to lo

This commit adds a fallback condition for the telnet connection.
If trying to establish a connection to the backdoor fails with
ECONNREFUSED the extension will then try to connect to the same
port on the lo device. Eventlet backdoors currently open on the
lo interface and this is to cover the common (and CI) use case
where the hostname doesn't resolve to 127.0.0.1.

Using the fallback was done to avoid adding a new config option
to specify that the hostname that is in the DB for the service
doesn't resolve to the lo device, and that the extension should
use just use localhost.

Change-Id: I0321db68cbccf0cddf13d91a77dfb744bb456d87
Don't use instance['instance_type'] for scheduler filters in migration

Instead, pull a fresh copy from the database, which has the proper
extra_specs cleanup which everyone downstream of us expects.

Fixes bug 1136430

Change-Id: Ifcb9feff8291096eed7c198b8e7a35c3c38ca93e
Fix deprecated network api

The rpc-only network api is deprecated in Grizzly, but it should still
be able to function.

Change summary:
* Remove update_cache kwyword argument to get_instance_network_info
* Add conductor_api keyword argument to get_instance_network_info
* Add blanket **kwargs for future compat to get_instance_network_info
* Pass instance['uuid'] as instance_id kwarg in _get_instance_nw_info
* Add conductor_api keyword argument to remove_fixed_ip_from_instance
  and add_fixed_ip_to_instance
* Add blanket **kwargs for future compat to remove_fixed_ip_from_instance
  and add_fixed_ip_to_instance
* Pass empty rxtx_factor in remove_fixed_ip_from_instance and
  add_fixed_ip_to_instance for rpcapi compat
* Add blanket **kwargs for future compat to deallocate_for_instance
* Add conductor_api and security_groups to allocate_for_instance
* Add blanket **kwargs for future compat to allocate_for_instance
* Pass instance['uuid'] as instance_id kwarg in allocate_for_instance

Fix Bug 1134512

Change-Id: I6791df1bf1ac2456c5e83ec5ae47b0226409cf95
Pep8/pyflakes cleanup of deprecated_api

* Reformats code better in line with hacking guidelines

Change-Id: I27fa5d7321c56155d1f1f3b6a35105e35e95e0f1