1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright (c) 2012 Openstack, LLC.
4
# Administrator of the National Aeronautics and Space Administration.
7
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8
# not use this file except in compliance with the License. You may obtain
9
# a copy of the License at
11
# http://www.apache.org/licenses/LICENSE-2.0
13
# Unless required by applicable law or agreed to in writing, software
14
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
# License for the specific language governing permissions and limitations
23
import eventlet.backdoor
26
from nova import flags
27
from nova.openstack.common import cfg
29
eventlet_backdoor_opts = [
30
cfg.IntOpt('backdoor_port',
32
help='port for eventlet backdoor to listen')
36
FLAGS.register_opts(eventlet_backdoor_opts)
40
print "Don't use this, just disconnect instead"
44
return filter(lambda o: isinstance(o, t), gc.get_objects())
47
def print_greenthreads():
48
for i, gt in enumerate(find_objects(greenlet.greenlet)):
50
traceback.print_stack(gt.gr_frame)
55
'_': None, # So it doesn't interfere with the global
56
'exit': dont_use_this, # So we don't exit the entire process
57
'quit': dont_use_this, # So we don't exit the entire process
59
'pgt': print_greenthreads,
63
def initialize_if_enabled():
64
if FLAGS.backdoor_port is None:
67
eventlet.spawn(eventlet.backdoor.backdoor_server,
68
eventlet.listen(('localhost', FLAGS.backdoor_port)),
69
locals=backdoor_locals)