pyvmomi
pyvmomi copied to clipboard
Guest Console - vCenter 6.0
Hi community,
I use to have a HTML 5 Console access working fine with vCenter 5.1, and fine means the URL generated grants direct access to VM console without prompting user for credentials.
Now I'm trying to use the same approach to access vCenter 6.x guests console and everything works fine, but it always redirect me to SAML2/SSO login page. Providing username and password manually will redirect the request to the VM Console but I would like to have this working without asking for user credentials.
Can anyone help me with this? any hint?
The generated URL is:
https://<vcenterName>:9443/vsphere-client/webconsole.html? vmId=<vm_id> &vmName=<vm_name> &serverGuid=<server_GUID> &host=<vCenter_fqdn>:443 &sessionTicket=<si.AcquireCloneTicket()> &thumbprint=<OpenSSL.crypto.load_certificate => digest('sha1')>
My Code:
import OpenSSL
ssl._create_default_https_context = ssl._create_unverified_context
service_instance = connect.SmartConnect(host=vcenter, user=username, pwd=password, port=443)
atexit.register(connect.Disconnect, service_instance)
search_index = service_instance.content.searchIndex
serverGuid = service_instance.content.about.instanceUuid
vm = search_index.FindByUuid(None, vm_uuid, True, True)
content = service_instance.RetrieveContent()
vcenter_data = content.setting
vm_moid = vm._moId
vcenter_settings = vcenter_data.setting
console_port = '9443'
for item in vcenter_settings:
key = getattr(item, 'key')
if key == 'VirtualCenter.FQDN':
vcenter_fqdn = getattr(item, 'value')
session_manager = content.sessionManager
session = session_manager.AcquireCloneTicket()
vc_cert = ssl.get_server_certificate((vcenter, 443))
vc_pem = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, vc_cert)
vc_fingerprint = vc_pem.digest('sha1')
return "https://" + vcenter + ":" + console_port + "/vsphere-client/webconsole.html?vmId=" + str(vm_moid) + "&vmName=" + vm.name + "&serverGuid=" + serverGuid + "&host=" + vcenter_fqdn + ":443&sessionTicket=" + session + "&thumbprint=" + vc_fingerprint
...
Versions
pyvmomi v6.5 Python v2.7.5