def _setup_munge(self): """ Setup Munge (used by Slurm as a user auth mechanism) """ log.debug("Setting up Munge (for Slurm)...") if not os.path.exists('/etc/munge'): # Munge not installed so grab it misc.run("apt-get update; apt-get install munge libmunge-dev -y") misc.run("/usr/sbin/create-munge-key") misc.append_to_file('/etc/default/munge', 'OPTIONS="--force"') misc.run("service munge start") log.debug("Done setting up Munge") # Copy the munge key to cluster NFS if not os.path.exists(self.app.path_resolver.slurm_root_nfs): misc.make_dir(self.app.path_resolver.slurm_root_nfs) nfs_munge_key = os.path.join(self.app.path_resolver.slurm_root_nfs, 'munge.key') shutil.copyfile('/etc/munge/munge.key', nfs_munge_key) os.chmod(nfs_munge_key, 0400) log.debug("Copied /etc/munge/munge.key to {0}".format(nfs_munge_key))
def _configure_sge(self): log.info("Setting up SGE...") SGE_config_file = '%s/galaxyEC2.conf' % self.app.path_resolver.sge_root with open(SGE_config_file, 'w') as f: print >> f, _get_sge_install_conf( self.app, self.app.cloud_interface.get_private_ip()) os.chown(SGE_config_file, pwd.getpwnam("sgeadmin")[2], grp.getgrnam("sgeadmin")[2]) log.debug("Created SGE install template as file '%s'" % SGE_config_file) fix_libc() log.debug("Setting up SGE.") self._fix_util_arch() if misc.run( 'cd %s; ./inst_sge -m -x -auto %s' % (self.app.path_resolver.sge_root, SGE_config_file), "Setting up SGE did not go smoothly", "Successfully set up SGE"): log.debug("Successfully setup SGE; configuring SGE") log.debug("Adding parallel environments") pes = ['SGE_SMP_PE', 'SGE_MPI_PE'] for pe in pes: pe_file_path = os.path.join('/tmp', pe) with open(pe_file_path, 'w') as f: print >> f, conf_manager.load_conf_template( getattr(conf_manager, pe)).safe_substitute() misc.run('cd %s; ./bin/lx24-amd64/qconf -Ap %s' % (self.app.path_resolver.sge_root, pe_file_path)) log.debug("Creating queue 'all.q'") SGE_allq_file = '%s/all.q.conf' % self.app.path_resolver.sge_root all_q_template = conf_manager.load_conf_template( conf_manager.SGE_ALL_Q_TEMPLATE) if self.app.config.hadoop_enabled: all_q_params = { "slots": int(commands.getoutput("nproc")), "prolog_path": os.path.join( paths.P_HADOOP_HOME, paths.P_HADOOP_INTEGRATION_FOLDER + "/hdfsstart.sh"), "epilog_path": os.path.join( paths.P_HADOOP_HOME, paths.P_HADOOP_INTEGRATION_FOLDER + "/hdfsstop.sh") } else: all_q_params = { "slots": int(commands.getoutput("nproc")), "prolog_path": 'NONE', "epilog_path": 'NONE' } with open(SGE_allq_file, 'w') as f: print >> f, all_q_template.substitute(all_q_params) os.chown(SGE_allq_file, pwd.getpwnam("sgeadmin")[2], grp.getgrnam("sgeadmin")[2]) log.debug("Created SGE all.q template as file '%s'" % SGE_allq_file) misc.run( 'cd %s; ./bin/lx24-amd64/qconf -Mq %s' % (self.app.path_resolver.sge_root, SGE_allq_file), "Error modifying all.q", "Successfully modified all.q") log.debug("Configuring users' SGE profiles") misc.append_to_file( paths.LOGIN_SHELL_SCRIPT, "\nexport SGE_ROOT=%s" % self.app.path_resolver.sge_root) misc.append_to_file(paths.LOGIN_SHELL_SCRIPT, "\n. $SGE_ROOT/default/common/settings.sh\n") # Write out the .sge_request file for individual users sge_request_template = conf_manager.load_conf_template( conf_manager.SGE_REQUEST_TEMPLATE) sge_request_params = { 'psql_home': self.app.path_resolver.pg_home, 'galaxy_tools_dir': self.app.path_resolver.galaxy_tools, } users = ['galaxy', 'ubuntu'] for user in users: sge_request_file = os.path.join('/home', user, '.sge_request') with open(sge_request_file, 'w') as f: print >> f, sge_request_template.substitute( sge_request_params) os.chown(sge_request_file, pwd.getpwnam(user)[2], grp.getgrnam(user)[2]) return True return False