Giter Site home page Giter Site logo

libnfs-python's Introduction

This module is an NFS client for python.
This project is hosted at https://github.com/sahlberg/libnfs-python

This module depends on the libnfs library.
You must first install libnfs before you can use this module.
Libnfs can be found at https://github.com/sahlberg/libnfs


The two main classes in this module are NFS and NFSFH.
NFS represents an NFS context that describes a mount point.
NFSFH is the main class that implements a file-like object for NFS files.


LICENSE
=======
This module is distributed under LGPL version 2.1.
Please see COPYING for the full text of this license.


Context-full access
===================
In the context-full mode you will first need to mount an NFS share and create
an NFS context before you can access any files. This NFS context is then used
for all future access to files in that mount point.

The benefit with this mode is that since performing the actual NFS mount is
very expensive you only need to perform it once, when creating the NFS object
and can reuse the mount for any future files you want to access.

In this mode absolute paths are relative to the mount point for the NFS object.

Example:
--------
import libnfs
nfs = libnfs.NFS('nfs://127.0.0.1/data/tmp/')
a = nfs.open('/foo-test', mode='w+')
a.write("Test string")
a.close()
print nfs.open('/foo-test', mode='r').read()


Context-free access
===================
This module also provides a mode where you can directly open and access
a file-like object without first having to instantiate a NFS mount.
In this case the file-like object will internally create an NFS mount
for the duration of the lifespan of the file-like object.

In this mode you invoke the libnfs.open() function with an NFS url
that points to a file :

Example:
--------
import libnfs
a = libnfs.open('nfs://127.0.0.1/data/tmp/foo-test', mode='w+')
a.write("Test string")
a.close()
print libnfs.open('nfs://127.0.0.1/data/tmp/foo-test', mode='r').read()

In the example above we create two instances of a file-like object. First
we create and write to the file and second time we read the file back and
print it. This is however both expensive and potentially poor performing.
The reason is that when we use context-free file-like objects we have to
create an NFS mount internally for each object and this is expensive.

Basically, when creating an NFS mount, the NFS protocol requires that we
perform the following operations/roundtrips :

Creating an NFS context:
------------------------
1, Establish TCP connection to portmapper (TCP port 111) on the server.
2, Send a Portmapper NULL command to verify we are connected to a genuine
   Portmapper and that it is alive.
3, Send a Portmapper GetPort command to fetch which port the MOUNT daemon
   is running on.
   Close the TCP connection.
4, Establish a TCP connection to the MOUNT daemon
5, Send a MOUNT NULL command to verify the MOUNT daemon is alive.
6, Send a MOUNT MNT command to fetch the NFS file handle for the mount point.
   Close the TCP connection.
7, Establish TCP connection to portmapper (TCP port 111) on the server.
8, Send a Portmapper NULL command to verify we are connected to a genuine
   Portmapper and that it is alive.
9, Send a Portmapper GetPort command to fetch which port the DAEMON daemon
   is running on.
   Close the TCP connection.
10, Establish a TCP connection to the NFS daemon
11, Send a NFS NULL command to verify the NFS daemon is alive.
12, Send a NFS FSINFO command to fetch some basic information about the
    filesystem we just mounted.
13, Send a NFS GETATTR command to fetch some information about the root
    directory for this mount.

When using context-free handles we have to perform these steps every time
a new file-like object is created making it very expensive.

The benefit with context-free handles is that they are very convenient to use.
Just pass an NFS url to the libnfs.open() function and you have a file-like
object. The drawback is that every context-free handle have to perform their
own NFS mount internally. If you plan to access multiple/many files you
should consider using context-full handles instead.


MAILING LIST
============
A libnfs-python mailing list is available at
http://groups.google.com/group/libnfs-python
Announcements of new versions of libnfs-python will be posted to this list.

libnfs-python's People

Contributors

2mf avatar captainupdates avatar fredrik-eriksson avatar poojashahuraj avatar sahlberg avatar tokibito avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.