风味操作通知

https://blueprints.launchpad.net/nova/+spec/flavor-notifications

Nova 目前不会在风味创建/更新/删除操作时发送通知。

风味有一组基本属性(id、name、cpus、ram、disk、swap、ephemeral、rxtx)。私有访问的风味还具有允许使用它们的租户集合。最后,它们还具有其他信息(可以通过 API 的 get_keys() 访问,也称为 extra_specs)。

在这些信息发生变化时,接收创建、更新和删除通知将会很有用,并且对于创建和更新,有效载荷应包含与从 API 访问相同的信息。

问题描述

用例

像 Searchlight[1] 这样的外部系统想要索引风味,这使得查询大量风味更快、更高效。这将允许强大的查询以及跨 OpenStack 资源(风味是其中之一)的统一搜索。

维护者希望在添加、更新或销毁风味时收到通知。

提议的变更

将为以下操作添加版本化通知

  • Flavor.create

  • Flavor.save_projects

  • Flavor.add_access

  • Flavor.remove_access

  • Flavor.save_extra_specs

  • Flavor.destroy

注意

风味没有更新 API,风味的更新操作与删除和创建结合在一起。

备选方案

数据模型影响

不需要数据库模式更改。

以下新对象将添加到风味中,用于 create、save_projects 和 save_extra_specs。

@base.NovaObjectRegistry.register
class FlavorNotification(notification.NotificationBase):
    # Version 1.0: Initial version
    VERSION = '1.0'
    fields = {
        'payload': fields.ObjectField('FlavorPayload')
    }

@base.NovaObjectRegistry.register
class FlavorPayload(notification.NotificationPayloadBase):
    # Version 1.0: Initial version
    SCHEMA = {
        'id': ('flavor', 'flavorid'),
        'name': ('flavor', 'name'),
        'ram': ('flavor', 'memory_mb'),
        'vcpus': ('flavor', 'vcpus'),
        'disk': ('flavor', 'root_gb'),
        'ephemeral': ('flavor', 'ephemeral_gb'),
        'swap': ('flavor', 'swap'),
        'rxtx_factor': ('flavor', 'rxtx_factor'),
        'vcpu_weight': ('flavor', 'vcpu_weight'),
        'disabled': ('flavor', 'disabled'),
        'is_public': ('flavor', 'is_public'),
        'extra_specs': ('flavor', 'extra_specs'),
        'projects': ('flavor', 'projects'),
    }
    VERSION = '1.0'
    fields = {
        'id': fields.StringField(),
        'name': fields.StringField(nullable=True),
        'ram': fields.IntegerField(),
        'vcpus': fields.IntegerField(),
        'disk': fields.IntegerField(),
        'ephemeral': fields.IntegerField(),
        'swap': fields.IntegerField(),
        'rxtx_factor': fields.FloatField(nullable=True),
        'vcpu_weight': fields.IntegerField(nullable=True),
        'disabled': fields.BooleanField(),
        'is_public': fields.BooleanField(),
        'extra_specs': fields.DictOfStringsField(),
        'projects': fields.ListOfStringsField(),
    }
    def __init__(self, flavor):
        super(FlavorPayload, self).__init__()
        self.populate_schema(flavor=flavor)

以下新对象将添加到风味中,用于 destroy

@base.NovaObjectRegistry.register
class FlavorDestroyNotification(notification.NotificationBase):
    # Version 1.0: Initial version
    VERSION = '1.0'
    fields = {
        'payload': fields.ObjectField('FlavorDestroyPayload')
    }

@base.NovaObjectRegistry.register
class FlavorDestroyPayload(notification.NotificationPayloadBase):
    # Version 1.0: Initial version
    SCHEMA = {
        'id': ('flavor', 'flavorid'),
    }
    VERSION = '1.0'
    fields = {
        'id': fields.StringField(),
    }
    def __init__(self, flavor):
        super(FlavorDestroyPayload, self).__init__()
        self.populate_schema(flavor=flavor)

NotificationBase 的定义可以在 [2] 中找到。

REST API 影响

安全影响

通知影响

针对风味不同操作的新通知将发送到名为“versioned_notifications”的 amqp topic。

其他最终用户影响

性能影响

如果启用了版本化通知,将发送通知。

其他部署者影响

开发人员影响

实现

负责人

主要负责人

liyingjun

工作项

  • 为风味添加版本化通知

依赖项

测试

除了单元测试,还将添加新的功能测试用例来覆盖新的通知,并且测试将断言存储的通知样本的有效性。

文档影响

参考资料

[1]: Searchlight: https://docs.openstack.org/developer/searchlight/index.html

[2]: 版本化通知: https://docs.openstack.org/developer/nova/notifications.html#versioned-notifications

历史

修订版

发布名称

描述

Ocata

引入