Last active
October 7, 2015 20:50
-
-
Save jtriley/3223691 to your computer and use it in GitHub Desktop.
Example sshfs plugin and config for StarCluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)