<?php /* * get_public_key * Created on: May 7, 2013 12:20:57 PM * * Copyright 2013 EnginSoft S.p.A. * All rights reserved */ include_once 'neurocloud/lib/common.php'; $user = $_GET['user']; $keyfile = get_private_key_file($user); if (is_file($keyfile)) { $output = exec("ssh-keygen -y -f {$keyfile}"); header("Content-Type: text/plain"); echo $output . " {$user}"; } else { header("Content-Type: text/plain"); echo "No private key found: {$keyfile}"; } exit;
public static function afterDeleteUser($info) { $user = $info['uid']; $keyfile = get_private_key_file($user); $publickeyfile = get_public_key_file($user); exec("rm -f {$keyfile} {$publickeyfile}"); exec("sudo umount " . OC_Config::getValue("datadirectory") . "/{$user}"); }
if (isset($_GET["jobid"])) { $rerun = true; $job_id = $_GET["jobid"]; } $space = get_used_space_remote(); if (is_array($space) && (int) $space['percent'] > (int) $NC_CONFIG['minimum_exec_space']) { # Redirect to neurocloud app index , showing an error message $link = OC_Helper::linkTo("neurocloud", "index.php", array("error" => "Cannot execute script, low free space in remote server.<br>Contact administration or delete old jobs")); header("Location: " . $link); exit; } if (OC_Neurocloud::is_study_runnable($study)) { if (isset($_GET["mode"]) && $_GET["mode"] == "remote") { // execute the script in the remote server via a SSH command // obtain the key file for the current user $key = get_private_key_file(OC_User::getUser()); // if the file does not exist, the user cannot launch a job if (!is_file($key)) { OC_Log::write("neurocloud", "Private key file {$key} not found", OC_Log::ERROR); $pid = false; } else { if (!$rerun) { $job_id = create_execution_env($study, $script); } $exec_dir = get_job_exec_dir_remote($job_id); $pid = execute_script_remote($study, $job_id, $exec_dir, $rerun, "pipeline" . DIRECTORY_SEPARATOR . $script); } } else { /* execute script locally in the owncloud machine */ if (!$rerun) { $job_id = create_execution_env($study, $script);
/** * * @param type $qsub_jobname * @return array an array containing 2 values: the first is the number of queued jobs, the second is the number of running jobs */ function get_queue_info($qsub_jobname) { include "neurocloud/config.inc.php"; $output = ""; $return_var = 0; $user = OC_User::getUser(); $host = $NC_CONFIG["remote_host"]; $key = get_private_key_file($user); $return_string = array(0, 0); // the process is not running, but there could be still pending SGE jobs in the cluster // so, we will check with qstat if there are still jobs $cmdline_qstat = create_ssh_command() . "qstat -u {$user} -xml 2>/dev/null "; exec($cmdline_qstat, $output, $return_var); if ($return_var == 0) { $xml_output = join("", $output); // parse the XML given in output $xml = new SimpleXMLElement($xml_output); /* the returned XML has this structure: <job_info><queue_info>[<job_list>*]<job_info>[<job_list>*] * * each job_list contains the data for a single SGE job (name, queue, state, etc) */ if ($xml->queue_info->job_list->count() == 0 && $xml->job_info->job_list->count() == 0) { #$return_string = "No running SGE jobs in queue for job_id " . $qsub_jobname; return $return_string; } else { #$return_string = "Running SGE jobs:\n"; foreach ($xml->queue_info->job_list as $job) { // check if the SGE job name contains the generated job id for this neurocloud job if (strpos($job->JB_name, $qsub_jobname)) { #$return_string = $return_string . $job->JB_name . "\n"; $return_string[1] = $return_string[1] + 1; } } #$return_string = $return_string . "\nQueued SGE jobs:\n"; foreach ($xml->job_info->job_list as $job) { // check if the SGE job name contains the generated job id for this neurocloud job if (strpos($job->JB_name, $qsub_jobname)) { #$return_string = $return_string . $job->JB_name . "\n"; $return_string[0] = $return_string[0] + 1; } } } return $return_string; } else { //return "No SGE jobs in queue for job_id " . $qsub_jobname; return array(0, 0); } }