示例#1
0
文件: utils.py 项目: south270/nova
def notify_about_volume_attach_detach(context, instance, host, action, phase,
                                      volume_id=None, exception=None, tb=None):
    """Send versioned notification about the action made on the instance
    :param instance: the instance which the action performed on
    :param host: the host emitting the notification
    :param action: the name of the action
    :param phase: the phase of the action
    :param volume_id: id of the volume will be attached
    :param exception: the thrown exception (used in error notifications)
    :param tb: the traceback (used in error notifications)
    """
    fault, priority = _get_fault_and_priority_from_exc_and_tb(exception, tb)
    payload = instance_notification.InstanceActionVolumePayload(
            context=context,
            instance=instance,
            fault=fault,
            volume_id=volume_id)
    notification = instance_notification.InstanceActionVolumeNotification(
            context=context,
            priority=priority,
            publisher=notification_base.NotificationPublisher(
                    host=host, source=fields.NotificationSource.COMPUTE),
            event_type=notification_base.EventType(
                    object='instance',
                    action=action,
                    phase=phase),
            payload=payload)
    notification.emit(context)
示例#2
0
def notify_about_volume_attach_detach(context,
                                      instance,
                                      host,
                                      action,
                                      phase,
                                      binary='nova-compute',
                                      volume_id=None,
                                      exception=None):
    """Send versioned notification about the action made on the instance
    :param instance: the instance which the action performed on
    :param host: the host emitting the notification
    :param action: the name of the action
    :param phase: the phase of the action
    :param binary: the binary emitting the notification
    :param volume_id: id of the volume will be attached
    :param exception: the thrown exception (used in error notifications)
    """
    fault, priority = _get_fault_and_priority_from_exc(exception)
    payload = instance_notification.InstanceActionVolumePayload(
        instance=instance, fault=fault, volume_id=volume_id)
    notification = instance_notification.InstanceActionVolumeNotification(
        context=context,
        priority=priority,
        publisher=notification_base.NotificationPublisher(context=context,
                                                          host=host,
                                                          binary=binary),
        event_type=notification_base.EventType(object='instance',
                                               action=action,
                                               phase=phase),
        payload=payload)
    notification.emit(context)