Mercurial > hg > Members > shoshi > webvirt
view 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 |
line wrap: on
line source
<?php class PagesController extends AppController { public $name = "Pages"; public $uses = null; public $autoRender = true; public function display() { $con = WebVirtUtil::GetConnection(); if($con == false){ trigger_error(libvirt_get_last_error($con)); die(); } $this->set("title_for_laytout",WebVirtUtil::$wvirt_config["APP_NAME"]." - ".WebVirtUtil::$wvirt_config["APP_VERSION"]); $hostname = libvirt_connect_get_hostname($con); $this->set("hostname",$hostname); $nodeinfo = libvirt_node_get_info($con); $this->set("nodeinfo",$nodeinfo); $this->set("actions",WebVirtUtil::$node_actions); $domains = libvirt_list_domains($con); $domlist = array(); foreach($domains as $dom){ $res = libvirt_domain_lookup_by_name($con,$dom); $name = libvirt_domain_get_name($res); $info = libvirt_domain_get_info($res); $status = "NO STATE"; switch($info["state"]){ case VIR_DOMAIN_NOSTATE: $status = "NO STATE"; break; case VIR_DOMAIN_RUNNING: $status = "RUNNING"; break; case VIR_DOMAIN_BLOCKED: $status = "BLOCKED"; break; case VIR_DOMAIN_PAUSED: $status = "PAUSED"; break; case VIR_DOMAIN_SHUTDOWN: $status = "SHUTDOWN"; break; case VIR_DOMAIN_SHUTOFF: $status = "SHUTOFF"; break; case VIR_DOMAIN_CRASHED: $status = "CRASHED"; break; } $actions = array(); array_push($domlist,array("name" => $name, "memory" => $info["memory"], "nrVirtCpu" => $info["nrVirtCpu"], "status" => $status, "actions" => WebVirtUtil::$domain_actions, "uuid" => libvirt_domain_get_uuid_string($res), )); } $this->set("domains",$domlist); } } ?>