axxyhtrx / pysphere

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

Error creating vm instance (by Harish) #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Reported by Harish

Code:
{{{
from pysphere import VIServer
server = VIServer()
server.connect("192.168.3.30", "root", "root123")
vmlist = server.get_registered_vms()
print server.get_registered_vms()
vm1 = server.get_vm_by_name("Win64-7")
vm2 = server.get_vm_by_path("[datastore2] Win64-7/Win64-7.vmx")´
print vm1.get_status()
print vm2.get_status()
server.disconnect() 
}}}

Error:

{{{
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on 
win32 Type "copyright", "credits" or "license()" for more information. 

'[datastore2] RHEL64-5.3 ES/RHEL64-5.3 ES.vmx', 'datastore2? 
Win64-7/Win64-7.vmx', '[datastore2] New Virtual Machine/New Virtual 
Machine.vmx'] 

Traceback (most recent call last): 

File "C:\Documents and Settings\hmunagapati\Desktop\vm_py\test.py", line 
10, in <module> 
vm1 = server.get_vm_by_name("Win64-7") 
File "C:\Python27\lib\site-packages\pysphere\vi_server.py", line 218, in 
get_vm_by_name 
return VIVirtualMachine(self, mor) 
File "C:\Python27\lib\site-packages\pysphere\vi_virtual_machine.py", line 
47, in init 
self.update_properties() 
File "C:\Python27\lib\site-packages\pysphere\vi_virtual_machine.py", line 
741, in update_properties 
self.mor, get_all=True) 
File "C:\Python27\lib\site-packages\pysphere\vi_server.py", line 396, in 
get_object_properties 
return request_call(request) 
File "C:\Python27\lib\site-packages\pysphere\vi_server.py", line 696, in 
call_retrieve_properties 
return self.proxy.RetrieveProperties?(request).returnval 
File 
"C:\Python27\lib\site-packages\pysphere\resources\VimService?_services.py", 
line 61, in RetrieveProperties? 
response = self.binding.Receive(RetrievePropertiesResponseMsg?.typecode) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\client.py", line 544, in 
Receive 
return Binding.Receive(self, replytype, kw) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\client.py", line 469, in 
Receive 
reply = self.ps.Parse(tc) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\parse.py", line 326, in 
Parse 
return how.parse(self.body_root, self) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 
203, in parse 
value = what.parse(c_elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 
203, in parse 
value = what.parse(c_elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 
203, in parse 
value = what.parse(c_elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TC.py", line 1392, in 
parse 
pyobj = what.parse(elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 
203, in parse 
value = what.parse(c_elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TC.py", line 446, in 
parse 
pyobj = self.text_to_data(v, elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCtimes.py", line 211, 
in text_to_data 
retval = fix_timezone(retval, tz_from = m.groupdict().get('tz'), tz_to 
= None) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCtimes.py", line 98, in 
fix_timezone 
ltv:6? = datetime((ltv:6? + [0, 
tz_from])).astimezone(tz_to).timetuple():6? 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCtimes.py", line 48, in 
utcoffset 
dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1))) 
OverflowError?: mktime argument out of range 
}}}

Original issue reported on code.google.com by argo...@gmail.com on 30 Nov 2011 at 7:56

GoogleCodeExporter commented 9 years ago
Its VMware ESXi 4.0

Original comment by harish....@gmail.com on 1 Dec 2011 at 2:50

GoogleCodeExporter commented 9 years ago
Harish, it seems the error is triggered by python's mktime function being 
unable to parse a date older than the epoch (1970/01/01). There must be some 
date property in the VM you're trying to instantiate that has an old date.

Can you apply the patch I'm attaching and let me now if that works for you?

Thanks.

Original comment by argo...@gmail.com on 1 Dec 2011 at 7:33

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed on r31

set MINYEAR to 1970

Original comment by argo...@gmail.com on 2 Dec 2011 at 4:31