Code Monkey home page Code Monkey logo

nfs-mounter's Introduction

nfs-mounter

This project generates a maven artifact that can be used to programmatically cause AutoFS to mount the specified NFS shares without the need for root privilages. The same mounter object can also be used on Windows, where the share is mounted as normal. Thus the consumer does not need to worry about platform specific code.

First, set up AutoFS

  1. Ensure AutoFS is installed and configured for linux. See https://wiki.archlinux.org/index.php/Autofs for specifics.
  2. edit the autofs master template file. This is usually something like /etc/autofs/auto.master or /etc/auto.master. *By default nfs-mounter will look for the following entry: /mnt/hydra /usr/local/etc/auto.hydra –timeout=60 *The expected fields' values can be changed by modifying a com.seven10.nfs_mounter.parameters.NfsMounterFactorySettings object, and passing it to com.seven10.nfs_mounter.NfsMounterFactory.setMounterConfig().
  3. Restart the autofs service.
  4. create the template file in the location you specified in the master file; eg touch /usr/local/etc/auto.hydra. Make sure the user that will be running the library has write access to this file. Leave the file empty

Next, add the nfs-mounter artifact to your project's pom file. Use the following settings:

<dependency>
    <groupId>com.seven10</groupId>
    <artifactId>nfs-mounter</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

Here is an example of how to use this function:

	private List<NfsMountExportsParameter> createParamObjects()
	{
		List<NfsMountExportsParameter> rval = new ArrayList<NfsMountExportsParameter>();
		rval.add(new NfsMountExportsParameter("my_share","localhost", "/nfs/my_share"));
		rval.add(new NfsMountExportsParameter("work", "isilon.corprate.interwebz", "/ifs"));
		rval.add(new NfsMountExportsParameter("windows","192.168.55.31", "/drive_c"));
		rval.add(new NfsMountExportsParameter("nfs_test","10.2.31.5", "/nfs_stuff"));
		return rval;
	}
	
	public void listNfsFiles() throws NfsClientException
	{
		NfsMounter mounter = NfsMounterFactory.getMounter();
		List<NfsMountExportsParameter> parameterObjects = createParamObjects();
		List<File> files = mounter.mountExports(parameterObjects);
		for(File f: files)
		{
			// do something interesting to each mounted folder
		}
	}

nfs-mounter's People

Contributors

seven10builder avatar phov 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.