prologin.hfs.server module

Home Filesystem Server: handle creation and migration of filesystems for /home/<user>.

Each user home directory is a separate filesystem served using NBD (Network Block Device). When a user logs in to a machine, the PAM session_start script is executed and will ask the HFS responsible for the machine for the port to connect to for NBD. Three things can happen on the HFS side:

  • The user has currently no home directory: we create a new one, copy the skeleton in it, serve it and return the port.

  • The user has a home directory and it is on this server: serve it and return the port.

  • The user has a home directory on another server. We ask the remote HFS for the data, then serve it and return the port.

The user<->hfs association is stored in a shared database hosted on db (PostgreSQL).

We don’t use Tornado for this service because it sucks at large file handling. tornado.iostream seems to buffer data when one side of the stream is too slow (read or write) instead of trying to throttle. When transfering 5GB files, buffering in RAM is just not a good idea.

exception prologin.hfs.server.ArgumentMissing

Bases: Exception

class prologin.hfs.server.HFSRequestHandler(request, client_address, server)

Bases: http.server.BaseHTTPRequestHandler

check_available_space()

Check if we have enough space to create or download a NBD for that user.

check_user_exists()

Check that the specified user exists locally to avoid creating hfs with invalid permissions.

do_POST()
error_message_format = '%(code)d - %(message)s - %(explain)s'
error_message_type = 'text/plain'
get_argument(name)

Returns the value of the GET argument called <name>. If it does not exist, send an error page.

get_hfs()
get_nbd_size()

Returns the NBD size for the current user type.

get_user_group()

Returns the UNIX group for the current user type.

kill_user_nbd()
migrate_user()
nbd_filename()

Returns the filename for the NBD.

new_user_handler()

Handles creation of a new NBD file for the given user.

remote_user_handler(peer_id)

Transfers the data from a remote HFS to the current HFS.

start_nbd_server(filename)

Starts the NBD server for a given filename. Allocates a random port between CFG[‘start_port_range’] and CFG[‘end_port_range’] (excl). Returns that port.

class prologin.hfs.server.ThHTTPServer(server_address, RequestHandlerClass, bind_and_activate=True)

Bases: http.server.HTTPServer, socketserver.ThreadingMixIn

prologin.hfs.server.find_free_port(start, end)

Finds a free port in [start, end[.

prologin.hfs.server.get_available_space(path)

Returns the number of bytes available on the FS containing <path>.

prologin.hfs.server.get_hfs_ip(hfs_id)

Returns the IPv4 address associated to an HFS. Assumes the HFS will have an alias “hfs%d” on it.