首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用pyVmomi获取每个ESX的ESX和系统设置列表

使用pyVmomi获取每个ESX的ESX和系统设置列表
EN

Stack Overflow用户
提问于 2017-03-22 18:16:15
回答 1查看 999关注 0票数 0

以下esxcli命令的并行pyVmomi API是什么?

代码语言:javascript
复制
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

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

谢谢,

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-26 15:00:48

代码语言:javascript
复制
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()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42959697

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档