天天看點

用pdb調試OpenStack

ADMIN_PASSWORD=password
MYSQL_PASSWORD=stackdb
RABBIT_PASSWORD=stackqueue
SERVICE_PASSWORD=$ADMIN_PASSWORD
#enable_service rally
SERVICE_TOKEN=password

## vnc

#enable_service n-spice
#enable_service n-novnc
#enable_service n-xvnc

#GIT_BASE=https://code.csdn.net
# Reclone each time
#RECLONE=yes
RECLONE=no

## For Keystone
KEYSTONE_TOKEN_FORMAT=PKI

## For Swift
#SWIFT_REPLICAS=1
#SWIFT_HASH=011688b44136573e209e

# Enable Logging
LOGFILE=/opt/stack/logs/stack.sh.log
VERBOSE=True
LOG_COLOR=True
SCREEN_LOGDIR=/opt/stack/logs

# Pre-requisite
ENABLED_SERVICES=rabbit,mysql,key

## If you want ZeroMQ instead of RabbitMQ (don't forget to un-declare 'rabbit' from the pre-requesite)
#ENABLED_SERVICES+=,-rabbit,-qpid,zeromq

## If you want Qpid instead of RabbitMQ (don't forget to un-declare 'rabbit' from the pre-requesite)
#ENABLED_SERVICES+=,-rabbit,-zeromq,qpid

# Horizon (Dashboard UI) - (always use the trunk)
ENABLED_SERVICES+=,horizon
HORIZON_REPO=https://github.com/openstack/horizon
HORIZON_BRANCH=master

# Nova - Compute Service
ENABLED_SERVICES+=,n-api,n-crt,n-obj,n-cpu,n-cond,n-sch

######vnc
ENABLED_SERVICES+=,n-novnc,n-xvnc


#jjIMAGE_URLS+=",https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img"
#IMAGE_URLS+=",http://172.28.0.1/image/cirros-0.3.0-x86_64-disk.img"


# Nova Network - If you don't want to use Neutron and need a simple network setup (old good stuff!)
#ENABLED_SERVICES+=,n-net

## Nova Cells
#ENABLED_SERVICES+=,n-cell

# Glance - Image Service
ENABLED_SERVICES+=,g-api,g-reg

# Swift - Object Storage
#ENABLED_SERVICES+=,s-proxy,s-object,s-container,s-account

# Neutron - Networking Service
# If Neutron is not declared the old good nova-network will be used
ENABLED_SERVICES+=,q-svc,q-agt,q-dhcp,q-l3,q-meta,neutron

## Neutron - Load Balancing
ENABLED_SERVICES+=,q-lbaas

## Neutron - VPN as a Service
ENABLED_SERVICES+=,q-vpn

## Neutron - Firewall as a Service
ENABLED_SERVICES+=,q-fwaas

# VLAN configuration
#Q_PLUGIN=ml2
#ENABLE_TENANT_VLANS=True

# GRE tunnel configuration
Q_PLUGIN=ml2
ENABLE_TENANT_TUNNELS=True

# VXLAN tunnel configuration
#Q_PLUGIN=ml2
#Q_ML2_TENANT_NETWORK_TYPE=vxlan   

# Cinder - Block Device Service
VOLUME_GROUP="cinder-volumes"
ENABLED_SERVICES+=,cinder,c-api,c-vol,c-sch,c-bak

# Heat - Orchestration Service
ENABLED_SERVICES+=,heat,h-api,h-api-cfn,h-api-cw,h-eng
#IMAGE_URLS+=",http://fedorapeople.org/groups/heat/prebuilt-jeos-images/F17-x86_64-cfntools.qcow2"

# Ceilometer - Metering Service (metering + alarming)
#ENABLED_SERVICES+=,ceilometer-acompute,ceilometer-acentral,ceilometer-collector,ceilometer-api
#ENABLED_SERVICES+=,ceilometer-alarm-notify,ceilometer-alarm-eval

# Apache fronted for WSGI
#APACHE_ENABLED_SERVICES+=keystone,swift
APACHE_ENABLED_SERVICES+=keystone
           

以上為localrc檔案,用于devstack安裝時的配置檔案,用git clone一份devstack的源碼,将localrc檔案copy過去,然後./stack,就可以了。

1.  建立檔案creds:

exportSERVICE_TOKEN=xxx(3中輸入的密碼)

exportOS_TENANT_NAME=admin

exportOS_USERNAME=admin

export OS_PASSWORD=xxx

exportOS_AUTH_URL=http://localhost:5000/v2.0/

exportSERVICE_ENDPOINT=http://localhost:35357/v2.0

source creds就可以使用openstack了

2. 若想更改已安裝的元件,再./stack.sh即可

Pdb調試Havana過程

1.      修改代碼

在需要調試的地方加入:

import pdb; pdb.set_trace()(以在nova/compute/api.py:get_all()中加入pdb為例)

2.      重新開機服務

在相應的screen中用ctrl+c終止目前程序,然後按向上的方向鍵,就會出現啟動服務的指令,按enter服務就起來了。

3.      開始調試:

用pdb調試OpenStack

顯示有兩個screen

screen –x stack

進入如下界面:

用pdb調試OpenStack

最下一行表示,每一個程序都有一個screen。帶*号的表示目前的screen,可以同時按下ctrl+a+8和ctrl+a+2分别前進和後退,來切換不同的screen.

4.      在0$中輸入nova list;切換到4$ n-api:

用pdb調試OpenStack

5.      開始使用pdb進行調試

用pdb調試OpenStack

6. 實體機重新開機後,可使用rejoin-stack.sh啟動openstack服務

7. ctrl+a+shift+", 可以選擇screen , 主要就不需要通過ctrl + a  or ctrl + p 來回切換了:)。

參考資料

1.使用pdb調試openstack (How to debug openstackusing pdb )

http://blog.csdn.net/hackerain/article/details/8373597

2. linux screen 指令詳解

http://www.cnblogs.com/mchina/archive/2013/01/30/2880680.html

繼續閱讀