【问题标题】:List all vm of ESXI with python用python列出所有ESXI的vm
【发布时间】:2020-10-07 15:08:10
【问题描述】:

我试图列出我的 esxi 中的所有 vms,

from pyVim.connect import SmartConnect, Disconnect
import requests
import ssl

requests.packages.urllib3.disable_warnings()
context = ssl._create_unverified_context()

si = SmartConnect(host="test.dev",
                  port=443,
                  user="username",
                  pwd="password",
                  sslContext=context)

client = si.RetrieveContent()

我有这条消息:

 File "test.py", line 2
    import requests
    ^

感谢您的回复

【问题讨论】:

  • 您的错误信息还有更多内容吗?
  • 我只有这个错误

标签: python vmware vsphere


【解决方案1】:

我的方式:python pexpect + "vim-cmd vmsvc/getallvms" 命令

  • python pexpect 与 ESXi 主机建立 SSH 连接
  • “vim-cmd vmsvc/getallvms”命令 -> 列出 ESXi 主机上的所有虚拟机

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 1970-01-01
  • 2015-10-24
  • 2016-05-11
  • 1970-01-01
  • 2016-08-17
  • 2019-10-01
  • 2022-12-04
  • 1970-01-01
  • 2017-05-01
相关资源
最近更新 更多