在Openstack H版部署Nova Cell 时 ,终端输入nova service-list 和 nova host-list 命令将报错

 

关于Cell的基本介绍,可以参考贤哥的一篇文章:

    【OpenStack】G版中关于Nova的Cell  http://blog.csdn.net/lynn_kong/article/details/8564558

详细的代码分析,可以参考gaoxingnengjisuan的blog:

     OpenStack Nova-cell服务的源码解析(编者注:G版) http://blog.csdn.net/gaoxingnengjisuan/article/details/14216977

 

 

Cell的服务部署:

在Openstack H版部署Nova Cell 时 ,终端输入nova service-list 和 nova host-list 命令将报错_第1张图片

Cell的消息路由:

在Openstack H版部署Nova Cell 时 ,终端输入nova service-list 和 nova host-list 命令将报错_第2张图片

 

 按照官方的推荐部署方案部署:即API Cell只部署nova-api,nova-cells服务,在Child Cell中部署除nova-api之外的全部cell服务(在本人的实际部署中,nova-compute单独部署在另一个节点)

在部署完nova-cells的服务之后,API cell上输入nova-manage service list,输出正常,但只显示本机的nova服务:
 
Binary           Host                                   Zone             Status     State Updated_At
nova-cells       API-cell                             internal         enabled    :-)   2014-04-04 09:57:47
 
在Child Cell 或nova-Compute节点上,输入nova-manage service list,输出也正常,但也只显示本Cell的nova服务:
 
Binary                   Host                                 Zone             Status     State Updated_At
nova-cert                Cell                                 internal         enabled    :-)   2014-04-04 10:00:11
nova-conductor       Cell                                 internal         enabled    :-)   2014-04-04 10:00:19
nova-consoleauth     Cell                                internal         enabled    :-)   2014-04-04 10:00:12
nova-scheduler        Cell                                 internal         enabled    :-)   2014-04-04 10:00:12
nova-cells               Cell                                 internal         enabled    :-)   2014-04-04 10:00:11
nova-compute     Computer3                         nova             enabled    :-)   2014-04-04 10:00:13

 

但是,在任意节点 终端输入 nova service-list  nova   host-list 命令将报错:

命令报错:

ERROR: Theserver has either erred or is incapable of performing the requested operation.(HTTP 500) (Request-ID: req-dfa169cf-db9e-44c6-b51b-0d80e4a89e3b)

 

跟踪 API Cell 节点的 nova-api.log, 输出如下错误信息:

2014-04-04 15:17:25.151 3172 ERROR nova.api.openstack [req-dfa169cf-db9e-44c6-b51b-0d80e4a89e3b 836609a159f244738933dc7c5cb6266a d965a
339b99a4d2da2be18bd0334b9ff] Caught error: invalid literal for int() with base 10: 'api!cell@1'
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack Traceback (most recent call last):
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/api/openstack/__init__.py", line 1
19, in __call__
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack     return req.get_response(self.application)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1296, in send
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    application, catch_exc_info=False)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1260, in call_a
pplication
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    app_iter = application(self.environ, start_response)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack     return resp(environ, start_response)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/keystoneclient/middleware/auth_token.py
", line 539, in __call__
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack     return self.app(env, start_response)                               [26/1914]
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack     return resp(environ, start_response)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack     return resp(environ, start_response)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/routes/middleware.py", line 131, in __c
all__
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    response = self.app(environ, start_response)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack     return resp(environ, start_response)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack     resp = self.call_func(req, *args, **self.kwargs)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack     return self.func(req, *args, **kwargs)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py", line 938,
in __call__
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    content_type, body, accept)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py", line 997,
in _process_stack
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    action_result = self.dispatch(meth, request, action_args)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py", line 1078,
 in dispatch
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack     return method(req=request, **action_args)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/api/openstack/compute/contrib/serv
ices.py", line 139, in index
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    services = self._get_services_list(req, detailed)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/api/openstack/compute/contrib/serv
ices.py", line 117, in _get_services_list
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    services = self._get_services(req)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/api/openstack/compute/contrib/serv
ices.py", line 86, in _get_services
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    context, set_zones=True)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/compute/cells_api.py", line 469, in service_get_all
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    services)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/objects/base.py", line 606, in obj
_make_list
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    **extra_args)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/objects/service.py", line 67, in _
from_db_object
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    service[key] = db_service[key]
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/objects/base.py", line 405, in __s
etitem__
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack    setattr(self, name, value)
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack   File "/usr/lib/python2.7/dist-packages/nova/objects/base.py", line 66, in sett
er
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack     return setattr(self, get_attrname(name), typefn(value))
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack ValueError: invalid literal for int() with base 10: 'api!cell@1'
2014-04-04 15:17:25.151 3172 TRACE nova.api.openstack
2014-04-04 15:17:25.154 3172 INFO nova.api.openstack [req-dfa169cf-db9e-44c6-b51b-0d80e4a89e3b 836609a159f244738933dc7c5cb6266a d965a3
39b99a4d2da2be18bd0334b9ff] http://192.168.122.12:8774/v2/d965a339b99a4d2da2be18bd0334b9ff/os-services returned with HTTP 500
2014-04-04 15:17:25.155 3172 INFO nova.osapi_compute.wsgi.server [req-dfa169cf-db9e-44c6-b51b-0d80e4a89e3b 836609a159f244738933dc7c5cb
6266a d965a339b99a4d2da2be18bd0334b9ff] 192.168.122.14 "GET /v2/d965a339b99a4d2da2be18bd0334b9ff/os-services HTTP/1.1" status: 500 len
: 335 time: 0.1216350

 

 

后来查询了N久,发现社区已有人提出Bugs:https://bugs.launchpad.net/nova/+bug/1251043

并已解决:

  Reviewed: https://review.openstack.org/81282
  Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=0df94733f7283cbc1e9ae7d27f5cd443158cae8e

 

因为在Cell中,主机名的ID 前面加了一个前缀:cell routing path,所以格式为<cell routing path>@ID,而nova object模块里,会用一个int()的方法来将id的字符串变为整数,而int('api!cell@1')显然会报一个ValueError!

 

Patch 中给出的办法就是用一个代理类ServiceProxy,来处理附加在id前面的cell_paths,如下:

class ServiceProxy(object):
    def __init__(self, obj, cell_path):
        self._obj = obj
        self._cell_path = cell_path

    @property
    def id(self):
        return cells_utils.cell_with_item(self._cell_path, self._obj.id)

    def __getitem__(self, key):
        if key == 'id':
            return self.id

        return getattr(self._obj, key)

    def __getattr__(self, key):
        return getattr(self._obj, key)

 

 

目前,输入nova service-list,得到正常输出,返回各个节点的nova服务,问题解决:

 在Openstack H版部署Nova Cell 时 ,终端输入nova service-list 和 nova host-list 命令将报错_第3张图片

 

你可能感兴趣的:(openstack)