OpenStack 集群事件通知

OpenStack Cluster Event Notification

到目前为止,根据我对 OpenStack Python SDK 的理解,我能够读取管理程序、服务器实例,但是,我没有看到 API 来接收和处理更改notification/events 用于集群上发生的操作,例如添加新 VM、删除现有 VM 等

有一个类似的旧 post(大约 2016 年),我很好奇通知处理是否有任何变化? Notifications to external systems from openstack

我看到一份文档,其中讨论了通过消息总线发出通知,指示服务中发生的不同事件。

https://docs.openstack.org/ironic/latest/admin/notifications.html

我有以下问题:

Does Openstack Python SDK support notification APIs?
How do I receive/monitor notifications for VM related changes?
How do I receive/monitor notifications for compute/hypervisor related changes?
How do I receive/monitor notifications for Virtual Switch related changes?

我看到其他 post,例如 Notifications in openstack,他们推荐使用使用数据库的 Ceilometer 项目。有没有比使用像 Ceilometer 这样完全不同的服务更轻量级的解决方案?

在此先感谢您在这方面的帮助。

据我所知,Openstack SDK没有提供这样的功能。

Ceilometer 也帮不了你。它仅通过 RPC 上的轮询和通知来收集数据。您仍然需要自己轮询云高仪的数据。除此之外,ceilometer 本身就有问题,它只会增长并会炸毁你的数据库,这就是为什么你在使用 ceilometer 时也应该使用 gnocchi。

目前我只看到 3 种可能的解决方案:

  1. 编写您自己的工具,它在后台永久运行并通过 OpenstackSDK 和 REST-API 请求定期收集数据。

  2. 写一些东西,它通过 oslo-messaging (RPC) 接收通知,就像 ceilometer 一样。请参阅配置中的 oslo_messaging_notifications 部分:https://docs.openstack.org/ocata/config-reference/compute/config-options.html#id35 (neutron has also such an option) and use messagingv2 as driver like ceilometer does. But be aware here, that not every event creates a notification. The list of the ceilometer meter-data should give a good overview of which event are creating a notification and what can only be collected by polling: https://docs.openstack.org/ceilometer/pike/admin/telemetry-measurements.html。通知事件的数量真的很少,所以它可能没有提供您想要的所有事件。

  3. 在配置 logoslo_messaging_notifications 部分使用 driver 将通知写入日志文件,并编写一个简单的程序来读取日志文件并处理或转发读取的内容。这是与第 2 个问题相同的问题,并非每个事件都会创建一个通知(在本例中为日志条目)。这也有问题,通知和事件日志也是在计算节点上创建的(据我所知),因此您必须通过您的工具监视所有计算节点。

基于我不知道的事实,编写一个通过 RPC 收集通知的工具需要多少工作量,而且因为我不知道,如果您想观看的所有事件真的创建了一个通知(基于这里的概述:https://docs.openstack.org/ceilometer/pike/admin/telemetry-measurements.html),我更喜欢 number 1.

这是创建工具的最简单方法,该工具定期通过 REST-API 运行 GET 请求,并将结果作为您自己的自定义通知转发到所需的目的地。

我按照以下参考资料进行操作。另外,与此代码和视频的作者聊天。

https://github.com/gibizer/nova-notification-demo/blob/master/ws_forwarder.py
https://www.youtube.com/watch?v=WFq5JWXa9AM

此外,我还遇到了其他问题:

  • 默认情况下,由于 IPTABLE 规则,OpenStack 服务器不允许您从远程主机连接到 RabbitMQ 总线。您必须在 IP table.
  • 中启用对 RabbitMQ 端口的访问