Novell Filr And The Raspberry PI

This article describes a piece of experimental work using the Filr REST API and exposing the functionality through a python library. Normally, Filr only supports the Web, Macintosh and Windows clients but using python will allow this to become far more cross platform. The work described here can be ported to other platforms very easily if the destination supports python 2.7 and a number of required modules.

To port the work from Windows to SLES took about 1 hour. Currently the work discussed here has been tested on a QNAP NAS box, SLES11 SP3, Windows, and the Raspberry PI. To demonstrate the use of this library the PyClient app has been developed which is a pure python based Filr Client and like the Filr library is cross platform.

Why the Raspberry PI? This may come under the fun but pointless category but it demonstrates the value of a lightweight interface to Filr on a platform with limited processor and memory; yet it will allow the uploading and downloading of files to Filr, the sharing of files and the viewing of files held on the Filr backend.

This Filr client interaction can also be scripted so that shell scripts can talk to Filr and automate certain backend processes. So for example a PI based robot could over wireless upload data to a Filr backend. There are many other potential uses for this sort of technology. The app and the library can be delivered as a single binary with no python install requirements.

This work is not currently maintained or supported by Novell and is currently purely experimental in nature.

Cross platform Filr support library

The foundation of the solution is the filr.py python module. This is designed to be imported in to other programs that require Filr support. The aim of the library is to wrap the Filr rest api in a scripting friendly manner and to abstract a number of key Filr operations. These include the following:

  • Creation and deletion of folders
  • Creation of netfolder and netfolder servers
  • Uploading and downloading of files
  • LDAP and Netfolder Synchronisation.

So the aim of filr.py is to provide an insulation layer to the applications written to use it. If the underlying Filr REST Api changes the app does not need to change, only the support library. This library can be used in a number of ways and here are some examples.

The code in figure 1 makes a rest call to the Filr server defined as filr.novell.com and returns a blob of data about the currently logged in data called userinfo. The user that is used for the login is defined in the script and the password can be extracted from the Credential Store used by the Filr Client, so that you do not have to put passwords in to your script.

28-shepherd-1
Figure 1: Making a rest call to the Filr server

The userinfo[“title”] line just extracts one piece of the data and prints the currently logged in user name.

Figure 2 demonstrates the use of the upload function that is also part of the library. The same pattern is followed as the previous example. In this case though the program has a folderid set that refers to a particular folder on the filr system in question This number will be unique in each case. The program prompts for a path and a file spec, and then it will upload files that match that spec to the backend filr system.

28-shepherd-2
Figure 2: Using the upload function

PyClient on the Raspberry PI

PyClient is a python program written to use the filr.py library. Using a program called Pyinstaller we can compile the .py as a binary that includes both pyclient.py and the filr library with all the required python dependencies. This results in one file that can be installed on the destination PI without having to make sure all of the various dependencies are met.

Figure 3 shows the client running from SSH on the PI. From the interface you can change to any folder in the list of netfolders including the Shared With Me folder. If home folders were configured it would show as home in this list. The inspiration for this client was an FTP client so various commands are available to you at this stage.

28-shepherd-3-600x556
Figure 3: Pyclient running on a Raspberry PI via SSH

So at this stage cd /xxxx would change you in to any netfolder. If the netfolder name has spaces then use cd /”xxxx xxx”. The use of the tab key will auto-complete commands and directory and file names. The client does have a help command.

This will show the supported commands and give an indication how they are used, as shown in figure 4. For example figure 5 shows the output from using the shares command which lists the files shared by the current user.

28-shepherd-4-600x311
Figure 4: Pyclient help command
28-shepherd-5-600x418
Figure 5: Results from the shares command

The command also lists who the files or folders are shared to and the rights that have been granted.

Basic file management commands also exist with the client such as mkdir to create a folder on the filr system and rmdir to remove the folder from Filr.

So to download a file from Filr to the local Raspberry PI the following command is used:

DL FILENAME /XX/XX

Where /xx/xx is the path that the download file should be saved to.

28-shepherd-6-600x841
Figure 6: Downloading a file

Script Files

The client can also be driven non interactively. So for example you can create a .scr file where the file is a text file that contains a list of commands to submit to the client. For example:
cd /test
dir
quit

To run the script the following command should be used.

./pyclient -s “filr.novell.com” -u “dshepherd” -r folders.scr

When it’s run the the script produces the output as shown in figure 7.

28-shepherd-8-600x418
Figure 7: Output generated from running the commands in a script file

The script runs and connects to the Filr Server as the user dshepherd, and then changes to the directory, and does a directory of that netfolder. Once done the script finishes and leaves pyclient.

This process also produces a file called folders.scr.out which is a dump of the output from the script. Other commands can be run in this manner producing .out files to indicate their output.

Admin Specific Functions

If the user is logged on as admin then extra functions become available. You have the ability to export the currently defined NetFolders and Netfolder Servers as XML files and these files can be used as templates. So they could be customised, or have new netfolders added and then used to bulk import new netfolders to the system.

We also have the ability to start a netfolder sync and an ldap sync of users from the interface shown previously and all of these functions can be scripted in the same way.

Summary

This is an experimental piece of work to provide a “simple” automation interface to Filr via scripting. The code mentioned here is cross platform and should run on most Python 2.7 supported devices. It abstracts the rest interface and handles session persistence and authentication to the Filr System. It is not currently supported by Novell.

If the functionality discussed here is thought to be useful then please get in touch at dshepherd@novell.com as we plan to make the client available through Cool Solutions early in 2015.

If you would like to see extra functionality available through this interface then please do get in touch. The potential of this sort of automation is extensive and the Raspberry PI was a specific example. Wouldn’t it be useful if the “Internet of things” had a lightweight and easy to use library to save and retrieve information to Filr ?

I am currently looking at additional features. For example, could we not wrap this with an IMAP interface so in effect every email client becomes a Filr Client. Hopefully other ideas will arrive as a result of this article, and more uses will be found for the code once released on Cool Solutions.

 

(This article was published in OHM28, 1-2015, p8-10).

Leave a Reply