Skip to content

Commit 2636da8

Browse files
committed
Multi-masternode implemented! Job deletion completed
1 parent 8fb5d16 commit 2636da8

11 files changed

+104
-46
lines changed

delete.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
1010

1111
// Apre la risorsa SSH
12-
$connection_handler = ssh2_connect($world['sshserver'],$world['sshport']);
12+
$connection_handler = ssh2_connect($_SESSION['sshserver'],$_SESSION['sshport']);
1313
if(!$connection_handler) {
14-
die("[delete.php] Connection Failed: ". $world['sshserver']." at ".$world['sshport']);
14+
die("[delete.php] Connection Failed: ". $_SESSION['sshserver']." at ".$_SESSION['sshport']);
1515
}
1616

1717
// Esegue la autenticazione in SSH con password plain

download.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111

1212
// Apre la risorsa SSH
13-
$connection_handler = ssh2_connect($world['sshserver'],$world['sshport']);
13+
$connection_handler = ssh2_connect($_SESSION['sshserver'],$_SESSION['sshport']);
1414
if(!$connection_handler) {
15-
die("[download.php] Connection Failed: ". $world['sshserver']." at ".$world['sshport']);
15+
die("[download.php] Connection Failed: ". $_SESSION['sshserver']." at ".$_SESSION['sshport']);
1616
}
1717

1818
// Esegue la autenticazione in SSH con password plain
@@ -24,7 +24,7 @@
2424
// Copia il file in un punto raggiungibile dall'interprete
2525
// il nome viene reso irriconoscibile
2626
$file = $_SESSION['home'].'/'.$_GET['file'];
27-
$temp_file = '/tmp/'.uniqid('down-');
27+
$temp_file = $world['tmp'].'/'.uniqid('down-');
2828
ssh2_scp_recv($connection_handler,$file,$temp_file);
2929

3030
header('Content-Description: File Transfer');

globals.php

+13-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
$world['ClusterName'] = "X-CLUSTER";
33
$world['ClusterLogo'] = "img/x-cluster-logo.png";
44
$world['UniLogo'] = "img/unitn-logo.png";
5-
$world['GangliaURL'] = 'http://x-cluster.science.unitn.it';
5+
$world['GangliaURL'] = 'http://ganglia.wikimedia.org/latest/';
66
$world['AdminMail'] = "[email protected]";
77
$world['University'] = "Università degli studi di Trento";
8-
$world['sshserver'] = "localhost";
9-
$world['sshport'] = "22";
108
$world['queue_list'] = array("batch","Another_queue1","Another_queue2");
119
$world['upload_temp'] = '/var/www/uploads';
10+
$world['tmp'] = '/tmp';
1211
$debug = true;
1312

13+
// List server
14+
$world['server_list'][0] = 'localhost:22';
15+
$world['server_list'][1] = '192.168.1.10:22';
16+
1417
// Bisogna ricordarsi di settare il parametro di upload_temp_dir
1518

1619

@@ -19,11 +22,12 @@
1922

2023
$world['ClusterLogo2'] = "<img src=\"" . $world['ClusterLogo'] . "\" width=\"150px\">";
2124
$world['UniLogo2'] = "<img src=\"" . $world['UniLogo'] . "\" width=\"150px\">";
22-
$world['GangliaURL2'] = '<a href="' . $world['GangliaURL'] . '"><i class="icon-eye-open icon-white"></i> Ganglia</a>';
25+
$world['GangliaURL2'] = '<a href="' . $world['GangliaURL'] . '" class="titolo_nav"><i class="icon-eye-open icon-white"></i> Ganglia</a>';
2326
$world['AdminMail2'] = "<a href=\"mailto:" . $world['AdminMail'] . "\">Contact Admin</a>";
2427
$world['AdminMail3'] = "<a href=\"mailto:" . $world['AdminMail'] . "\">here</a>";
2528

26-
$VERSION = "v0.7 - Linux - DEBUG";
29+
$VERSION = 'v0.7Alpha - Linux';
30+
if($debug) { $VERSION .= ' - DebugOn'; }
2731
?>
2832

2933
<?php
@@ -40,9 +44,9 @@ function ssh2_exec2($username, $password, $command)
4044
global $world;
4145

4246
// Apre la risorsa SSH
43-
$connection_handler = ssh2_connect($world['sshserver'],$world['sshport']);
47+
$connection_handler = ssh2_connect($_SESSION['sshserver'],$_SESSION['sshport']);
4448
if(!$connection_handler) {
45-
die("[globals.php] Connection Failed: ". $world['sshserver']." at ".$world['sshport']);
49+
die("[globals.php] Connection Failed: ". $_SESSION['sshserver']." at ".$_SESSION['sshport']);
4650
}
4751

4852
// Esegue la autenticazione in SSH con password plain
@@ -99,9 +103,9 @@ function ssh2_sftp_down($username, $password, $abs_path) {
99103
global $world;
100104

101105
// Apre la risorsa SSH
102-
$connection_handler = ssh2_connect($world['sshserver'],$world['sshport']);
106+
$connection_handler = ssh2_connect($_SESSION['sshserver'],$_SESSION['sshport']);
103107
if(!$connection_handler) {
104-
die("[globals.php] Connection Failed: ". $world['sshserver']." at ".$world['sshport']);
108+
die("[globals.php] Connection Failed: ". $_SESSION['sshserver']." at ".$_SESSION['sshport']);
105109
}
106110

107111
// Esegue la autenticazione in SSH con password plain

html_include/header.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@
1414
<div class="navbar navbar-inverse navbar-fixed-top">
1515
<div class="navbar-inner">
1616
<div class="container">
17-
<a class="brand" href="#"><? echo $world['ClusterName']; ?></a>
17+
<a class="brand titolo_brand" href="#"><? echo $world['ClusterName']; ?></a>
1818
<div class="nav-collapse collapse">
1919
<ul class="nav">
2020
<li <? if ($active === 'home') { echo 'class="active"'; } ?>>
21-
<a href="mainmenu.php">
22-
<i class="icon-home icon-white"></i>
21+
<a href="mainmenu.php" class="titolo_nav">
22+
<i class="icon-home icon-white image-nav"></i>
2323
Home
2424
</a>
2525
</li>
2626
<li <? if ($active === 'queue') { echo 'class="active"'; } ?>>
27-
<a href="queue_status.php">
28-
<i class="icon-th-list icon-white"></i>
27+
<a href="queue_status.php" class="titolo_nav">
28+
<i class="icon-th-list icon-white image-nav"></i>
2929
Queue
3030
</a>
3131
</li>
3232
<li <? if ($active === 'submit') { echo 'class="active"'; } ?>>
33-
<a href="jsubmit.php#FormCreate">
34-
<i class="icon-download-alt icon-white"></i>
33+
<a href="jsubmit.php#FormCreate" class="titolo_nav">
34+
<i class="icon-download-alt icon-white image-nav"></i>
3535
Submit
3636
</a>
3737
</li>
3838
<li <? if ($active === 'ssh') { echo 'class="active"'; } ?>>
39-
<a href="sshinterf.php">
40-
<i class="icon-tasks icon-white"></i>
39+
<a href="sshinterf.php" class="titolo_nav">
40+
<i class="icon-tasks icon-white image-nav"></i>
4141
SSH
4242
</a>
4343
</li>
@@ -49,9 +49,9 @@
4949
<? echo $world['GangliaURL2']; ?>
5050
</li>
5151
<li>
52-
<a href="logout.php">
53-
<i class="icon-user icon-white"></i>
54-
Logout
52+
<a href="logout.php" class="titolo_nav">
53+
<i class="icon-user icon-white image-nav"></i>
54+
Logout <? echo $_SESSION['username'].'@'.$_SESSION['sshserver']; ?>
5555
</a>
5656
</li>
5757
</ul>

html_include/qstatxml.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,10 @@ function make_job_table($j) {
105105
$output .= ' </td>';
106106
$output .= ' <td class="muted" width="30%">'.$j['owner'].'</td>';
107107
$output .= ' <td align="right" width="10%">';
108-
if ($j['owned'] === true) {
109-
$output .= ' <a href="#" onclick="$('."'#".$j['name'].$j['id']."'".').click();">';
108+
if ($j['owned'] === true && ($j['state'] === 'Queued' || $j['state'] === 'Running')) {
109+
$output .= ' <a href="job_delete.php?jid='.$j['id'].'">';
110110
$output .= ' <span class="badge badge-important">Delete</span>';
111111
$output .= ' </a>';
112-
$output .= ' <form style="display:none;" method="POST" action="qdel.php">';
113-
$output .= ' <input type="text" value="'.$j['id'].'" name="jid" />';
114-
$output .= ' <button id="'.$j['name'].$j['id'].'" type="submit"></button>';
115-
$output .= ' </form>';
116112
}
117113
$output .= ' </td>';
118114
$output .= ' </tr>';
@@ -256,8 +252,8 @@ function make_job_table($j) {
256252
</div>
257253
<div class="modal-footer">
258254
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>';
259-
if( $j['owned'] === true ) {
260-
$output .='<button class="btn btn-danger" onclick="$('."'#".$j['name'].$j['id']."'".').click()">Delete Job</button>';
255+
if( $j['owned'] === true && ($j['state'] === 'Queued' || $j['state'] === 'Running')) {
256+
$output .='<a class="btn btn-danger" href="job_delete.php?jid='.$j['id'].'">Delete Job</a>';
261257
}
262258
$output .= ' </div>
263259
</div>';

index.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@
1919
if (!isset($_SESSION['username'])) $_SESSION['username'] = null;
2020
if (!isset($_SESSION['password'])) { $_SESSION['password'] = null; }
2121
if (!isset($_SESSION['home'])) { $_SESSION['home'] = null; }
22+
23+
function create_server_list($server_array) {
24+
$output = "";
25+
$output = '<select name="server_select" class="span2" id="server_select">';
26+
27+
foreach($server_array as $server) {
28+
29+
$output .= '
30+
<option>'.$server.'</option>';
31+
}
32+
$output .= '</select>';
33+
return $output;
34+
}
35+
?>
2236

2337
?>
2438

@@ -62,7 +76,11 @@
6276
<h2 class="form-signin-heading">Please login</h2>
6377
<input type="text" class="input-block-level" name="username" placeholder="SSH username">
6478
<input type="password" class="input-block-level" name="password" placeholder="Password">
65-
<button class="btn btn-large btn-primary" type="submit">Login</button>
79+
<div class="input-prepend input-append" style="position:relative; left:-2px;">
80+
<button class="btn btn-primary span2" type="submit">Login</button>
81+
<span class="add-on">@</span>
82+
<? echo create_server_list($world['server_list']); ?>
83+
</div>
6684
</form>
6785
</div> <!-- /container -->
6886
<!-- Fine Body -->

job_delete.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?
2+
session_start();
3+
4+
include_once('globals.php');
5+
6+
$redirect = "https://".$_SERVER['HTTP_HOST']."/index.php";
7+
if (!isset($_SESSION['username'])) { header("Location:$redirect"); }
8+
if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
9+
if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
10+
11+
if($debug) {
12+
$qdel_cmd = 'touch '.$_GET['jid'].'.txt';
13+
} else {
14+
$qdel_cmd = 'qdel '.$_POST['relative_path'];
15+
}
16+
17+
$output = ssh2_exec2($_SESSION['username'],$_SESSION['password'],$qdel_cmd);
18+
header('Location:queue_status.php');
19+
20+
?>

login_ssh.php

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
session_start();
44
include_once("globals.php");
5+
6+
$exploded = explode(':',$_POST['server_select']);
7+
$_SESSION['sshserver'] = $exploded[0];
8+
$_SESSION['sshport'] = $exploded[1];
59

610
$_SESSION['home'] = null;
711

style.css

+17-1
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,20 @@ body {
110110
font-weight: bold;
111111
font-size: 0.8em;
112112
width:150px;
113-
}
113+
}
114+
115+
/*login*/
116+
#server_select {
117+
-webkit-border-radius: 0px 4px 4px 0px;
118+
-moz-border-radius: 0px 4px 4px 0px;
119+
border-radius: 0px 4px 4px 0px;
120+
}
121+
122+
.titolo_nav {
123+
font-size: 0.75em;
124+
font-weight: bold;
125+
}
126+
127+
.image_nav {/*refuso*/}
128+
129+
.titolo_brand { font-weight: bold; }

submit_run.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
99
if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
1010

11-
$tmpfile = '/tmp/'.uniqid('qsub-');
11+
$tmpfile = $world['tmp'].'/'.uniqid('qsub-');
1212
file_put_contents($tmpfile, $_POST['result_script']);
1313
if(!$_POST['scriptname']) { $_POST['scriptname'] = uniqid('qsub-'); }
1414
$file = $_SESSION['home'].'/'.$_POST['scriptname'].'.pbs';
1515

1616
// Apre la risorsa SSH
17-
$connection_handler = ssh2_connect($world['sshserver'],$world['sshport']);
17+
$connection_handler = ssh2_connect($_SESSION['sshserver'],$_SESSION['sshport']);
1818
if(!$connection_handler) {
19-
die("[submit_run.php] Connection Failed: ". $world['sshserver']." at ".$world['sshport']);
19+
die("[submit_run.php] Connection Failed: ". $_SESSION['sshserver']." at ".$_SESSION['sshport']);
2020
}
2121

2222
// Esegue la autenticazione in SSH con password plain

upload_scp.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
session_start();
33
include_once('globals.php');
44

5-
//$redirect = "https://".$_SERVER['HTTP_HOST']."/index.php";
6-
//if (!isset($_SESSION['username'])) { header("Location:$redirect"); }
7-
//if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
8-
//if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
5+
$redirect = "https://".$_SERVER['HTTP_HOST']."/index.php";
6+
if (!isset($_SESSION['username'])) { header("Location:$redirect"); }
7+
if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
8+
if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
99

1010
$error_msg = array("OK", "exceed max_file_size - ini", "exceed max_file_size", "partial upload", "no file uploaded", "write to disk failed", "temp dir missing", "unknown extension error");
1111

1212
// Apre la risorsa SSH
13-
$connection_handler = ssh2_connect($world['sshserver'],$world['sshport']);
13+
$connection_handler = ssh2_connect($_SESSION['sshserver'],$_SESSION['sshport']);
1414
if(!$connection_handler) {
15-
die("[upload_scp.php] Connection Failed: ". $world['sshserver']." at ".$world['sshport']);
15+
die("[upload_scp.php] Connection Failed: ". $_SESSION['sshserver']." at ".$_SESSION['sshport']);
1616
}
1717

1818
// Esegue la autenticazione in SSH con password plain
@@ -26,7 +26,7 @@
2626
$tmp_name = $_FILES["filesToUpload"]["tmp_name"][$key];
2727
$name = $_FILES["filesToUpload"]["name"][$key];
2828

29-
$source = $world['upload_temp'] . '/' . $name;
29+
$source = $world['tmp'] . '/' . $name;
3030
$destination = $_SESSION['home'] . '/' .$name;
3131

3232
// localhost

0 commit comments

Comments
 (0)