Show Table of Contents
A.10. 使用 VDSM Hooking 模块
VDSM 提供了一个 Python hooking 模块,可以用来帮助开发 VDSM hook 脚本。这个模块以一个实例的形式提供,只对使用 Python 的 VDSM hook 有效。
这个 hooking 模块可以读一个虚拟机的 libvirt XML 并把数据保存为一个 DOM 项。然后,Python 内置的
xml.dom 库 (http://docs.python.org/release/2.6/library/xml.dom.html) 就可以对这个项进行操作。
然后,这个被修改的项就可以通过 hooking 模块存回到 libvirt XML。hooking 模块提供了以下的功能:
表 A.2. Hooking 模块功能
| 名称 | 参数 | 描述 |
|---|---|---|
tobool | string | 把字符串 "true" 或 "false" 转换为一个布尔(Boolean)值 |
read_domxml | - | 读虚拟机的 libvirt XML,并把它转换为一个 DOM 项 |
write_domxml | DOM object | 根据 DOM 项写虚拟机的 libvirt XML |

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.