python-3.x Pyvmomi如何禁用/启用vsan静默检查

k5ifujac  于 2023-10-21  发布在  Python
关注(0)|答案(2)|浏览(118)

bounty还有2天到期。回答此问题可获得+200声望奖励。Progs希望引起更多的注意这个问题。

我一直在阅读pyvmomi的文档,但它不清楚如何从托管对象vim.cluster.VsanVcClusterHealthSystem使用函数VsanHealthSetVsanClusterSilentChecks,它没有说如何初始化或如何示例化对象或显示任何如何使用它的例子。
我试过这样的代码:

vchs = vim.cluster.VsanVcClusterHealthSystem('vsan-cluster-health-system')
check = vchs.VsanHealthSetVsanClusterSilentChecks(cluster, None, alarm_list)

这段代码抛出了一个异常,但描述性不强:

VsanVcClusterHealthSystem

这就是异常错误消息的全部内容。
VsanHealthSetVsanbrowterSilentChecks的Pyvmomi文档

zed5wv10

zed5wv101#

我认为您需要从服务示例的content属性中检索VsanVcClusterHealthSystem对象!
比如这样:

from pyVim import connect

#don't forget to replace vcenter_server, username and password with yours
si = connect.SmartConnectNoSSL(host="vcenter_server", user="username", pwd="password")

#get the content property of the service instance
content = si.RetrieveContent()

#get the vSphere API root folder
root_folder = content.rootFolder

#get the cluster object by name and ensure that the cluster object is correctly obtained from the root folder
cluster = root_folder.childEntity[0]

#get the VsanVcClusterHealthSystem object from the cluster
vchs = cluster['vsan-cluster-health-system']

#calling the VsanHealthSetVsanClusterSilentChecks function
check = vchs.VsanHealthSetVsanClusterSilentChecks(cluster, None, alarm_list)
v7pvogib

v7pvogib2#

原来pyvmomi本身不能做到这一点,我需要使用vSAN Management SDK for Python

相关问题