Skip to content

Instantly share code, notes, and snippets.

#!/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.
@prziborowski
prziborowski / event_monitor.py
Last active July 14, 2021 18:18
Monitor event history collector
#!/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.
@prziborowski
prziborowski / gist:ba3ebf610dd6cca3f4e7be5e2874499f
Last active July 16, 2023 00:42
Use property collector to retrieve names quickly
#!/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.
@prziborowski
prziborowski / gist:1a8ee0e3e4185e07f208212fcc083078
Created October 16, 2018 05:30
send_nmi_via_vmsupport.py
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)