DiegoSanjuan / pysphere

Automatically exported from code.google.com/p/pysphere
0 stars 0 forks source link

TypeError for ZSI NoHost_Def Options #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Original mail from John Calcote. (see 
http://groups.google.com/group/pysphere/browse_thread/thread/81d97515a223e5e9#)

Hi Seba, 
I think I ran into a bug in pysphere - it may be in ZSI itself. I got 
the following TraceBack when attempting to call 
AcquireCIMServicesTicket on the VIServer instance with a managed 
object reference to a host that was currently disconnected: 
Traceback (most recent call last): 
  File "c:\fusion\fio-esx-agent-mgr-script.py", line 15, in <module> 
    fioesxagentmgr.main() 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\src\fioesxagentmgr\__init__.py", line 80, in main 
    esx_manager.poll_for_config_changes() 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\src\fioesxagentmgr\esxmgr.py", line 251, in 
poll_for_config_changes 
    ticket = self._get_host_services_ticket(mor) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\src\fioesxagentmgr\esxmgr.py", line 150, in 
_get_host_services_ticket 
    response = self._server._proxy.AcquireCimServicesTicket(request) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\resources 
\VimService_services.py", line 1416, in AcquireCimServicesTicket 
    response = 
self.binding.Receive(AcquireCimServicesTicketResponseMsg.typecode) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\client.py", line 
549, in Receive 
    return _Binding.Receive(self, replytype, **kw) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\client.py", line 
467, in Receive 
    msg = FaultFromFaultMessage(self.local.ps) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\fault.py", line 
253, in FaultFromFaultMessage 
    pyobj = ps.Parse(FaultType.typecode) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\parse.py", line 
326, in Parse 
    return how.parse(self.body_root, self) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\TCcompound.py", 
line 203, in parse 
    value = what.parse(c_elt, ps) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\TCcompound.py", 
line 206, in parse 
    value = what.parse(c_elt, ps) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\TC.py", line 
1455, in parse 
    pyobj = what.parse(elt, ps) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\TCcompound.py", 
line 147, in parse 
    what = TypeDefinition.getSubstituteType(self, elt, ps) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\schema.py", line 
296, in getSubstituteType 
    (self.type[0], self.type[1], pyclass), ps.Backtrace(elt)) 
TypeError: ("Substitute Type (urn:vim25, NoHost) is not derived from 
<class 'pysphere.resources.VimService_services_types.NoHost_Def'>", u'/ 
soapenv:Envelope/soapenv:Body/soapenv:Fault/detail/NoHostFault') 

It looks like it should have thrown a NoHost exception, but instead it 
throws a TypeError. 
Thanks in advance, 
John

Original issue reported on code.google.com by argo...@gmail.com on 16 Mar 2012 at 5:38

GoogleCodeExporter commented 8 years ago
Hi John,

   It seems that this is not a pysphere's bug but a vSphere SDK's. The reason I think so is the following:

This is the SOAP response I get when requesting AcquireCIMServicesTicket on a 
disconnected host:

<soapenv:Fault>
    <faultcode>ServerFaultCode</faultcode>
    <faultstring>vim.fault.NoHost</faultstring>
        <detail>
            <NoHostFault xmlns="urn:vim25" xsi:type="SystemError">
                <reason>Invalid fault</reason>
            </NoHostFault>
        </detail>
</soapenv:Fault>

Which is a NoHostFault 
(http://pubs.vmware.com/vsphere-50/index.jsp?topic=/com.vmware.wssdk.apiref.doc_
50/vim.fault.NoHost.html)

The type descriptor (xsi:type) should be either a NoHost type or a superclass 
of it. The response indicates that the type is "SystemError". So ZSI attempts 
to create at runtime the object representation of this fault. However 
inspecting the wsdl definition and the documentation you can see that 
SystemError is not a superclass of NoHost.

Here's the class tree of NoHost:
NoHostFault->HostConnectFault->VimFault->MethodFault

And this is the SystemError tree:
SystemError->RuntimeFault->MethodFault

As you can see they are in separate branches (even though they both share 
MethodFault class inheritance)

Summarizing, the server is sending the wrong type in the soap response.

As you found this, do you want to report it to VMWare yourself?

For the moment I'm closing this ticket as invalid.

Thanks for your time and cooperation!

By the way, I reproduced this with a vCenter 4.1.0, 345043 (this might be fixed 
already in a newer version or more up-to-date patch)

Original comment by argo...@gmail.com on 16 Mar 2012 at 9:30

GoogleCodeExporter commented 8 years ago
Thanks Seba. I tried it on the latest vCenter server and got the failure. I 
understand the problem now and how you can't do anything about it. It doesn't 
really matter - I just capture TypeError and treat it like NoHost (sadly). If I 
really need to distinguish between a NoHost TypeError and a real type error, I 
can just look at the error object's attributes to figure out if it's related to 
the NoHost issue.

John

Original comment by john.cal...@gmail.com on 17 Mar 2012 at 1:10