Mercurial > hg > Members > shoshi > webvirt
comparison app/controllers/vncviewer_controller.php @ 1:eb4fee3d9bb8
added StoragePools management functions (storage_controller)
author | Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 27 Jul 2011 00:00:25 +0900 |
parents | 261e66bd5a0c |
children |
comparison
equal
deleted
inserted
replaced
0:261e66bd5a0c | 1:eb4fee3d9bb8 |
---|---|
6 public $name = "Vncviewer"; | 6 public $name = "Vncviewer"; |
7 | 7 |
8 public static $ERROR_TABLE = array( | 8 public static $ERROR_TABLE = array( |
9 0 => "uuid is required to process this action", | 9 0 => "uuid is required to process this action", |
10 1 => "vnc is not supported.", | 10 1 => "vnc is not supported.", |
11 2 => "domain is inactive.", | |
11 ); | 12 ); |
12 | 13 |
13 public function exec() | 14 public function exec() |
14 { | 15 { |
15 if(!isset($this->params['url']['uuid'])){ | 16 if(!isset($this->params['url']['uuid'])){ |
16 $this->redirect(array("action" => "error","?" => array("e" => 0)),200,true); | 17 $this->redirect(array("action" => "error","?" => array("e" => 0)),200,true); |
17 } | 18 } |
18 | 19 |
19 $con = WebVirtUtil::GetConnection(); | 20 $con = WebVirtUtil::GetConnection(); |
20 $dom = libvirt_domain_lookup_by_uuid_string($con,$this->params['url']['uuid']); | 21 $dom = libvirt_domain_lookup_by_uuid_string($con,$this->params['url']['uuid']); |
21 $xml = simplexml_load_string(libvirt_domain_get_xml_desc($dom)); | 22 $info = libvirt_domain_get_info($dom); |
23 if($info["state"] != VIR_DOMAIN_RUNNING){ | |
24 $this->redirect(array("action" => "error","?" => array("e" => 2)),200,true); | |
25 } | |
26 | |
27 $xml = simplexml_load_string(libvirt_domain_get_xml_desc($dom,null)); | |
22 | 28 |
23 $port = -1; | 29 $port = -1; |
24 foreach($xml->devices->graphics as $graphic){ | 30 foreach($xml->devices->graphics as $graphic){ |
25 $attributes = $graphic->attributes(); | 31 $attributes = $graphic->attributes(); |
26 if(strcmp($attributes->type,"vnc") == 0 && strcmp($attributes->listen,"127.0.0.1") != 0){ | 32 if(strcmp($attributes->type,"vnc") == 0 && strcmp($attributes->listen,"127.0.0.1") != 0){ |
39 | 45 |
40 public function error() | 46 public function error() |
41 { | 47 { |
42 if(isset($this->params["url"]["e"])){ | 48 if(isset($this->params["url"]["e"])){ |
43 $e = (int)$this->params["url"]["e"]; | 49 $e = (int)$this->params["url"]["e"]; |
44 trigger_error(self::$ERROR_TABLE[$e]); | 50 $this->set("content",self::$ERROR_TABLE[$e]); |
45 } | 51 } |
46 } | 52 } |
47 } | 53 } |
48 ?> | 54 ?> |