Partially revert "Remove unused scheduler functions"

This partially reverts commit 2aaa3d2860eed7574c5df64a8ceeb8a6adf23460.

The problem pointed out by this bug is that these changes introduce a
non-backwards compatibile change to the schedulre rpc API.  There are a
couple of acceptable ways to deal with this:

1) Leave most of the code and only remove the client side.  This means
   that a message sent from an earlier version will still work.  This is
   the ideal situation for almost *all* changes to rpc APIs.  We have to
   make a habit of this to eventually be able to support rolling
   upgrades.

2) Leave the manager methods, but simply have them raise an exception.
   This is a bit better than removing the method because the error
   can be made more explicit and obvious.  Otherwise, the operator will
   get "no such method" rpc exceptions, which will seem a bit more
   bizzare.

   An example of when this option makes sense is commit
   cac332c39645286a11c009094a86f62d02752183.  This patch refactored the
   live migration code is such a significant way that making it
   backwards compatibile seemed rather difficult to do.  The old rpc
   methods stuck around but just raise an exception.  The potential
   failure is just that live migration would fail, but the exception
   makes it obvious that an upgrade must be completed for live migration
   to work.

The current patch implements #2 in the case of get_service_capabilities,
since it hasn't been used since pre-essex.  Approach #2 is taken for
get_host_list() as well.  It was used until fairly recently, but was
broken, including being broken in Essex.  The fix that went into Essex
for this makes it no longer use RPC.

Fix bug 1029262.

Change-Id: I74c7d2a3e88b3a4f114e7da62c56f0481ee64a64
Sync w/ latest openstack common log.py.

Includes the following updates for openstack-common's log.py:

    Remove code to clear basicConfig root log handlers

    Removes some old Nova specific code to clear out the log handlers
    from Nova's logging basicConfig. This code is arguably Nova specific
    and doesn't really belong in openstack-common's generic logging
    configuration.

    Additionally, This code was actually removing the root logger used
by
    some command line tools and binaries and hiding log messages that
should
    have otherwise gone to the console.

    Fixes LP Bug #1029577.

Change-Id: Ic6a6862e5bc357846bf3202186c7e24622d3bb87
fix unmounting of LXC containers

There were two issues here.

1. There was a global object stored for all instances,
thus the last mounted instance was always unmounted.

2. Even if there was only a single LXC instance in use,
the global object would be lost on restart of Nova.

Therefore we reset the internal state for the mount object,
by passing in the mount point to destroy_container(),
and querying the device in use for that mount point.

Fixes bug: 971621
Change-Id: I5442442f00d93f5e8b82f492d62918419db5cd3b
Migrate a logging change from common:

commit 58404a1a9461900367dbb7a8b3f2f98441e12959
Author: Mate Lakat <mate.lakat@citrix.com>
Date:   Tue Jul 31 17:53:57 2012 +0100

    Install a qualified except hook.

    Fixes bug 1031351.

    As an Exception is raised, it was not visible in the log, because
    it wasn't qualified. The fix sets up the exception hook to be
    qualified as the product_name.

Change-Id: I38c48d0dd2ac885fcb226310b6039be667af9e0d
Update reset_db to call setup if _DB is None.

This resolves issues when running individual tests that require
a database. With this fix I can once again run individual test
modules that make use of the database. For example:

  ./run_tests.sh test_libvirt

Previously this would fail with database errors.

Fixes LP Bug #1032738.

Change-Id: Icce7ac9414f0e19eece44819a217634947de7f73
Fix broken pep8 exclude processing.

First of all, our pep8 exclude was excluding openstack, to trap
for not doing pep8 checks on openstack/common, which comes from elsewhere.
But, pep8 strips filenames down to basename when doing exclude checks on
them, which makes no sense. To fix this, grab the two functions from pep8,
fix them, and monkeypatch them from within hacking.py.

Patch has been submitted upstream as:

  https://github.com/jcrocholl/pep8/pull/111

Also, changed the exclude to catch just openstack/common.

Change-Id: If0b18ae828e74203f84a8b6f8b4ba0100b3bbc59
Handle InstanceNotFound in libvirt list_instances.

Updates the libvirt driver so that InstanceNotFound is
handled within the list_instances function. This
can occur if an instance is deleted while the
list_instances function is processing.

Fixes LP Bug #1032741.
Change-Id: I97c9533f8b37957e71237c610ac360fbf9f57b9a
Remove unused variables

Change-Id: I137c9522257e8b5fcb13c1e9fe6cb4e0c442e33c
import missing module time

time is used in line 2450 but is never imported

Change-Id: I8b5690c5562768050416d0921cbae7dd0af769c9
Rename _self to self according to Python convention

If self is never used, it should probably be defined as a classmethod
or a staticmethod, instead of _self. Use "self" for now to stick
to python convention, and leave proper refactor to other patches.

Change-Id: I71de42ffd3e83c57772b6490c52f24bcd9d1f1ea
Merge "Rename _self to self according to Python convention"
Audit log messages in nova/compute/api.py

To include instance whereever possible.

Change-Id: Ic3b86eed17ebee90766af9e2c3c74f33c7a09432
Update list_instances to catch libvirtError.

Commit be590cfa4b0025587a956642dc859902d577f3f7 caught (and tested
for) the wrong exception. lookupByID throws a libvirtError.

Fixes LP Bug #1032741.

Change-Id: I6745660658df4d0f2bc4cd423e173200fc23cd8e
Merge "Remove unused variables"
Merge "Fix broken pep8 exclude processing."
Merge "Partially revert "Remove unused scheduler functions""
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
Merge "fix unmounting of LXC containers"
Require eventlet >= 0.9.17

0.9.17 was released 2012-08-03 and
includes two particular fixes related to OpenStack

1. https://bitbucket.org/which_linden/eventlet/issue/123/
Fix an exception thrown by epoll in certain cases.
This can cause jenkins to deadlock, triggered for example by:
https://review.openstack.org/#/c/10767/

2. https://bitbucket.org/which_linden/eventlet/issue/115/
   https://bugs.launchpad.net/nova/+bug/903199
Fix a significant memory leak of _DummyThread objects.

Change-Id: I449f30afde7d162ed2c0df149174f1250ef378ca