Mercurial > hg > Members > shoshi > webvirt
annotate app/controllers/pages_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 |
rev | line source |
---|---|
0 | 1 <?php |
2 | |
3 class PagesController extends AppController | |
4 { | |
5 public $name = "Pages"; | |
6 public $uses = null; | |
7 public $autoRender = true; | |
8 | |
9 public function display() | |
10 { | |
11 $con = WebVirtUtil::GetConnection(); | |
12 if($con == false){ | |
13 trigger_error(libvirt_get_last_error($con)); | |
14 die(); | |
15 } | |
16 | |
17 $this->set("title_for_laytout",WebVirtUtil::$wvirt_config["APP_NAME"]." - ".WebVirtUtil::$wvirt_config["APP_VERSION"]); | |
18 | |
1
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
19 $hostname = libvirt_connect_get_hostname($con); |
0 | 20 $this->set("hostname",$hostname); |
21 $nodeinfo = libvirt_node_get_info($con); | |
22 $this->set("nodeinfo",$nodeinfo); | |
23 $this->set("actions",WebVirtUtil::$node_actions); | |
24 | |
25 $domains = libvirt_list_domains($con); | |
1
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
26 $domlist = array(); |
0 | 27 foreach($domains as $dom){ |
1
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
28 $res = libvirt_domain_lookup_by_name($con,$dom); |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
29 $name = libvirt_domain_get_name($res); |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
30 $info = libvirt_domain_get_info($res); |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
31 $status = "NO STATE"; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
32 |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
33 switch($info["state"]){ |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
34 case VIR_DOMAIN_NOSTATE: |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
35 $status = "NO STATE"; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
36 break; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
37 case VIR_DOMAIN_RUNNING: |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
38 $status = "RUNNING"; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
39 break; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
40 case VIR_DOMAIN_BLOCKED: |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
41 $status = "BLOCKED"; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
42 break; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
43 case VIR_DOMAIN_PAUSED: |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
44 $status = "PAUSED"; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
45 break; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
46 case VIR_DOMAIN_SHUTDOWN: |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
47 $status = "SHUTDOWN"; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
48 break; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
49 case VIR_DOMAIN_SHUTOFF: |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
50 $status = "SHUTOFF"; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
51 break; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
52 case VIR_DOMAIN_CRASHED: |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
53 $status = "CRASHED"; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
54 break; |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
55 } |
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
56 |
0 | 57 $actions = array(); |
1
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
58 array_push($domlist,array("name" => $name, |
0 | 59 "memory" => $info["memory"], |
60 "nrVirtCpu" => $info["nrVirtCpu"], | |
1
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
61 "status" => $status, |
0 | 62 "actions" => WebVirtUtil::$domain_actions, |
1
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
63 "uuid" => libvirt_domain_get_uuid_string($res), |
0 | 64 )); |
65 } | |
66 | |
1
eb4fee3d9bb8
added StoragePools management functions (storage_controller)
Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
67 $this->set("domains",$domlist); |
0 | 68 } |
69 } | |
70 | |
71 ?> |