远程调试openstack
之前一直没有找到方法调试openstack的horizon代码,现在终于找到方法了,特别感谢下面这篇博客,讲解非常清晰:
http://blog.csdn.net/tantexian/article/details/38295599 但是其中有一个问题就是需要在源程序代码中添加代码以供调试用,这样调试完了还要去删除这些代码,十分不方便。所以我就想在此基础上做些改进,具体情况如下:
Komodo下载地址:http://pan.baidu.com/s/13i5Zk
PythonRemoteDebuggingClient下载地址:http://code.activestate.com/komodo/remotedebugging/
一、本地安装配置Komodo
1、Edit->Preferences:配置python解释器。
2、Debug-> Listen for debuging connections:确保勾选上,这样才能远程调试。
3、Debug->Listener Status:查看配置的远程连接端口。(Edit-> Preferences->Debugger->Connection:可以自定义远程连接端口)
二、远程服务器配置
解压PythonRemoteDebuggingClient并进入该目录!
cd pythonlib/dbgp
1.
cp client.py client.py.bak
vim client.py
在头部添加:
import stat
在brk函数处进行修改:
def brk(file=None,host = '10.10.24.96', port = 9000, idekey = '',
preloadScript = None, logLevel = logging.WARN):
filepath=os.path.abspath(file)
tmp_file='/tmp/brk_file'
if not os.path.exists(tmp_file):
with open(tmp_file,'a') as f:
f.write(filepath)
f.write('\n')
os.chmod(tmp_file,os.stat(tmp_file).st_mode|stat.S_IWGRP|stat.S_IWOTH)
else:
with open(tmp_file,'a') as f:
f.write(filepath)
f.write('\n')
说明:这里设置/tmp/brk_file为临时记录文件,记录那些添加了断点设置代码的文件路径信息。10.10.24.96为Komodo所在的机器IP地址,非调试的代码所在地址。9000为调试设置的端口。
2.
cp __init__.py __init__.py.bak
vim __init__.py
在头部添加:
from dbgp.client import brk
3.
cp -r pythonlib/dbgp /usr/lib/python2./site-packages/
cp pydbgp /usr/bin/
chmod a+x /usr/bin/pydbgp
三、设置删除断点程序
1.
vim brk-clean
添加如下内容:
#!/usr/bin/python
import subprocess
import os
import sys def delete_brk(file):
cmd="sed -i "+r"'/import dbgp/d' "+file+";"
cmd=cmd+"sed -i "+r"'/dbgp.brk(__file__)/d' "+file
proc=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
out,err=proc.communicate()
if proc.returncode:
raise RuntimeError('Failed:\n%s' % err) def main(): result=True
#if tmp file not exist or is not a file
if not os.path.exists('/tmp/brk_file') or not os.path.isfile('/tmp/brk_file'):
print "/tmp/brk_file doesn't exist!\nCheck if it has been deleted Or you didn't set any breakpoint !"
result=False
return result #find files with brk
file_list=[]
with open('/tmp/brk_file','r') as f:
file_list=f.readlines()
try:
os.remove('/tmp/brk_file')
except:
print r"Error:Can't delete /tmp/brk_file!"
result=False for file in file_list:
file=file.rstrip('\n')
if os.path.exists(file) and os.path.isfile(file):
delete_brk(file)
print 'Deleted brk in file: '+file+r"!"
else:
print 'Error:'+file+r"doesn't exist or isn't a file"
result=False return result if __name__=='__main__':
#delete the brk in a file
if len(sys.argv)>1:
file=sys.argv[1]
if not os.path.exists(file) or not os.path.isfile(file):
print file+r" doesn't exist!"
sys.exit()
delete_brk(file)
print "Breakpoints in "+file+" have been cleaned up !"
sys.exit() result=main()
if result:
print 'Brk-Clean Completed !'
2.
mv brk-clean /usr/bin
chmod a+x /usr/bin/brk-clean
四、在需要设置断点的地方插入断点设置代码
import dbgp
dbgp.brk(__file__)
五、运行需要调试的程序或重启相关服务
这里提供一个启动openstack服务的脚本,非本人所写 ,不过用起来也不错,参考链接:https://github.com/liuan/openstack-x
六、调试完后记得删除断点设置代码
brk-clean
七、如果有必要,须重启相关服务
远程调试openstack的更多相关文章
- 利用pycharm远程调试openstack代码
1.安装pycharm专业版 本文安装pycharm 2016.2.3专业版.网上教程较多,这里不做详细介绍,只要到pycharm官网上下载应用程序进行安装即可. 2.pycharm配置 (1)首先按 ...
- [转]使用eclipse+pydev远程调试OpenStack
作者:张华 发表于:2014-01-17版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 ( http://blog.csdn.net/quqi99 ) 1, ...
- Python远程调试Openstack
前言 由于开始着手openstack运维方面的东西,我这颗大白菜必须要学一学这个高端的东西啦. 准备 pycharm依赖于专业版(这里需要注意,我前面浪费了好多时间...)下载并安装pycharm,网 ...
- Openstack Pycharm 的远程调试
问题背景 最近再研究openstack cinder api的时候遇到了个问题:使用命令行调用API的时候,使用domain的token时,会产生一个错误,但是通过cinder的api都无法确定产生错 ...
- 微信公众号开发之VS远程调试
目录 (一)微信公众号开发之VS远程调试 (二)微信公众号开发之基础梳理 (三)微信公众号开发之自动消息回复和自定义菜单 前言 微信公众平台消息接口的工作原理大概可以这样理解:从用户端到公众号端一个流 ...
- tomcat开发远程调试端口以及利用eclipse进行远程调试
一.tomcat开发远程调试端口 方法1 WIN系统 在catalina.bat里: SET CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compi ...
- Visual Studio 2012远程调试中遇到的问题
有的时候开发环境没问题的代码在生产环境中会某些开发环境无法重现的问题,或者需要对生产环境代码进行远程调试该怎么办? Vs已经提供给开发者远程调试的工具 下面简单讲讲该怎么用,前期准备:1.本地登录账户 ...
- 使用Eclipse进行远程调试
转自:http://blog.csdn.net/sunyujia/article/details/2614614 今天决定做件有意义的事,写篇图文并茂的blog,为什么要图文并茂?因为很多事可能用语言 ...
- 微信公众号开发系列教程一(调试环境部署续:vs远程调试)
http://www.cnblogs.com/zskbll/p/4080328.html 目录 C#微信公众号开发系列教程一(调试环境部署) C#微信公众号开发系列教程一(调试环境部署续:vs远程调试 ...
随机推荐
- 子元素设置margin-top后,父元素跟随下移的问题
子元素设置margin-top后,父元素跟随下移的问题 <!DOCTYPE html> <html lang="en"> <head> < ...
- linux计划任务 学习笔记
原文链接: http://www.tsingfeng.com/?tag=cronjob 本文说的计划任务是指linux的Cronjob.语法 下面是个简单的计划任务: 10 * * * * /usr/ ...
- Beta阶段第2周/共2周 Scrum立会报告+燃尽图 02
此作业要求参见:[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2410] 版本控制地址 https://git.coding.net ...
- 团队Alpha冲刺(三)
目录 组员情况 组员1(组长):胡绪佩 组员2:胡青元 组员3:庄卉 组员4:家灿 组员5:凯琳 组员6:丹丹 组员7:家伟 组员8:政演 组员9:鸿杰 组员10:刘一好 组员11:何宇恒 展示组内最 ...
- 第六章 过滤器Filter
Filter概述 Filter不用于客户端请求,只用于对request,response进行修改或对context,session,request事件进行监听. 1.概述 如上图,多个filter组成 ...
- Scrum 项目准备4.0
4.0----------------------------------------------- 1.准备看板. 形式参考图4. 2.任务认领,并把认领人标注在看板上的任务标签上. 先由个人主动领 ...
- 用PS做PNG格式底色是透明的logo
有时我们需要底色为透明色的logo图片,但是一般的图片底色都是白色的,覆盖在其它图片上会显示白色. 本文介绍如何用PS CS6制作透明底色的图片. 1.首先我们确定所选图片的大小(即分辨率大小),在资 ...
- 【JavaScript&jQuery】单选框radio,复选框checkbox,下拉选择框select
HTML: <!DOCTYPE html> <html> <head> <title></title> <meta charset=& ...
- [二十]SpringBoot 之 (多)文件上传
(1)新建maven Java project 新建一个名称为spring-boot-fileuploadmaven java项目 (2)在pom.xml加入相应依赖: <project xml ...
- [您有新的未分配科技点]数位dp:从懵X到板子(例题:HDU2089 不要62)
数位dp主要用来处理一系列需要数数的问题,一般套路为“求[l,r]区间内满足要求的数/数位的个数” 要求五花八门……比如“不出现某个数字序列”,“某种数的出现次数”等等…… 面对这种数数题,暴力的想法 ...