@@ -0,0 +1,2372 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4%0A%0A# Copyright (c) 2012 Openstack, LLC.%0A# Administrator of the National Aeronautics and Space Administration.%0A# All Rights Reserved.%0A#%0A#    Licensed under the Apache License, Version 2.0 (the %22License%22); you may%0A#    not use this file except in compliance with the License. You may obtain%0A#    a copy of the License at%0A#%0A#         http://www.apache.org/licenses/LICENSE-2.0%0A#%0A#    Unless required by applicable law or agreed to in writing, software%0A#    distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A#    License for the specific language governing permissions and limitations%0A#    under the License.%0A%0Aimport gc%0Aimport pprint%0Aimport sys%0Aimport traceback%0A%0Aimport eventlet%0Aimport eventlet.backdoor%0Aimport greenlet%0A%0Afrom openstack.common import cfg%0A%0Aeventlet_backdoor_opts = %5B%0A    cfg.IntOpt('backdoor_port',%0A               default=None,%0A               help='port for eventlet backdoor to listen')%0A    %5D%0A%0ACONF = cfg.CONF%0ACONF.register_opts(eventlet_backdoor_opts)%0A%0A%0Adef _dont_use_this():%0A    print %22Don't use this, just disconnect instead%22%0A%0A%0Adef _find_objects(t):%0A    return filter(lambda o: isinstance(o, t), gc.get_objects())%0A%0A%0Adef _print_greenthreads():%0A    for i, gt in enumerate(find_objects(greenlet.greenlet)):%0A        print i, gt%0A        traceback.print_stack(gt.gr_frame)%0A        print%0A%0A%0Adef initialize_if_enabled():%0A    backdoor_locals = %7B%0A        'exit': _dont_use_this,      # So we don't exit the entire process%0A        'quit': _dont_use_this,      # So we don't exit the entire process%0A        'fo': _find_objects,%0A        'pgt': _print_greenthreads,%0A    %7D%0A%0A    if CONF.backdoor_port is None:%0A        return%0A%0A    # NOTE(johannes): The standard sys.displayhook will print the value of%0A    # the last expression and set it to __builtin__._, which overwrites%0A    # the __builtin__._ that gettext sets. Let's switch to using pprint%0A    # since it won't interact poorly with gettext, and it's easier to%0A    # read the output too.%0A    def displayhook(val):%0A        if val is not None:%0A            pprint.pprint(val)%0A    sys.displayhook = displayhook%0A%0A    eventlet.spawn(eventlet.backdoor.backdoor_server,%0A                   eventlet.listen(('localhost', CONF.backdoor_port)),%0A                   locals=backdoor_locals)%0A

Copy eventlet_backdoor into common from nova.