39 |
|
|
40 |
<script type='text/javascript'> |
<script type='text/javascript'> |
41 |
$(document).ready( function() { |
$(document).ready( function() { |
42 |
loadServer(); |
setInterval(refreshData, 60000); |
43 |
|
refreshData(); |
44 |
}); |
}); |
45 |
|
|
46 |
|
function refreshData() { |
47 |
|
$.get('ajaxdata.php', function(xml) { |
48 |
|
$(xml).find('vm').each(function() { |
49 |
|
var name = $(this).find('name').text(); |
50 |
|
var state = $(this).find('state').text(); |
51 |
|
|
52 |
|
name = name.replace(" ", "_"); |
53 |
|
name = name.replace(".", "_"); |
54 |
|
|
55 |
|
var id = "#state_" + name; |
56 |
|
var css = $(id).css("background"); |
57 |
|
|
58 |
|
if (state == "Running") { |
59 |
|
$(id).css("background-image", "url('gfx/vps_topgreen.png')"); |
60 |
|
} else { |
61 |
|
$(id).css("background-image", "url('gfx/vps_topred.png')"); |
62 |
|
} |
63 |
|
|
64 |
|
}) |
65 |
|
}); |
66 |
|
} |
67 |
|
|
68 |
function doAction(action, uuid) { |
function doAction(action, uuid) { |
69 |
var key = prompt("Key"); |
var key = prompt("Key"); |
70 |
if (key == "" || key == null) { |
if (key == "" || key == null) { |
76 |
var response = $.get(url, function(data) { |
var response = $.get(url, function(data) { |
77 |
alert(data); |
alert(data); |
78 |
document.body.style.cursor = 'default' |
document.body.style.cursor = 'default' |
79 |
if (data == "OK") { |
|
80 |
window.location.reload(); |
refreshData(); |
|
} |
|
81 |
}); |
}); |
82 |
} |
} |
83 |
|
|
96 |
window.open(url); |
window.open(url); |
97 |
} |
} |
98 |
|
|
|
function loadServer() { |
|
|
$('#mainwindow').load('server.php'); |
|
|
} |
|
99 |
|
|
|
function loadvm(uuid) { |
|
|
$('#mainwindow').load('vm.php?uuid=' + uuid ); |
|
|
} |
|
100 |
|
|
101 |
</script> |
</script> |
102 |
|
|
172 |
$harddrive_size = 0; |
$harddrive_size = 0; |
173 |
$cpu_count = $vm["VCPUs_max"]; |
$cpu_count = $vm["VCPUs_max"]; |
174 |
|
|
175 |
|
$clean_name = str_replace(" ", "_", $name); |
176 |
|
$clean_name = str_replace(".", "_", $clean_name); |
177 |
|
|
178 |
|
|
179 |
foreach ($vm["VBDs"] as $vbds) { |
foreach ($vm["VBDs"] as $vbds) { |
180 |
$vbd = $xenserver->VBD__get_record($vbds); |
$vbd = $xenserver->VBD__get_record($vbds); |
181 |
if ($vbd["type"] == 'Disk') { |
if ($vbd["type"] == 'Disk') { |
192 |
$vps_topbg = 'vps_topred.png'; |
$vps_topbg = 'vps_topred.png'; |
193 |
} |
} |
194 |
|
|
195 |
|
$network = ""; |
196 |
|
if ( $vm["power_state"] == "Running" && $vm["guest_metrics"] != "OpaqueRef:NULL" ) { |
197 |
|
$guest_metrics = $xenserver->VM_guest_metrics__get_record( $vm["guest_metrics"] ); |
198 |
|
$network = "(IP: " . implode( ",", $guest_metrics["networks"]) . ")"; |
199 |
|
} else { |
200 |
|
$guest_metrics = Array() ; |
201 |
|
} |
202 |
|
|
203 |
|
|
204 |
$url = ""; |
$url = ""; |
205 |
$session = ""; |
$session = ""; |
206 |
foreach($vm["consoles"] as $conref) { |
foreach($vm["consoles"] as $conref) { |
212 |
$session = $xenserver->get_id(); |
$session = $xenserver->get_id(); |
213 |
} |
} |
214 |
} |
} |
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
// echo "<a href='#' onclick=\"loadvm('$uuid');\">$name</a><br>\n"; |
// echo "<a href='#' onclick=\"loadvm('$uuid');\">$name</a><br>\n"; |
220 |
?> |
?> |
221 |
<!-- MACHINE --> |
<!-- MACHINE --> |
222 |
<table width='99%' cellpadding='3' cellspacing='0' border='0' class='vps'> |
<table width='99%' cellpadding='3' cellspacing='0' border='0' class='vps' id='<?php echo $name;?>'> |
223 |
<tr background='gfx/vps_topbg.png'> |
<tr background='gfx/vps_topbg.png'> |
224 |
<td width='10' background='gfx/<?php echo $vps_topbg; ?>' class='small'> </td> |
<td width='10' background='gfx/<?php echo $vps_topbg; ?>' class='small' id='state_<?php echo $clean_name;?>'> </td> |
225 |
<td colspan='2' class='small'><b><?php echo $name; ?></b></td> |
<td colspan='2' class='small'><b><?php echo $name; ?></b></td> |
226 |
<td colspan='2' class='small' align='right'> |
<td colspan='2' class='small' align='right'> |
227 |
(IP: 192.168.10.45, 172.10.0.34) |
<?php echo $network;?> |
228 |
<a href="#" onclick="console('<?php echo $url;?>','<?php echo $session;?>')"><img src='gfx/icon-terminal.png' style='vertical-align: middle;'></a> |
<?php |
229 |
|
if ($url != "") { |
230 |
|
echo "<a href='#' onclick=\"console('$url','$session')\"><img src='gfx/icon-terminal.png' style='vertical-align: middle;'></a>"; |
231 |
|
} |
232 |
|
?> |
233 |
</td> |
</td> |
234 |
</tr> |
</tr> |
235 |
|
|
236 |
<tr bgcolor='#eee'> |
<tr bgcolor='#eee'> |
237 |
<td></td> |
<td></td> |
238 |
|
|
239 |
<td width='150' class='small'>start stop force</td> |
<td width='150' class='small'> |
240 |
|
<?php |
241 |
|
if ($state == "Running") { |
242 |
|
echo "start | "; |
243 |
|
echo "<a href='#' onclick=\"doAction('shutdown','$uuid')\">stop</a> | "; |
244 |
|
echo "<a href='#' onclick=\"doAction('hardshutdown','$uuid')\">force shutdown</a>"; |
245 |
|
} else { |
246 |
|
echo "<a href='#' onclick=\"doAction('start','$uuid')\">start</a> | "; |
247 |
|
echo "stop | "; |
248 |
|
echo "force shutdown"; |
249 |
|
} |
250 |
|
?> |
251 |
|
|
252 |
|
</td> |
253 |
|
|
254 |
<td width='100' align='right' class='small'> |
<td width='100' align='right' class='small'> |
255 |
<img src='gfx/icon-cpu.png' style='vertical-align: middle;'> |
<img src='gfx/icon-cpu.png' style='vertical-align: middle;'> |