目錄
ESXI配置DNS
界面配置
mob查找
python3 sdk 調用查詢實例
'''
@Author: shun zi 2016
@Date: 2020-04-28 18:35:14
@LastEditTime: 2020-04-29 15:11:23
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: host.py
'''
# -*- coding: utf-8 -*-
from pyvim import connect
import ssl
import pyVmomi
ssl._create_default_https_context = ssl._create_unverified_context
import atexit
service_instance = connect.SmartConnect(host='172xx.x.xx.15',user='[email protected]',pwd='xx.xx.xx.xx',port=443)
# service_instance = connect.SmartConnect(host='172.xx.xx..1',
# user='[email protected]',
# pwd='xxxxxxx',
# port=443)
content = service_instance.RetrieveContent()
# print str(content)
# print str(content.dvSwitchManager)
# print str(content.viewManager)
vcontent = service_instance.content
for dc in vcontent.rootFolder.childEntity:
if dc.name == 'Datacenter':
break
clusterNotFound = False
for cluster in dc.hostFolder.childEntity:
if cluster.name == 'colony':
clusterNotFound = True
break
if clusterNotFound == False:
print("clusterNotFound:%s " % 'colony')
for host in cluster.host:
print('host-name')
print(str(host))
print(host.name)
print(host.config.network.dnsConfig)
print(host.config.network.dnsConfig.hostName)
print(host.config.network.dnsConfig.domainName)
esxi_ip_domain_list = []
for host in cluster.host:
domainName = host.config.network.dnsConfig.domainName
esxi_ip_domain_list.append(domainName)
hostName = host.config.network.dnsConfig.hostName
esxi_ip_domain_list.append(hostName)
domain_name = hostName + '.' + domainName
esxi_ip_domain_list.append(domain_name)
esxi_ip_domain_list.append(host.name)