~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/common/eventlet_backdoor.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright (c) 2012 Openstack, LLC.
 
4
# Administrator of the National Aeronautics and Space Administration.
 
5
# All Rights Reserved.
 
6
#
 
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
 
10
#
 
11
#         http://www.apache.org/licenses/LICENSE-2.0
 
12
#
 
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
 
17
#    under the License.
 
18
 
 
19
import gc
 
20
import traceback
 
21
 
 
22
import eventlet
 
23
import eventlet.backdoor
 
24
import greenlet
 
25
 
 
26
from nova import flags
 
27
from nova.openstack.common import cfg
 
28
 
 
29
eventlet_backdoor_opts = [
 
30
    cfg.IntOpt('backdoor_port',
 
31
               default=None,
 
32
               help='port for eventlet backdoor to listen')
 
33
    ]
 
34
 
 
35
FLAGS = flags.FLAGS
 
36
FLAGS.register_opts(eventlet_backdoor_opts)
 
37
 
 
38
 
 
39
def dont_use_this():
 
40
    print "Don't use this, just disconnect instead"
 
41
 
 
42
 
 
43
def find_objects(t):
 
44
    return filter(lambda o: isinstance(o, t), gc.get_objects())
 
45
 
 
46
 
 
47
def print_greenthreads():
 
48
    for i, gt in enumerate(find_objects(greenlet.greenlet)):
 
49
        print i, gt
 
50
        traceback.print_stack(gt.gr_frame)
 
51
        print
 
52
 
 
53
 
 
54
backdoor_locals = {
 
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
 
58
    'fo': find_objects,
 
59
    'pgt': print_greenthreads,
 
60
}
 
61
 
 
62
 
 
63
def initialize_if_enabled():
 
64
    if FLAGS.backdoor_port is None:
 
65
        return
 
66
 
 
67
    eventlet.spawn(eventlet.backdoor.backdoor_server,
 
68
                   eventlet.listen(('localhost', FLAGS.backdoor_port)),
 
69
                   locals=backdoor_locals)