使用pyVmomi API,如何获取主机维护模式状态?

时间:2019-02-16 19:45:34

标签: python pyvmomi esx

我正在编写Python脚本,以便远程管理ESXi主机(ssh终端)。

到目前为止,我设法将主机系统(ESXi)置于维护模式并退出,但我找不到任何方法来获取主机状态(如果它已经处于维护模式)。

API文档(https://code.vmware.com/apis/196/vsphere#/doc/vim.HostSystem.html#enterMaintenanceMode)中存在此InMaintenanceMode状态,但我无法访问它。

c = SmartConnect(host=host, user=user, pwd=pwd, sslContext=s)
cont = c.RetrieveContent()
atexit.register(Disconnect, c) 

objview = c.content.viewManager.CreateContainerView(c.content.rootFolder, [vim.HostSystem], True)

#enter in Maintenance Mode
objview.view[0].EnterMaintenanceMode(0)

#exit the Maintenance Mode
objview.view[0].ExitMaintenanceMode(0)

你能帮我吗?

0 个答案:

没有答案