Python PySphere 和 PyVmomi 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21326448/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the Difference between PySphere and PyVmomi?
提问by anukalp
I need to write python scripts to automate time configuration of Virtual Machines running on a ESX/ESXi host. I don't know which api to use... I am able to find to python bindings for VMWare apis viz. PySphere and PyVmomi. Could anyone please explain what is the difference between them, which one should be used?
我需要编写 python 脚本来自动化在 ESX/ESXi 主机上运行的虚拟机的时间配置。我不知道要使用哪个 api...我可以找到 VMWare apis viz 的 python 绑定。PySphere 和 PyVmomi。谁能解释一下它们之间有什么区别,应该使用哪一个?
Thanks!
谢谢!
采纳答案by joshk0
I'm the (now former) VMware employee who helped get this out the door.
我是帮助解决这个问题的(现在是前任)VMware 员工。
pyVmomi represents the official bindings of the vSphere API released by VMware. The functions and object names map directly to what's documented in the vSphere Web Services SDK. It takes a while to get used to it and we should add some docs helping people map what's in the official documentation to what you can actually use in pyVmomi, but it's really all there and you'll probably get more functionality than you would out of pysphere which wraps official API calls in API-specific function names.
pyVmomi 代表 VMware 发布的 vSphere API 的官方绑定。函数和对象名称直接映射到vSphere Web Services SDK 中记录的内容。需要一段时间来适应它,我们应该添加一些文档来帮助人们将官方文档中的内容映射到您可以在 pyVmomi 中实际使用的内容,但它真的就在那里,您可能会获得比使用更多的功能pysphere 将官方 API 调用包装在特定于 API 的函数名称中。
One of the most complete projects that uses the vSphere API via pyVmomi is another project I helped open source, ThinApp Factory. I recommend looking at its source (specifically linked.py) to see what is possible.
通过 pyVmomi 使用 vSphere API 的最完整的项目之一是我帮助开源的另一个项目ThinApp Factory。我建议查看其来源(特别是links.py)以了解可能的情况。
If things are hard to use or unclear about pyVmomi, please feel free to file a bug on our Github. Have fun!
如果 pyVmomi 难以使用或不清楚,请随时在我们的 Github上提交错误。玩得开心!
回答by Toure Dunnon
Just as Josh suggested its a clean interface to VMWare API it also support a few versions of python which is nice as it will allow you to migrate from lets say python2.7 to python3.3.
正如 Josh 建议它为 VMWare API 提供一个干净的接口一样,它也支持几个版本的 python,这很好,因为它允许您从 python2.7 迁移到 python3.3。
回答by Hyman
Also pyVmomi directly corresponds to the vsphere Managed Object browser. So get to the MOB on the vcenter, figure out what properties you need, the methods as well and the 1 to 1 name convention from pyvmomi helps you achieve what you want. (in short, you learn about vsphere api and are good to go with pyvmomi, no mapping in the head needed)
另外pyVmomi直接对应vsphere Managed Object浏览器。因此,请访问 vcenter 上的 MOB,找出您需要的属性、方法以及来自 pyvmomi 的 1 对 1 命名约定可帮助您实现您想要的。(简而言之,您了解了 vsphere api 并且很适合使用 pyvmomi,不需要头部映射)
回答by Banjer
pyvmomiis the officialpython library from VMWare for the vSphere API.
pyvmomi是来自 VMWare 的用于 vSphere API的官方Python 库。
Related links:
相关链接:
- pyvmomi community samples- example code
- ezmomi- pyvmomi-based cli for common tasks like deploying VMs. (Shameless plug)
- pyvmomi 社区示例- 示例代码
- ezmomi- 基于 pyvmomi 的 cli,用于部署 VM 等常见任务。(无耻的插头)

