使用pyVmomi获取每个ESX的ESX列表和系统设置(Getting List of ESXs and system settings per ESX using pyVmomi)

编程入门 行业动态 更新时间:2024-10-27 22:28:48
使用pyVmomi获取每个ESX的ESX列表和系统设置(Getting List of ESXs and system settings per ESX using pyVmomi)

什么是以下esxcli命令的平行pyVmomi API:

esxcli system settings advanced list --option /DataMover/HardwareAcceleratedMove esxcli system settings advanced list --option /DataMover/HardwareAcceleratedInit esxcli system settings advanced list --option /VMFS3/HardwareAcceleratedLocking esxcli system settings advanced list --option /VMFS3/EnableBlockDelete esxcli storage nmp device list

我想获取驻留在特定数据中心的所有ESX的此信息

谢谢,

What are the parallel pyVmomi API for the following esxcli commands:

esxcli system settings advanced list --option /DataMover/HardwareAcceleratedMove esxcli system settings advanced list --option /DataMover/HardwareAcceleratedInit esxcli system settings advanced list --option /VMFS3/HardwareAcceleratedLocking esxcli system settings advanced list --option /VMFS3/EnableBlockDelete esxcli storage nmp device list

I would like to get this info for all ESXs that resides in a specific datacenter

Thanks,

最满意答案

import atexit from pyVim import connect from pyVmomi import vmodl from pyVmomi import vim import tools.cli as cli def print_host_info(host_machine): """ Print information for a particular host machine """ print host_machine.config.network.dnsConfig.hostName print host_machine.config.product.version for option in host_machine.config.option: if option.key in ('VMFS3.UseATSForHBOnVMFS5','DataMover.HardwareAcceleratedInit','DataMover.HardwareAcceleratedMove','VMFS3.HardwareAcceleratedLocking','VMFS3.EnableBlockDelete') : print option.key,option.value def main(): """ Simple command-line program for listing the hosts machines on a system. """ args = cli.get_args() try: service_instance = connect.SmartConnect(host=args.host, user=args.user, pwd=args.password, port=int(args.port)) atexit.register(connect.Disconnect, service_instance) content = service_instance.RetrieveContent() container = content.rootFolder # starting point to look into viewType = [vim.HostSystem] # object types to look for recursive = True # whether we should look into it recursively containerView = content.viewManager.CreateContainerView( container, viewType, recursive) children = containerView.view for child in children: print_host_info(child) except vmodl.MethodFault as error: print("Caught vmodl fault : " + error.msg) return -1 return 0 # Start program if __name__ == "__main__": main() import atexit from pyVim import connect from pyVmomi import vmodl from pyVmomi import vim import tools.cli as cli def print_host_info(host_machine): """ Print information for a particular host machine """ print host_machine.config.network.dnsConfig.hostName print host_machine.config.product.version for option in host_machine.config.option: if option.key in ('VMFS3.UseATSForHBOnVMFS5','DataMover.HardwareAcceleratedInit','DataMover.HardwareAcceleratedMove','VMFS3.HardwareAcceleratedLocking','VMFS3.EnableBlockDelete') : print option.key,option.value def main(): """ Simple command-line program for listing the hosts machines on a system. """ args = cli.get_args() try: service_instance = connect.SmartConnect(host=args.host, user=args.user, pwd=args.password, port=int(args.port)) atexit.register(connect.Disconnect, service_instance) content = service_instance.RetrieveContent() container = content.rootFolder # starting point to look into viewType = [vim.HostSystem] # object types to look for recursive = True # whether we should look into it recursively containerView = content.viewManager.CreateContainerView( container, viewType, recursive) children = containerView.view for child in children: print_host_info(child) except vmodl.MethodFault as error: print("Caught vmodl fault : " + error.msg) return -1 return 0 # Start program if __name__ == "__main__": main()

更多推荐

本文发布于:2023-08-02 19:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1380615.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:系统设置   列表   ESX   pyVmomi   settings

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!