Coverage for nova/debugger.py: 48%

19 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-04-24 11:16 +0000

1# Copyright 2010 United States Government as represented by the 

2# Administrator of the National Aeronautics and Space Administration. 

3# Copyright 2011 Justin Santa Barbara 

4# All Rights Reserved. 

5# 

6# Licensed under the Apache License, Version 2.0 (the "License"); you may 

7# not use this file except in compliance with the License. You may obtain 

8# a copy of the License at 

9# 

10# http://www.apache.org/licenses/LICENSE-2.0 

11# 

12# Unless required by applicable law or agreed to in writing, software 

13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

15# License for the specific language governing permissions and limitations 

16# under the License. 

17 

18# NOTE(markmc): this is imported before monkey patching in nova.cmd 

19# so we avoid extra imports here 

20 

21import sys 

22 

23 

24def enabled(): 

25 return ('--remote_debug-host' in sys.argv and 

26 '--remote_debug-port' in sys.argv) 

27 

28 

29def init(): 

30 import nova.conf 

31 CONF = nova.conf.CONF 

32 

33 # NOTE(markmc): gracefully handle the CLI options not being registered 

34 if 'remote_debug' not in CONF: 34 ↛ 35line 34 didn't jump to line 35 because the condition on line 34 was never true

35 return 

36 

37 if not (CONF.remote_debug.host and CONF.remote_debug.port): 37 ↛ 40line 37 didn't jump to line 40 because the condition on line 37 was always true

38 return 

39 

40 from oslo_log import log as logging 

41 LOG = logging.getLogger(__name__) 

42 

43 LOG.debug('Listening on %(host)s:%(port)s for debug connection', 

44 {'host': CONF.remote_debug.host, 

45 'port': CONF.remote_debug.port}) 

46 

47 try: 

48 from pydev import pydevd 

49 except ImportError: 

50 import pydevd 

51 

52 pydevd.settrace(host=CONF.remote_debug.host, 

53 port=CONF.remote_debug.port, 

54 stdoutToServer=False, 

55 stderrToServer=False) 

56 

57 LOG.warning('WARNING: Using the remote debug option changes how ' 

58 'Nova uses the eventlet library to support async IO. This ' 

59 'could result in failures that do not occur under normal ' 

60 'operation. Use at your own risk.')