码迷,mamicode.com
首页 > 其他好文 > 详细

nova notification

时间:2015-11-17 18:16:53      阅读:369      评论:0      收藏:0      [点我收藏+]

标签:

Nova:
in nova/manager.py
instance usage 发送方式:
    method(context, ‘compute.instance.%s‘ % event_suffix, usage_info)
event_suffix = "create.error" / "create.end"
self.notifier = rpc.get_notifier(self.service_name, self.host)

def get_notifier(service, host=None, publisher_id=None):
    assert NOTIFIER is not None
    if not publisher_id:
        publisher_id = "%s.%s" % (service, host or CONF.host)
    return NOTIFIER.prepare(publisher_id=publisher_id)


Ceilometer处理:
ceilometer/compute/notification/instance.py
event_types = [‘compute.instance.*‘]


VM privisoning latency:
nova/compute/api.py:    def _provision_instances(self, context, instance_type, min_count,
    rpc.get_notifier(service, host).info(context,
                                         ‘compute.instance.update‘, payload)

是否需要参数:notify_on_state_change
nova/nofitication.py
3中通知
1. notify_on_state_change
(可以是空,vm_state,vm_and_task_state)
用在send_update/send_update_with_states
send_update 用在conductor.manager.py
send_update_with_states在compute.api

发送compute.instance.update类型的消息
最后都是调用
def _send_instance_update_notification中的
    rpc.get_notifier(service, host).info(context,
                                         ‘compute.instance.update‘, payload)

send_update调用了send_update_with_states,另外send_update_with_states还被用在了nova/compute/api.py 的_provision_instances
notifications.send_update_with_states(context, instance, None,
              vm_states.BUILDING, None, None, service="api")
publisherid= service + host

问题是这个在ceilometer被转换成sample了。


2. notify_api_faults
用在send_api_fault
    rpc.get_notifier(‘api‘).error(common_context.get_current() or
                                  nova.context.get_admin_context(),
                                  ‘api.fault‘,
                                  payload)
publish ID:‘api‘
类型:‘api.fault‘

用在nova/api/openstack/__init__.py:作为一个FaultWrapper的中间件
etc/nova/api-paste.ini:paste.filter_factory = nova.api.openstack:FaultWrapper.factory

3. default_notification_level
用在def notify_decorator(name, fn):
发送方式publishid=‘api‘+CONF.default_publisher_id or CONF.host 级别info, 类型

nova/utils.py:                  ‘nova.compute.api:%s‘ % (notify_decorator)
需要配置:
    cfg.ListOpt(‘monkey_patch_modules‘,
                default=[
                  ‘nova.api.ec2.cloud:%s‘ % (notify_decorator),
                  ‘nova.compute.api:%s‘ % (notify_decorator)
                  ],

4. nova/compute/utils.py
def notify_about_instance_usage
method(context, ‘compute.instance.%s‘ % event_suffix, usage_info)
param event_suffix: Event type like "delete.start" or "exists

被waper    
def _notify_about_instance_usage(self, context, instance, event_suffix,
                                     network_info=None, system_metadata=None,
                                     extra_usage_info=None, fault=None):
        compute_utils.notify_about_instance_usage(
            self.notifier, context, instance, event_suffix,
            network_info=network_info,
            system_metadata=system_metadata,
            extra_usage_info=extra_usage_info, fault=fault)

nova/compute/manager.py:
self._notify_about_instance_usage(context, instance, ‘create.start‘,


create.error

所有的nova.compute.api
需要配置monkey_patch=true,默认修饰nova.compute.api和nova.api.ec2.cloud


notify_opts = [
    cfg.StrOpt(‘notify_on_state_change‘,
        help=‘If set, send compute.instance.update notifications on instance ‘
             ‘state changes.  Valid values are None for no notifications, ‘
             ‘"vm_state" for notifications on VM state changes, or ‘
             ‘"vm_and_task_state" for notifications on VM and task state ‘
             ‘changes.‘),
    cfg.BoolOpt(‘notify_api_faults‘, default=False,
        help=‘If set, send api.fault notifications on caught exceptions ‘
             ‘in the API service.‘),
    cfg.StrOpt(‘default_notification_level‘,
               default=‘INFO‘,
               help=‘Default notification level for outgoing notifications‘),
    cfg.StrOpt(‘default_publisher_id‘,
               help=‘Default publisher_id for outgoing notifications‘),


event_type‘: u‘compute.instance.reboot.start
provining vm:
def _build_and_run_instance
- self._notify_about_instance_usage(context, instance, ‘create.start‘,
-- notify_about_instance_usage 发出:
compute.instance.create.start
compute.instance.exists
compute.instance.create.end

nova notification

标签:

原文地址:http://www.cnblogs.com/allcloud/p/4972163.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!