/[projects]/misc/xenconsole/index.php
ViewVC logotype

Diff of /misc/xenconsole/index.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

misc/xenconsole/webadmin.php revision 1878 by torben, Fri Nov 30 08:44:57 2012 UTC misc/xenconsole/index.php revision 1887 by torben, Sat Dec 1 10:59:57 2012 UTC
# Line 39  $vms_array = $xenserver->VM__get_all_rec Line 39  $vms_array = $xenserver->VM__get_all_rec
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    
# Line 74  function console(url, session) { Line 128  function console(url, session) {
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    
# Line 122  body { Line 170  body {
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>
# Line 156  foreach($vms_array as $vm) { Line 204  foreach($vms_array as $vm) {
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') {
# Line 164  foreach($vms_array as $vm) { Line 216  foreach($vms_array as $vm) {
216                  }                  }
217          }          }
218    
         $vps_topbg = 'vps_topyellow.png';  
219    
220          if ($state == "Running") {          
                 $vps_topbg = 'vps_topgreen.png';  
         } else if ($state == "Halted") {  
                 $vps_topbg = 'vps_topred.png';  
         }  
   
         $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 "<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'>          <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'>&nbsp;</td>                          <td width='10' class='small state'>&nbsp;</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                                  (IP: 192.168.10.45, 172.10.0.34)                                  <span class='network'></span>
229                                  <a href="#" onclick="console('<?php echo $url;?>','<?php echo $session;?>')"><img src='gfx/icon-terminal.png' style='vertical-align: middle;'></a>                                  <a href='#' style='display:none;' class='console'>
230                                            <img src='gfx/icon-terminal.png' style='vertical-align: middle;'>
231                                    </a>
232                          </td>                          </td>
233                  </tr>                  </tr>
234    
235                  <tr bgcolor='#eee'>                  <tr bgcolor='#eee'>
236                  <td></td>                  <td></td>
237    
238                          <td width='150' class='small'>start stop force</td>                  <td width='150' class='small'>
239                            <span class="actionstop" style='display:none'>
240                                    start |
241                                    <a href='#' onclick="doAction('shutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >stop</a> |
242                                    <a href='#' onclick="doAction('hardshutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >force shutdown</a>
243                            </span>
244                            
245                            <span class="actionstart">                      
246                                    <a href='#' onclick="doAction('start','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >start</a> |
247                                    stop |
248                                    force shutdown
249                            </span>
250    
251                    </td>
252    
253                  <td width='100' align='right' class='small'>                  <td width='100' align='right' class='small'>
254                          <img src='gfx/icon-cpu.png' style='vertical-align: middle;'>                          <img src='gfx/icon-cpu.png' style='vertical-align: middle;'>

Legend:
Removed from v.1878  
changed lines
  Added in v.1887

  ViewVC Help
Powered by ViewVC 1.1.20