用pdb.set_trace()设断点,跟nova/api/openstack/compute/servers.py - detail() 流程
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用pdb.set_trace()设断点,跟nova/api/openstack/compute/servers.py - detail() 流程相关的知识,希望对你有一定的参考价值。
由
curl -s -H "X-Auth-Token: $OS_TOKEN" http://192.168.153.128:8774/v2.1/servers/detail | python -m json.tool 命令;
得到结果:
{
"servers": [] 注:因为servers是核心资源,所有返回为空。
}
1/opt/stack/nova/nova/api/openstack/compute/servers.py(210)detail() pdb.set_trace()
11/opt/stack/nova/nova/api/openstack/wsgi.py(867)__getattribute__() :
12/opt/stack/nova/nova/api/openstack/compute/servers.py(215)_get_servers() :"""Returns servers, based on search options specified."""
###search_opts.update(req.GET)
121/usr/local/lib/python2.7/dist-packages/webob/request.py(813)GET(): """Return a MultiDict containing all the variables from the QUERY_STRING."""
122/usr/local/lib/python2.7/dist-packages/webob/multidict.py(255)keys():
13/opt/stack/nova/nova/api/openstack/compute/servers.py(1106)_get_server_search_options():"""Return server search options allowed by non-admin."""
14/opt/stack/nova/nova/api/openstack/api_version_request.py(126)is_supported():"""Check if API request version satisfies version restrictions."""
###search_options : (‘reservation_id‘, ‘name‘, ‘status‘, ‘image‘, ‘flavor‘, ‘ip‘, ...)
15/opt/stack/nova/nova/api/openstack/compute/servers.py(1187)remove_invalid_options():"""Remove search options that are not valid for non-admin API/context."""
16/opt/stack/nova/nova/api/openstack/common.py(521)is_all_tenants():"""Checks to see if the all_tenants flag is in search_opts"""
17> /opt/stack/nova/nova/api/openstack/compute/servers.py(332)_get_servers()
-> limit, marker = common.get_limit_and_marker(req):
171/opt/stack/nova/nova/api/openstack/common.py(236)get_limit_and_marker():"""Get limited parameter from request."""
18> /opt/stack/nova/nova/api/openstack/compute/servers.py(333)_get_servers()
-> sort_keys, sort_dirs = common.get_sort_params(req.params):
181> /usr/local/lib/python2.7/dist-packages/webob/request.py(846)params()
182> /opt/stack/nova/nova/api/openstack/common.py(145)get_sort_params()
-> def get_sort_params(input_params, default_key=‘created_at‘,default_dir=‘desc‘):"""Processes the parameters to create a list of sort keys and sort directions that correspond to the ‘sort_key‘ and ‘sort_dir‘ parameter values."""
### return sort_keys, sort_dirs -> ([‘created_at‘], [‘desc‘])
19> /opt/stack/nova/nova/api/openstack/compute/servers.py(337)_get_servers()
-> expected_attrs.append(‘services‘)
20> /opt/stack/nova/nova/api/openstack/compute/servers.py(343)_get_servers()
-> expected_attrs = self._view_builder.get_show_expected_attrs(expected_attrs)
201> /opt/stack/nova/nova/api/openstack/compute/views/servers.py(92)get_show_expected_attrs()
-> def get_show_expected_attrs(self, expected_attrs=None):
###return sorted(list(set(self._show_expected_attrs + expected_attrs)))
21> /opt/stack/nova/nova/api/openstack/compute/servers.py(347)_get_servers()
-> instance_list = self.compute_api.get_all(elevated or context,search_opts=search_opts, limit=limit, marker=marker,expected_attrs=expected_attrs,
sort_keys=sort_keys, sort_dirs=sort_dirs)
211--Call--
> /opt/stack/nova/nova/compute/api.py(2226)get_all()
-> def get_all(self, context, search_opts=None, limit=None, marker=None,expected_attrs=None, sort_keys=None, sort_dirs=None):"""Get all instances filtered by one of the given parameters."""
22> /opt/stack/nova/nova/api/openstack/compute/servers.py(213)detail()
-> return servers
221> /opt/stack/nova/nova/api/openstack/extensions.py(338)wrapped()->{‘servers‘: []}
-> return f(*args, **kwargs)
222> /opt/stack/nova/nova/api/openstack/wsgi.py(749)dispatch()->{‘servers‘: []}
-> return method(req=request, **action_args)
223> /opt/stack/nova/nova/api/openstack/wsgi.py(417)__exit__()
-> def __exit__(self, ex_type, ex_value, ex_traceback):
224> /opt/stack/nova/nova/api/openstack/wsgi.py(669)_process_stack()
-> if not response:
225> /opt/stack/nova/nova/api/openstack/wsgi.py(705)_process_stack()-><Respons...c 200 OK>
-> return response
226> /opt/stack/nova/nova/api/openstack/wsgi.py(607)__call__()-><Respons...c 200 OK>
-> content_type, body, accept)
227> /usr/local/lib/python2.7/dist-packages/webob/dec.py(195)call_func()-><Respons...c 200 OK>
-> return self.func(req, *args, **kwargs)
> /usr/local/lib/python2.7/dist-packages/webob/dec.py(133)__call__()
-> if resp is None:
(Pdb) n
> /usr/local/lib/python2.7/dist-packages/webob/dec.py(136)__call__()
-> if isinstance(resp, text_type):
(Pdb) n
> /usr/local/lib/python2.7/dist-packages/webob/dec.py(138)__call__()
-> if isinstance(resp, bytes):
(Pdb) n
> /usr/local/lib/python2.7/dist-packages/webob/dec.py(142)__call__()
-> if resp is not req.response:
(Pdb) n
> /usr/local/lib/python2.7/dist-packages/webob/dec.py(143)__call__()
-> resp = req.response.merge_cookies(resp)
(Pdb) n
> /usr/local/lib/python2.7/dist-packages/webob/dec.py(144)__call__()
-> return resp(environ, start_response)
(Pdb) n
--Return--
> /usr/local/lib/python2.7/dist-packages/webob/dec.py(144)__call__()->[‘{"servers": []}‘]
-> return resp(environ, start_response)
(Pdb) n
--Return--
> /usr/local/lib/python2.7/dist-packages/webob/dec.py(144)__call__()->[‘{"servers": []}‘]
-> return resp(environ, start_response)
(Pdb) n
> /usr/local/lib/python2.7/dist-packages/routes/middleware.py(144)__call__()
-> try:
以上是关于用pdb.set_trace()设断点,跟nova/api/openstack/compute/servers.py - detail() 流程的主要内容,如果未能解决你的问题,请参考以下文章