/[projects]/misc/xenconsole/old/old_index.php
ViewVC logotype

Annotation of /misc/xenconsole/old/old_index.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2018 - (hide annotations) (download)
Thu Jul 18 13:00:14 2013 UTC (10 years, 10 months ago) by torben
File size: 2076 byte(s)
first functioning CD selector
1 torben 1876 <?php
2 torben 1959 include("../config.php");
3 torben 1876
4     // http://docs.vmd.citrix.com/XenServer/5.5.0/1.0/en_gb/api/docs/html/browser.html
5    
6     function mb($val) {
7     return round( $val / (1024*1024) );
8     }
9    
10 torben 1959 include('../xenapi.php');
11 torben 1876
12     /* Establish session with Xenserver */
13     $xenserver = new XenApi($url, $login, $password);
14    
15     ?>
16     <html>
17     <body style="font-family: monospace">
18    
19    
20 torben 2018 <script type='text/javascript' src="../jquery/jquery-1.9.1.min.js"></script>
21 torben 1876
22     <script type='text/javascript'>
23     $(document).ready( function() {
24     loadServer();
25     });
26    
27     function doAction(action, uuid) {
28     var key = prompt("Key");
29     if (key == "" || key == null) {
30     return;
31     }
32     document.body.style.cursor = 'wait';
33    
34     var url = "action.php?action=" + action + "&uuid=" + uuid + "&key=" + key;
35     var response = $.get(url, function(data) {
36     alert(data);
37     document.body.style.cursor = 'default'
38     if (data == "OK") {
39     window.location.reload();
40     }
41     });
42     }
43    
44     function console(url, session) {
45     var key = prompt("Key");
46     if (key == "" || key == null) {
47     return;
48     }
49     var url = "console.php?url=" + url + "&session=" + session + "&key=" + key;
50    
51     //window.location = url;
52     $('#mainwindow').load(url);
53     }
54    
55     function loadServer() {
56     $('#mainwindow').load('server.php');
57     }
58    
59     function loadvm(uuid) {
60     $('#mainwindow').load('vm.php?uuid=' + uuid );
61     }
62    
63     </script>
64    
65     <?php
66    
67    
68    
69     echo "<table border=0><tr><td valign='top'>";
70     echo "<a href='#' onclick='loadServer()'>XenServer</a><br><br>";
71     $vms_array = $xenserver->VM__get_all_records();
72     foreach($vms_array as $vm) {
73     if ($vm["is_a_template"] != 0 || $vm["is_control_domain"] != 0) {
74     continue;
75     }
76    
77    
78     $name = $vm["name_label"];
79     $uuid = $vm["uuid"];
80     $state = $vm["power_state"] ;
81    
82     if ($state == "Running") {
83     echo "<span style='background-color:green;'>&nbsp;&nbsp;</span>";
84     } else if ($state == "Halted") {
85     echo "<span style='background-color:red;'>&nbsp;&nbsp;</span>";
86     } else {
87     echo "<span style='background-color:yellow;'>&nbsp;&nbsp;</span>";
88     }
89    
90    
91     echo "<a href='#' onclick=\"loadvm('$uuid');\">$name</a><br>\n";
92     }
93     ?>
94     </td><td>
95    
96     <span id='mainwindow'></span>
97    
98    
99    
100    
101     </td></tr><table>
102    
103     </body>
104     </html>

  ViewVC Help
Powered by ViewVC 1.1.20