vcenter通过python的sdk创建自定义的虚拟机信息,并配置相关的属性信息(四)配置esxi的dns,以及查看调用dns数据

目录

 

ESXI配置DNS

 mob查找

python3  sdk 调用查询实例


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='administrator@vsphere.local',pwd='xx.xx.xx.xx',port=443)
# service_instance = connect.SmartConnect(host='172.xx.xx..1',
#                                         user='administrator@vsphere.local',
#                                         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)

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

千码君2016

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值