Skip to content

Instantly share code, notes, and snippets.

@DanyC97
Forked from sky-joker/vm_hw_version.py
Created November 21, 2017 11:17
Show Gist options
  • Save DanyC97/62e36e544d39da3983a618c470ba28e7 to your computer and use it in GitHub Desktop.
Save DanyC97/62e36e544d39da3983a618c470ba28e7 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
from pyVim.connect import SmartConnect, Disconnect
from pyVmomi import vim
import ssl
import atexit
if __name__ == '__main__':
# 接続情報
host = 'vCenter IP or Host Name'
username = '[email protected]'
password = ''
# SSL証明書対策
context = None
if hasattr(ssl, '_create_unverified_context'):
context = ssl._create_unverified_context()
# vCenterへ接続
si = SmartConnect(host = host,
user = username,
pwd = password,
sslContext = context)
# 処理完了時にvCenterから切断
atexit.register(Disconnect, si)
# VM情報の取得
content = si.content
datacenter = content.rootFolder.childEntity[0]
vmfolder = datacenter.vmFolder
hosts = datacenter.hostFolder.childEntity
resource_pool = hosts[0].resourcePool
for i in hosts[0].environmentBrowser.QueryConfigOptionDescriptor():
print("%s -> %s" % (i.key, i.description))
"""
vmx-03 -> ESX 2.x 仮想マシン
vmx-04 -> ESX 3.x 仮想マシン
vmx-07 -> ESX/ESXi 4.x 仮想マシン
vmx-08 -> ESXi 5.0 仮想マシン
vmx-09 -> ESXi 5.1 仮想マシン
vmx-10 -> ESXi 5.5 仮想マシン
vmx-11 -> ESXi 6.0 仮想マシン
vmx-12 -> Workstation 12 仮想マシン
vmx-13 -> ESXi 6.5 仮想マシン
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment