Hi John,
ok it is near 1 year ago as you wrote this :o) but I also try to use the service tickets like you. Unfortunately the code you pasted is not working for me.
I need to say that I'm a python noobie and so i may miss some basic stuff here but I can't figure out where the problem is.
as far as I understood I need to add the line for 'executing' the definition like this:
get_host_service_ticket(my-esx-ip, Network)
But the result is always:
"Failed to retrieve CIM services ticket from vCenter server."
Well it is clear that I first need to open a valid server connection with user and password like this:
s = VIServer()
host = "192.168.56.99"
user = "root"
password = "abc123456"
s.connect(host, user, password)
so I added this code, too. Same result. I need to say that a connection with the above parameters works fine. E.g. I can get the Network Labels etc.
Hope that you or someone else can help me out here..
Here is my full python code:
#####################################################
#!/usr/bin/env python
from pysphere import VIServer
from pysphere.resources import VimService_services as VI
s = VIServer()
host = "192.168.56.99"
user = "root"
password = "abc123456"
s.connect(host, user, password)
def get_host_service_ticket(server, mor):
"""Request host (mor) cim services ticket from vCenter (server)."""
try:
request = VI.AcquireCimServicesTicketRequestMsg()
request.set_element__this(mor)
response = server._proxy.AcquireCimServicesTicket(request)
return response.Returnval.SessionId
except:
print("Failed to retrieve CIM services ticket from vCenter server.")
return None
get_host_service_ticket('192.168.56.99', 'Network')
#####################################################
Thanks
Thomas
[....]
>
> CIM services tickets are basically login credentials accepted by ESX
> hosts' SMI-s services and understood by them to be pre-configured, pre-
> authenticated session ids. They have limited lifetimes - initial
> access (SMI-s login) has to happen within 120 seconds from the time
> they're handed out, or they'll expire. They then expire after 15
> minutes of inactivity. They always expire within one hour, regardless
> of the level of activity. An interesting thing is that CIM services
> tickets are the ONLY way to contact an ESX server's SMI-s service if
> the server has been placed in lock-down mode.
>
> Here's the code I used to acquire a CIM services ticket:
>
> from pysphere import VIServer
> from pysphere.resources import VimService_services as VI
>
> def get_host_service_ticket(server, mor):
> """Request host (mor) cim services ticket from vCenter
> (server)."""
> try:
> request = VI.AcquireCimServicesTicketRequestMsg()
> request.set_element__this(mor)
> response = server._proxy.AcquireCimServicesTicket(request)
> return response.Returnval.SessionId
> except:
> logging.warn("Failed to retrieve CIM services ticket from
> vCenter server.")
> return None
>
[...]