Created
October 16, 2018 05:30
-
-
Save prziborowski/1a8ee0e3e4185e07f208212fcc083078 to your computer and use it in GitHub Desktop.
send_nmi_via_vmsupport.py
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) | |
host = vm.runtime.host | |
manifest = quote_plus('HungVM:Send_NMI_To_Guest') | |
url = ('https://%s/cgi-bin/vm-support.cgi?manifests=%s&vm=%s' % | |
(host.name, manifest, vmPathName)) | |
spec = vim.SessionManager.HttpServiceRequestSpec(method='httpGet', url=url) | |
ticket = si.content.sessionManager.AcquireGenericServiceTicket(spec) | |
opener = build_opener() | |
opener.addheaders.append(('Cookie', 'vmware_cgi_ticket=' + ticket.id)) | |
resp = opener.open(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment