Created
November 6, 2019 13:30
-
-
Save sky-joker/7920b32ca57395ac672d8161bca86549 to your computer and use it in GitHub Desktop.
vCenter connect template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from pyVim.connect import SmartConnect, Disconnect | |
from pyVmomi import vim, vmodl | |
import ssl | |
import atexit | |
host = '' | |
username = '' | |
password = '' | |
mob = vim.VirtualMachine | |
if __name__ == "__main__": | |
context = None | |
if hasattr(ssl, '_create_unverified_context'): | |
context = ssl._create_unverified_context() | |
si = SmartConnect(host=host, | |
user=username, | |
pwd=password, | |
sslContext=context) | |
atexit.register(Disconnect, si) | |
content = si.content | |
mob_list = content.viewManager.CreateContainerView(content.rootFolder, | |
[mob], | |
True) | |
for mob in mob_list.view: | |
print(mob.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment