sahlberg / libnfs-python

Python bindings for libnfs
GNU Lesser General Public License v2.1
64 stars 34 forks source link

Enable resolving of hostnames in nfs url. #7

Closed fredrik-eriksson closed 8 years ago

fredrik-eriksson commented 9 years ago

Hi,

This is just a small fix to allow hostnames (not just ip addresses) in nfs urls.

fredrik-eriksson commented 9 years ago

Actually it fails on nfs_open:

 63         self._nfsfh = new_NFSFileHandle()
 64         if _mode & os.O_CREAT:
 65             _status = nfs_create(self._nfs, path, _mode, 0o664, self._nfsfh)
 66         else:
 67             _status = nfs_open(self._nfs, path, _mode, self._nfsfh)
 68         if _status != 0:
 69             _errmsg = "open failed: %s" % (os.strerror(-_status),)
 70             raise ValueError(_errmsg)
Traceback (most recent call last):
  File "kaka.py", line 18, in <module>
    f = handle.open(rel_path, 'rb')
  File "/usr/lib64/python2.7/site-packages/libnfs-1.0.post1-py2.7-linux-x86_64.egg/libnfs/__init__.py", line 164, in open
    return NFSFH(self._nfs, path, mode=mode)
  File "/usr/lib64/python2.7/site-packages/libnfs-1.0.post1-py2.7-linux-x86_64.egg/libnfs/__init__.py", line 70, in __init__
    raise ValueError(_errmsg)
ValueError: open failed: Bad address

I didn't dig any deeper into this, but since it worked with IP addresses I assumed it didn't do any resolving...

sahlberg commented 8 years ago

Can not reproduce.

PYTHONPATH=./build/lib.linux-x86_64-2.7/ python utils/nfs-ls.py nfs://localhost/data/tmp can resolve the hostname and does show the listing I expect.