Mercurial > hg > Members > shoshi > webvirt
annotate app/controllers/vncviewer_controller.php @ 4:c3adb28473d6 default tip
modified icon feature
author | Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 16 Aug 2011 18:31:36 +0900 |
parents | eb4fee3d9bb8 |
children |
rev | line source |
---|---|
0 | 1 <?php |
2 | |
3 class VncviewerController extends AppController | |
4 { | |
5 public $uses = null; | |
6 public $name = "Vncviewer"; | |
7 | |
8 public static $ERROR_TABLE = array( | |
9 0 => "uuid is required to process this action", | |
10 1 => "vnc is not supported.", | |
1
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
11 2 => "domain is inactive.", |
0 | 12 ); |
13 | |
14 public function exec() | |
15 { | |
16 if(!isset($this->params['url']['uuid'])){ | |
17 $this->redirect(array("action" => "error","?" => array("e" => 0)),200,true); | |
18 } | |
19 | |
20 $con = WebVirtUtil::GetConnection(); | |
21 $dom = libvirt_domain_lookup_by_uuid_string($con,$this->params['url']['uuid']); | |
1
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
22 $info = libvirt_domain_get_info($dom); |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
23 if($info["state"] != VIR_DOMAIN_RUNNING){ |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
24 $this->redirect(array("action" => "error","?" => array("e" => 2)),200,true); |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
25 } |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
26 |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
27 $xml = simplexml_load_string(libvirt_domain_get_xml_desc($dom,null)); |
0 | 28 |
29 $port = -1; | |
30 foreach($xml->devices->graphics as $graphic){ | |
31 $attributes = $graphic->attributes(); | |
32 if(strcmp($attributes->type,"vnc") == 0 && strcmp($attributes->listen,"127.0.0.1") != 0){ | |
33 $port = (int)$attributes->port; | |
34 } | |
35 } | |
36 | |
37 if($port != -1){ | |
38 $hostname = $_SERVER["SERVER_NAME"]; | |
39 $this->set("hostname",$hostname); | |
40 $this->set("port",$port); | |
41 }else{ | |
42 $this->redirect(array("action" => "error","?" => array("e" => 1)),200,true); | |
43 } | |
44 } | |
45 | |
46 public function error() | |
47 { | |
48 if(isset($this->params["url"]["e"])){ | |
49 $e = (int)$this->params["url"]["e"]; | |
1
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
50 $this->set("content",self::$ERROR_TABLE[$e]); |
0 | 51 } |
52 } | |
53 } | |
54 ?> |