This file contains 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 | |
""" | |
Written by Nathan Prziborowski | |
Github: https://github.com/prziborowski | |
This code is released under the terms of the Apache 2 | |
http://www.apache.org/licenses/LICENSE-2.0.html | |
Download a VM file using an http request. |
This file contains 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 | |
""" | |
Written by Nathan Prziborowski | |
Github: https://github.com/prziborowski | |
This code is released under the terms of the Apache 2 | |
http://www.apache.org/licenses/LICENSE-2.0.html | |
Simple example for watching events of a datacenter. |
This file contains 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 | |
""" | |
Written by Nathan Prziborowski | |
Github: https://github.com/prziborowski | |
This code is released under the terms of the Apache 2 | |
http://www.apache.org/licenses/LICENSE-2.0.html | |
The property collector can be used to fetch a subset of properties | |
for a large amount of objects with fewer round trips that iterating. | |
This sample shows how to use the TraversalSpec to get properties | |
of another object without multiple calls. |
This file contains 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
from six.moves.urllib.request import build_opener | |
from six.moves.urllib.parse import quote_plus | |
from pyVmomi import vim | |
si = vim.ServiceInstance() # use your service instance | |
vm = vim.VirtualMachine() # use your actual vm | |
vmPathName = vm.config.files.vmPathName | |
for dsUrl in vm.config.datastoreUrl: | |
vmPathName = vmPathName.replace('[%s] ' % dsUrl.name, '%s/' % dsUrl.url) | |
vmPathName = quote_plus(vmPathName) |