Skip to content

Instantly share code, notes, and snippets.

@jtriley
Last active October 7, 2015 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtriley/3223691 to your computer and use it in GitHub Desktop.
Save jtriley/3223691 to your computer and use it in GitHub Desktop.
Example sshfs plugin and config for StarCluster
# This is an example config that assumes sshfs.py is either in
# $HOME/.starcluster/plugins or lives somewhere in your $PYTHONPATH
[vol myvol]
volume_id = vol-99999
mount_path = /results
[plugin sshfs]
setup_class = sshfs.SSHFSPlugin
local_mount_path = ~/ec2-results
volume = myvol
[cluster default]
...
volumes = myvol
plugins = sshfs
# Install this file to $HOME/.starcluster/plugins/sshfs.py or somewhere on your $PYTHONPATH
import os
from starcluster.clustersetup import ClusterSetup
from starcluster.logger import log
class SSHFSPlugin(ClusterSetup):
def __init__(self, local_mount_path, volume):
self.mount_path = os.path.expanduser(local_mount_path)
self.volume = volume
def run(self, nodes, master, user, user_shell, volumes):
if not os.path.exists(self.mount_path):
log.info("Creating mount path: %s" % self.mount_path)
os.makedirs(self.mount_path)
vol_path = volumes.get(self.volume).get('mount_path')
ctx = dict(key=master.key_location, user=user, server=master.dns_name,
vol_path=vol_path, mount_path=self.mount_path)
log.info("Mounting master:%s over sshfs" % vol_path)
os.system('sshfs -o ssh_command="ssh -i %(key)s" '
'%(user)s@%(server)s:%(vol_path)s %(mount_path)s' % ctx)
@why-not
Copy link

why-not commented Sep 27, 2013

I had to modify the last line in this script to the following to make it work:

os.system('sshfs -o ssh_command="ssh -i %(key)s" %(user)s@%(server)s:%(vol_path)s %(mount_path)s' % ctx)

@jtriley
Copy link
Author

jtriley commented Dec 19, 2013

@why-not Thanks, fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment