nova notification

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

时间: 2024-10-14 04:40:41

nova notification的相关文章

Neutron 是如何向 Nova 虚机分配固定IP地址的 (How Neutron Allocates Fixed IPs to Nova Instance)

Nova 虚机获取固定IP (Fixed IP)主要分为两个步骤: (1)在创建虚机过程中,Neutron 随机生成 MAC 和 从配置数据中分配一个固定IP 地址,并保存到 Dnsmasq 的 hosts 文件中,让 Dnsmasq 做好准备. (2)虚机在启动时向 Dnsmasq 获取 IP 地址 本文将分析该过程.整个过程涉及不同节点的几个模块: 下面将具体分析该过程. 1. 创建虚机时的数据流 Nova-compute 在创建虚机时,需要 Neutron 所做的主要事情之一就是分配一个

nova event机制分析

本文主要分析Nova的一个event机制,目前主要用于VIF plugin是的notification,可以实现Nova 和 Neutron直接VIF 状态信息的交互. 1. nova部分 vif_plugging_timeout配置参数的解释,用于定义创建VM时等待VIF准备好的时间 cfg.BoolOpt('vif_plugging_is_fatal', default=True, help="Fail instance boot if vif plugging fails"),

nova boot代码流程分析(五):VM启动从neutron-dhcp-agent获取IP与MAC

1.   network和subnet创建代码流程 [[email protected] ~(keystone_user1)]# neutron net-create demo-net [[email protected] ~(keystone_user1)]# neutron subnet-create  demo-net 1.1.1.0/24 --name demo-subnet --gateway 1.1.1.1 --enable_dhcp true 这里,我们主要分析上面两个命令的代码流

通知栏Notification在不同手机上显示的问题总结

可以参照http://blog.csdn.net/vipzjyno1/article/details/25248021,这里面关于通知的写的不错,也很全面,我的这篇主要是记录自己在适配上遇到的问题. 通知的统一的创建方式: NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext); 而通知的管理则是使用NotificationManager是用来管理通知的,使用如下:先初始化用到的系统服务,然后调

nova - nova base image id的生成算法

nova spawn instance的时候,会先create_image,下面是获取的base image的函数 def get_cache_fname(images, key):     """Return a filename based on the SHA1 hash of a given image ID.     Image files stored in the _base directory that match this pattern     are c

Apple Notification Center Service--ANCS【转】

Apple Notification Center Service 转自:http://studentdeng.github.io/blog/2014/03/22/ancs/ MAR 22ND, 2014 | COMMENTS 名词解释与约定 名词解释 Apple Notification Center Service 简称 ANCS. ANCS 服务(iOS设备,如iPhone,iPad等)的publisher 称为 Notification Provider. 任意的ANCS服务的clien

Notification Centers 通知中心

Notification Centers 通知中心 A notification center manages the sending and receiving of notifications. It notifies all observers of notifications meeting specific criteria. The notification information is encapsulated in NSNotification objects. Client o

Mobile Push Notification

In one embodiment, a method includes sending to a mobile client computing device a first notification through a real-time push service, the first notification including content and being associated with a stateful object; the method also includes, in

Java 线程第三版 第四章 Thread Notification 读书笔记

一.等待与通知 public final void wait() throws InterruptedException 等待条件的发生. public final void wait(long timeout) throws InterruptedException 等待条件的发生.如果通知没有在timeout指定的时间内发生,它还是会返回. public final void wait(long timeout, int nanos) throws InterruptedException