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 |
|
$('.console').click( function() { |
45 |
|
var session = $(this).data('session'); |
46 |
|
var conurl = $(this).data('conurl'); |
47 |
|
console(conurl,session); |
48 |
|
}); |
49 |
|
|
50 |
|
$('#logo').click( function() { |
51 |
|
refreshData(); |
52 |
|
}); |
53 |
}); |
}); |
54 |
|
|
55 |
function doAction(action, uuid) { |
function refreshData() { |
56 |
|
$.get('ajaxdata.php', function(xml) { |
57 |
|
$(xml).find('vm').each(function() { |
58 |
|
var name = $(this).find('name').text(); |
59 |
|
var state = $(this).find('state').text(); |
60 |
|
var network = $(this).find('network').text(); |
61 |
|
var state = $(this).find('state').text(); |
62 |
|
var conurl = $(this).find('conurl').text(); |
63 |
|
var session = $(this).find('session').text(); |
64 |
|
|
65 |
|
name = name.replace(" ", "_"); |
66 |
|
name = name.replace(".", "_"); |
67 |
|
|
68 |
|
var id = "#vm_" + name; |
69 |
|
|
70 |
|
var vm = $(id); |
71 |
|
|
72 |
|
if (state == "Running") { |
73 |
|
vm.find('.state').css("background-image", "url('gfx/vps_topgreen.png')"); |
74 |
|
vm.find('.network').show(); |
75 |
|
vm.find('.network').text( '(IP: ' + network + ')' ); |
76 |
|
vm.find('.console').show(); |
77 |
|
vm.find('.console').data('conurl', conurl); |
78 |
|
vm.find('.console').data('session', session); |
79 |
|
vm.find('.actionstop').show(); |
80 |
|
vm.find('.actionstart').hide(); |
81 |
|
} else { |
82 |
|
if (state == "Halted") { |
83 |
|
vm.find('.state').css("background-image", "url('gfx/vps_topred.png')"); |
84 |
|
} else { |
85 |
|
vm.find('.state').css("background-image", "url('gfx/vps_topyellow.png')"); |
86 |
|
} |
87 |
|
vm.find('.network').hide(); |
88 |
|
vm.find('.console').hide(); |
89 |
|
vm.find('.actionstop').hide(); |
90 |
|
vm.find('.actionstart').show(); |
91 |
|
} |
92 |
|
|
93 |
|
}) |
94 |
|
}); |
95 |
|
} |
96 |
|
|
97 |
|
function doAction(action, uuid, vm) { |
98 |
var key = prompt("Key"); |
var key = prompt("Key"); |
99 |
if (key == "" || key == null) { |
if (key == "" || key == null) { |
100 |
return; |
return; |
101 |
} |
} |
102 |
document.body.style.cursor = 'wait'; |
document.body.style.cursor = 'wait'; |
103 |
|
$('#vm_' + vm).find('.state').css("background-image", "url('gfx/vps_topyellow.png')"); |
104 |
|
|
105 |
var url = "action.php?action=" + action + "&uuid=" + uuid + "&key=" + key; |
var url = "action.php?action=" + action + "&uuid=" + uuid + "&key=" + key; |
106 |
var response = $.get(url, function(data) { |
var response = $.get(url, function(data) { |
107 |
alert(data); |
if (data != 'OK') { |
108 |
document.body.style.cursor = 'default' |
alert(data); |
|
if (data == "OK") { |
|
|
window.location.reload(); |
|
109 |
} |
} |
110 |
|
document.body.style.cursor = 'default' |
111 |
|
|
112 |
|
refreshData(); |
113 |
}); |
}); |
114 |
} |
} |
115 |
|
|
128 |
window.open(url); |
window.open(url); |
129 |
} |
} |
130 |
|
|
|
function loadServer() { |
|
|
$('#mainwindow').load('server.php'); |
|
|
} |
|
131 |
|
|
|
function loadvm(uuid) { |
|
|
$('#mainwindow').load('vm.php?uuid=' + uuid ); |
|
|
} |
|
132 |
|
|
133 |
</script> |
</script> |
134 |
|
|
170 |
|
|
171 |
<table width='100%' background='gfx/topbg.png' cellpadding='3' cellspacing='0' border='0' class='toptable'> |
<table width='100%' background='gfx/topbg.png' cellpadding='3' cellspacing='0' border='0' class='toptable'> |
172 |
<tr> |
<tr> |
173 |
<td rowspan='2' width='160'><img src='gfx/citrix-logo.png'></td> |
<td rowspan='2' width='160'><img src='gfx/citrix-logo.png' id='logo'></td> |
174 |
<td colspan='3' class='small' align='right'>Linux:2.6.32.12-0.7.1.xs6.0.2.542.170665xen / xen: 4.1.2 / xapi: 1.3</td> |
<td colspan='3' class='small' align='right'>Linux:2.6.32.12-0.7.1.xs6.0.2.542.170665xen / xen: 4.1.2 / xapi: 1.3</td> |
175 |
</tr> |
</tr> |
176 |
<tr> |
<tr> |
204 |
$harddrive_size = 0; |
$harddrive_size = 0; |
205 |
$cpu_count = $vm["VCPUs_max"]; |
$cpu_count = $vm["VCPUs_max"]; |
206 |
|
|
207 |
|
$clean_name = str_replace(" ", "_", $name); |
208 |
|
$clean_name = str_replace(".", "_", $clean_name); |
209 |
|
|
210 |
|
|
211 |
foreach ($vm["VBDs"] as $vbds) { |
foreach ($vm["VBDs"] as $vbds) { |
212 |
$vbd = $xenserver->VBD__get_record($vbds); |
$vbd = $xenserver->VBD__get_record($vbds); |
213 |
if ($vbd["type"] == 'Disk') { |
if ($vbd["type"] == 'Disk') { |
216 |
} |
} |
217 |
} |
} |
218 |
|
|
|
$vps_topbg = 'vps_topyellow.png'; |
|
|
|
|
|
if ($state == "Running") { |
|
|
$vps_topbg = 'vps_topgreen.png'; |
|
|
} else if ($state == "Halted") { |
|
|
$vps_topbg = 'vps_topred.png'; |
|
|
} |
|
|
|
|
|
$network = ""; |
|
|
if ( $vm["power_state"] == "Running" && $vm["guest_metrics"] != "OpaqueRef:NULL" ) { |
|
|
$guest_metrics = $xenserver->VM_guest_metrics__get_record( $vm["guest_metrics"] ); |
|
|
$network = "(IP: " . implode( ",", $guest_metrics["networks"]) . ")"; |
|
|
} else { |
|
|
$guest_metrics = Array() ; |
|
|
} |
|
|
|
|
219 |
|
|
|
$url = ""; |
|
|
$session = ""; |
|
|
foreach($vm["consoles"] as $conref) { |
|
|
$con = $xenserver->console__get_record( $conref ); |
|
|
//var_dump($con); |
|
|
|
|
|
if ($con["protocol"] == "rfb") { |
|
|
$url = urlencode( $con["location"] ); |
|
|
$session = $xenserver->get_id(); |
|
|
} |
|
|
} |
|
220 |
|
|
|
|
|
|
|
|
|
|
|
|
// echo "<a href='#' onclick=\"loadvm('$uuid');\">$name</a><br>\n"; |
|
221 |
?> |
?> |
222 |
<!-- MACHINE --> |
<!-- MACHINE --> |
223 |
<table width='99%' cellpadding='3' cellspacing='0' border='0' class='vps' id='<?php echo $name;?>'> |
<table width='99%' cellpadding='3' cellspacing='0' border='0' class='vps' id='vm_<?php echo $clean_name;?>'> |
224 |
<tr background='gfx/vps_topbg.png'> |
<tr background='gfx/vps_topbg.png' > |
225 |
<td width='10' background='gfx/<?php echo $vps_topbg; ?>' class='small'> </td> |
<td width='10' class='small state'> </td> |
226 |
<td colspan='2' class='small'><b><?php echo $name; ?></b></td> |
<td colspan='2' class='small'><b><?php echo $name; ?></b></td> |
227 |
<td colspan='2' class='small' align='right'> |
<td colspan='2' class='small' align='right'> |
228 |
<?php echo $network;?> |
<span class='network'></span> |
229 |
<?php |
<a href='#' style='display:none;' class='console'> |
230 |
if ($url != "") { |
<img src='gfx/icon-terminal.png' style='vertical-align: middle;'> |
231 |
echo "<a href='#' onclick=\"console('<?php echo $url;?>','<?php echo $session;?>')\"><img src='gfx/icon-terminal.png' style='vertical-align: middle;'></a>"; |
</a> |
|
} |
|
|
?> |
|
232 |
</td> |
</td> |
233 |
</tr> |
</tr> |
234 |
|
|
236 |
<td></td> |
<td></td> |
237 |
|
|
238 |
<td width='150' class='small'> |
<td width='150' class='small'> |
239 |
<?php |
<span class="actionstop" style='display:none'> |
240 |
if ($state == "Running") { |
start | |
241 |
echo "start | "; |
<a href='#' onclick="doAction('shutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >stop</a> | |
242 |
echo "<a href='#' onclick=\"doAction('shutdown','$uuid')\">stop</a> | "; |
<a href='#' onclick="doAction('hardshutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >force shutdown</a> |
243 |
echo "<a href='#' onclick=\"doAction('hardshutdown','$uuid')\">force shutdown</a>"; |
</span> |
244 |
} else { |
|
245 |
echo "<a href='#' onclick=\"doAction('start','$uuid')\">start</a> | "; |
<span class="actionstart"> |
246 |
echo "stop | "; |
<a href='#' onclick="doAction('start','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >start</a> | |
247 |
echo "force shutdown"; |
stop | |
248 |
} |
force shutdown |
249 |
?> |
</span> |
250 |
|
|
251 |
</td> |
</td> |
252 |
|
|