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

Annotation of /misc/xenconsole/action.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1958 - (hide annotations) (download)
Tue Mar 26 13:43:07 2013 UTC (11 years, 2 months ago) by torben
File size: 1261 byte(s)
addmenu options for adjusting memory and vcpu count
1 torben 1876 <?php
2     include("config.php");
3     include('xenapi.php');
4    
5     // http://docs.vmd.citrix.com/XenServer/5.5.0/1.0/en_gb/api/docs/html/browser.html
6    
7     /* Establish session with Xenserver */
8     $xenserver = new XenApi($url, $login, $password);
9    
10    
11     if ($_GET["action"] != "" && $_GET["uuid"] != "" ) {
12     if ($_GET["key"] != $password) {
13     die("Invalid key");
14     }
15 torben 1952 $key = $_GET["key"];
16 torben 1876
17     $uuid = $_GET["uuid"];
18     $action = $_GET["action"];
19    
20     $vmref = $xenserver->VM__get_by_uuid($uuid);
21    
22     if ($action == "start") {
23     $xenserver->VM__start($vmref, false, false);
24     }
25     if ($action == "shutdown") {
26     $xenserver->VM__clean_shutdown($vmref);
27     }
28     if ($action == "hardshutdown") {
29     $xenserver->VM__hard_shutdown($vmref);
30 torben 1952 }
31     if ($action == "setMemory") {
32     $val = $_GET["val"];
33     if ($val == "") {
34     echo "val is missing";
35     exit(1);
36     }
37    
38 torben 1958 $cmd = "xe -pw {$password} vm-memory-limits-set static-min={$val}MiB static-max={$val}MiB dynamic-max={$val}MiB dynamic-min={$val}MiB uuid={$uuid}";
39 torben 1952
40     passthru($cmd);
41 torben 1876 }
42 torben 1958 if ($action == "setCPU") {
43     $val = $_GET["val"];
44     if ($val == "") {
45     echo "val is missing";
46     exit(1);
47     }
48    
49     $cmd = "xe -pw {$password} vm-param-set VCPUs-max={$val} uuid={$uuid}";
50    
51     passthru($cmd);
52     }
53 torben 1876
54     echo "OK";
55     } else {
56     echo "Missing action or uuid";
57     }
58     ?>

  ViewVC Help
Powered by ViewVC 1.1.20