--- misc/xenconsole/index.php 2012/11/30 15:54:54 1884
+++ misc/xenconsole/index.php 2012/11/30 17:56:07 1885
@@ -41,6 +41,11 @@
$(document).ready( function() {
setInterval(refreshData, 60000);
refreshData();
+ $('.console').click( function() {
+ var session = $(this).data('session');
+ var conurl = $(this).data('conurl');
+ console(conurl,session);
+ });
});
function refreshData() {
@@ -48,17 +53,37 @@
$(xml).find('vm').each(function() {
var name = $(this).find('name').text();
var state = $(this).find('state').text();
+ var network = $(this).find('network').text();
+ var state = $(this).find('state').text();
+ var conurl = $(this).find('conurl').text();
+ var session = $(this).find('session').text();
name = name.replace(" ", "_");
name = name.replace(".", "_");
- var id = "#state_" + name;
- var css = $(id).css("background");
+ var id = "#vm_" + name;
+
+ var vm = $(id);
if (state == "Running") {
- $(id).css("background-image", "url('gfx/vps_topgreen.png')");
+ vm.find('.state').css("background-image", "url('gfx/vps_topgreen.png')");
+ vm.find('.network').show();
+ vm.find('.network').text( '(IP: ' + network + ')' );
+ vm.find('.console').show();
+ vm.find('.console').data('conurl', conurl);
+ vm.find('.console').data('session', session);
+ vm.find('.actionstop').show();
+ vm.find('.actionstart').hide();
} else {
- $(id).css("background-image", "url('gfx/vps_topred.png')");
+ if (state == "Halted") {
+ vm.find('.state').css("background-image", "url('gfx/vps_topred.png')");
+ } else {
+ vm.find('.state').css("background-image", "url('gfx/vps_topyellow.png')");
+ }
+ vm.find('.network').hide();
+ vm.find('.console').hide();
+ vm.find('.actionstop').hide();
+ vm.find('.actionstart').show();
}
})
@@ -184,52 +209,19 @@
}
}
- $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() ;
- }
-
- $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();
- }
- }
-
-
-
-// echo "$name
\n";
?>
-
-
- |
+
+
+ |
|
-
- ";
- }
- ?>
+
+
+
+
|
@@ -237,17 +229,17 @@
|
- stop | ";
- echo "force shutdown";
- } else {
- echo "start | ";
- echo "stop | ";
- echo "force shutdown";
- }
- ?>
+
+ start |
+ stop |
+ force shutdown
+
+
+
+ start |
+ stop |
+ force shutdown
+
|