zoukankan      html  css  js  c++  java
  • nova event

     nova处理neutron发送过来的event事件。暂时追踪nova event部分代码

    tail -f /var/log/nova/nova-api.log  下面就是一个事件  Creating event network-vif-plugged:

    对代码不熟的话直接代码中的关键字 

    调用create方法

    def create(self, req, body):

     1 if accepted_events:
     2             '''
     3                self.compute_api.external_instance_event 方法在这里===>  /usr/lib/python2.7/site-packages/nova/compute/api.py 
     4                
     5                里面就是这个方法
     6                def external_instance_event(self, context, instances, events):    
     7             '''
     8             LOG.info(_LI(type(self.compute_api)))
     9             self.compute_api.external_instance_event(
    10                 context, accepted_instances, accepted_events)
    11         else:
    12             msg = _('No instances found for any event')
    13             raise webob.exc.HTTPNotFound(explanation=msg)
    14 
    15         # FIXME(cyeoh): This needs some infrastructure support so that
    16         # we have a general way to do this
    17         robj = wsgi.ResponseObject({'events': response_events})
    18         robj._code = result
    19         #LOG.info(_LI("=======>def create:"))
    20         ''' robj.obj对象中的内容,内容大概可以看出是跟某个vm有关的并且status字段是completed.
    21         {'events': [{u'status': 'completed', u'tag': u'8e781f3d-1b9b-4e37-a699-ae7a122c89f0', u'name': u'network-vif-plugged', u'server_uuid': u'1013d789-735b-4047-878b-beda1809f6be', 'code': 200}, 
    22                    {u'status': 'completed', u'tag': u'd4e29058-4d6c-4a8a-9741-e59c8f986df2', u'name': u'network-vif-plugged', u'server_uuid': u'9cf6584f-2fa5-4aea-ac37-cc2bc152012a', 'code': 200}]}
    23         '''
    24         #LOG.info(_LI(":::::::>%s"%repr(robj.obj)))
    25         return robj

    改完后重启nova-api服务器,查看日志就能看出

    继续上面代码self.compute_api.external_instance_event 去发送rpc调用

    /usr/lib/python2.7/site-packages/nova/compute/api.py

    for host in instances_by_host:
                # TODO(salv-orlando): Handle exceptions raised by the rpc api layer
                # in order to ensure that a failure in processing events on a host
                # will not prevent processing events on other hosts
                  
                #这里循环的host就是计算节点名字 
                LOG.info("host:%s"%repr(host))
    
                '''
                [InstanceExternalEvent(data=<?>,instance_uuid=327acc17-4495-4d30-94b4-7a3d5d2e0504,name='network-vif-plugged',status='completed',tag='7b03e150-be1e-4f19-89a9-534846abf955'), 
    
    InstanceExternalEvent(data=<?>,instance_uuid=86cd3487-9664-4f5a-a3d7-30e2dfe7c3da,name='network-vif-plugged',status='completed',tag='9e1a2e3a-090e-405c-beca-de4baa18a02d'), 
    
    InstanceExternalEvent(data=<?>,instance_uuid=5bf2966a-5323-4882-895e-da9bb0b61a03,name='network-vif-plugged',status='completed',tag='816ea553-e6bb-4975-bf44-1350f7737e34')]         
                状态完成
                status='completed'
                tag='816ea553-e6bb-4975-bf44-1350f7737e34' 计算节点上创建的虚拟机网卡名称如:tap816ea553-e6 
                '''
                #打印内容是上面的注释,
                LOG.info("events_by_host[host]:%s"%repr(events_by_host[host]))
    
                # compute_rpcapi ====> /usr/lib/python2.7/site-packages/nova/compute/rpcapi.py 下面有个external_instance_event方法
                self.compute_rpcapi.external_instance_event(
                    context, instances_by_host[host], events_by_host[host],
                    host=host)

    追踪self.compute_rpcapi.external_instance_event

     1 def external_instance_event(self, ctxt, instances, events, host=None):
     2         LOG.info(_LI("external_instance_event::::::>rpcapi"))
     3         #LOG.info(_LI("ctxt::%s"%repr(ctxt)))
     4         #LOG.info("instances::%s"%repr(instances[0]))
     5         #LOG.info(_LI("events::%s"%repr(events)))
     6         #LOG.info(_LI("host::%s"%repr(host)))      
     7 
     8 
     9         instance = instances[0]
    10         cctxt = self.router.by_instance(ctxt, instance).prepare(
    11             server=_compute_host(host, instance),
    12             version='4.0')
    13         
    14         #ccxt.cast 异步方式,api调用的方法和传递的值
    15         #self.compute_rpcapi.external_instance_event(
    16         #        context, instances_by_host[host], events_by_host[host],
    17         #        host=host)
    18        
    19         cctxt.cast(ctxt, 'external_instance_event', instances=instances,
    20                    events=events)

    追踪到这里出现了一个问题这个方法  无法追踪下去了  external_instance_event  如果有大神看到指点小弟一下哈哈!!!

     /usr/lib/python2.7/site-packages/nova/compute/manager.py  正常应该是这个文件下的  

  • 相关阅读:
    【08月20日】A股滚动市净率PB历史新低排名
    沪深300指数的跟踪基金最近1年收益排名
    基金前15大重仓股持仓股排名
    中证500指数的跟踪基金最近1年收益排名
    【08月14日】A股ROE最高排名
    【08月13日】预分红股息率最高排名
    【08月09日】北上资金持股比例排名
    最近一月研报推荐次数最多的最热股票
    JDK源码阅读-------自学笔记(二十一)(java.util.ArrayList详细版集合类)
    MyBatis-Plus 3.0.3 Sql注入器添加,即全局配置Sql注入器,sqlInjector改写
  • 原文地址:https://www.cnblogs.com/menkeyi/p/7081342.html
Copyright © 2011-2022 走看看