ianrosadas / pysphere

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

Error using guest send_file function in IPv6 enviroment - address mangled #49

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start python console
2. Load pysphere module
3. Create pysphere instance and connect to ESXi server (successful) 
4. create vm instance using get_vm_by_name()
5. Set guest credentials using vm.login_in_guest()
6. Attempt to push local file to guest file system using vm.send_file() 
function.  This produces the error below.  

What is the expected output? What do you see instead?
Successful push of file from local system to guest system

What version of the product are you using? On what operating system?
Current - 0.1.8

Please provide any additional information below.

From initial trouble shooting it appears the IPv6 address somewhere in the 
process to use the urllib2.py library.  Looks like the ":" colons are being 
used somewhere to split the address up expecting a port and is ignoring the 
wrapping square brackets "[]".
initial ipv6 address = "[fd30:f8fe:a3af:4466::100]"
resulting url var looking like this....
url = "[fd30:"

Currently I am seeing this by looking in some print statements in the 
vm_virtual_machine.py around line 1292. "url = url.replace("*", 
urlparse(self._server._proxy.binding.url).hostname)"

Python session below
###############################################

Python 2.6.6 (r266:84292, May 27 2013, 05:35:12) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysphere import *
>>> s = VIServer()
>>> s.connect("[fd30:f8fe:a3af:4466::100]", "admin", "adminpass")
>>> vm = s.get_vm_by_name("IPV6guest")
>>> vm.login_in_guest("guestuser","guestpass")
>>> stat = 
vm.send_file("/etc/puppet/manifests/site.pp","/etc/puppet/manifests/site.pp", 
True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/pyve/mdms/lib/python2.6/site-packages/pysphere/vi_virtual_machine.py", line 1301, in send_file
    resp = urllib2.urlopen(request)
  File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 1198, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib64/python2.6/urllib2.py", line 1165, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>

Original issue reported on code.google.com by ch...@kalazzerx.com on 16 Jan 2014 at 6:22

GoogleCodeExporter commented 9 years ago
actual print output from produced with print statements in 
vi_virtual_machine.py.

2014-01-16 17:56:13,616 - DEBUG - Send file 'network' to VM: si6-mongodb1a
XXXX URL: 
https://*:443/guestFile?id=1004&token=52856b37-936a-474b-6ba1-4e4cea7684c81004
XXXX hostname: [fd30
2014-01-16 17:56:14,776 - CRITICAL - Error: not all arguments converted during 
string formatting

Original comment by ch...@kalazzerx.com on 16 Jan 2014 at 6:27