Deprecate root_helper in favor of rootwrap_config

Mark the root_helper option deprecated and introduce usage of
the rootwrap_config option instead. The root_helper option will
still fully be supported in Folsom, but will be removed in Grizzly.

Transition notes: you should replace:
root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf

by:
rootwrap_config=/etc/nova/rootwrap.conf

Implements bp deprecate-root-helper

Change-Id: I8dfc94e9b91f7ffc82d393b345f09409da347e78
Merge "Deprecate root_helper in favor of rootwrap_config"
Check instance lock in compute/api

This adds a check for the instance lock in compute/api.py, which:
1. Helps avoid the need to call into the manager just to be stopped
   by the lock there
2. Returns a failure to the user right away when an operation cannot
   be completed due to the lock
3. Avoids the potential for task_state to get into an unhappy state
   because a user unknowingly attempts an action whilst an instance
   is locked
4. Avoids the manager from having to re-do the lock check by
   stuffing a flag into RequestContext when the check has already
   been done by api.py

Various tests needed to be fixed up in order to pass fake instances
with the locked attribute. We could make the decorator ignore
instances without it, but I think it's more explicit to push that
requirement into the tests.

This fixes bug 872541

Change-Id: I1127e31d86a061a93a64ee1eb4a4d900d8bf49b5
Use function registration for policy checks

The original policy framework allowed new policy checks to be created
through inheritance.  This is somewhat clunky and unnecessary in
Python.  This change refactors policy.py to allow new policy checks
to be registered using an @register() decorator.  One consequence is
that HttpBrain is deprecated.

Care has been taken to ensure backwards compatibility; deprecation
warnings will be emitted for uses of HttpBrain or the inheritance-
based checks.

(Pull-up from openstack-common, with deprecation of HttpBrain.)

Change-Id: Ia9a6039a82fe4ebfa9b18e5eb93c21fffee90f09
Update usage of 'ip' to handle more return codes

Make sure that ip raises an exception.ProcessExecutionError unless
'ip' exits with a 0, 2, or 254.

0 = command executed correctly
2/254 = command has already been executed.

Change-Id: I55dd63ca7fc22bc133ab5fe722df4141c332a819
Signed-off-by: Chuck Short <chuck.short@canonical.com>
Simple refactor of some db api tests.

A few tests were using context.elevated instead of just passing the correct
project id to the instance_create function.

Change-Id: Ib54d079cbad823abd85dcca9e5cd813887169fb0
Remove unused imports

Change-Id: I9e307cd5bab2542f43948c96767811a769814341
Merge "Update usage of 'ip' to handle more return codes"
Merge "Check instance lock in compute/api"
Merge "Simple refactor of some db api tests."
Updates to the prep_resize scheduler rpc call.

I started looking at this because of the prep_resize rpc call in the compute
manager.  An API server calls prep_resize on the scheduler which then calls it
on a compute node.  I will need to make the same changes on the compute side,
but this is the first step.

The prep_resize call was taking two object IDs, an instance UUID and an
instance_type ID.  Both of these have been converted.  It now takes an instance
dict and an instance_type dict, instead.  It can also handle receiving the old
IDs for backwards compatibility.  prep_resize also took a topic argument that
was unused, so it has just been removed.

There are a number of changes in the scheduler code tied up in this to make it
more explicit about exactly what arguments are expected instead of just using
*args, **kwargs.

Part of blueprint no-db-messaging.

Change-Id: I4af18e5575e2bb60a410fc8edabf3d607c72aabc
Remove **kwargs from prep_resize in compute manager.

The only place where additional arguments were being passed in was via
the unit tests, and they aren't used.

Part of blueprint no-db-messaging.

Change-Id: I13f4a209ac9acc732966cb6e01bdbbcc3e3bd3c8
Remove instance_id fallback from cast_to_compute_host().

This removes some code that supported using either an instance id or
uuid when doing an instance update.  The db API no longer accepts an ID.
A UUID must be used or it will raise an exception.  I also updated the
unit tests to reflect this.

Change-Id: I5a9442f3b571f37950676e96e2f129ea45c55d78
Reduce db access in prep_resize in the compute manager.

This patch changes the arguments passed to prep_resize in the compute
manager.  Previously it took instance and instance_type IDs.  It now
receives a full dict for both of these.  This cuts down on database
access needed on the compute node.

This method was not previously in the compute rpcapi module, so it has
been added there.  The scheduler had a bit of work done ot get it to use
the rpcapi module for prep_resize, as well.

Part of blueprint no-db-messaging.

Change-Id: Idadbf4fc624d5d1b128f758a46c61b3c840b9898
Update args to _set_vm_state_and_notify.

This patch removes *args and **kwargs from _set_vm_state_and_notify.
The only additional argument used was request_spec, so just list it out
explicitly.

Change-Id: I64590a2d79c2d303e7c936a4c3b1545eecfd0f2b
Use explicit args in run_instance scheduler code.

This patch goes through code paths related to run_instance in the
scheduler to use explicit arguments instead of **kwargs.  I'm trying to
work out exactly what data is getting passed through the system when an
instance is created, so that I can make the no-db-messaging related
changes.  This patch helps clarify some things.

Part of blueprint no-db-messaging.

Change-Id: Id83fc1e399e1d5c75af6dd3c8972b8ba9d706af1