Added Node Summary

This commit is contained in:
Deon George
2011-05-30 19:27:08 +10:00
parent d3b97ae485
commit d29b29fa07
13 changed files with 305 additions and 62 deletions

View File

@@ -79,5 +79,12 @@ abstract class Controller_lnApp_Default extends Controller {
}
}
}
public function after() {
parent::after();
// Generate and check the ETag for this file
$this->response->check_cache(NULL,$this->request);
}
}
?>

View File

@@ -53,37 +53,35 @@ $(document).ready(function () {$("#node_name").change(function () {
$no = ORM::factory('node',$node_name);
$output = View::factory('nodes/detail')
->set('node',$no);
Block::add(array(
'title'=>sprintf('%s %s',_('Detailed Node Information for'),$no->NODE_NAME),
'body'=>$output,
'body'=>View::factory('nodes/detail')->set('node',$no),
));
$output = View::factory('nodes/detail_filesystem')
->set('node',$no);
Block::add(array(
'title'=>_('Protected File System Information'),
'body'=>$output,
'body'=>View::factory('nodes/detail_filesystem')->set('node',$no),
));
$output = View::factory('nodes/detail_volumes')
->set('node',$no);
Block::add(array(
'title'=>_('Sequential Volume Usage Information'),
'body'=>$output,
'body'=>View::factory('nodes/detail_volumes')->set('node',$no),
));
$output = View::factory('nodes/detail_schedule')
->set('node',$no);
Block::add(array(
'title'=>_('Schedule Information'),
'body'=>$output,
'body'=>View::factory('nodes/detail_schedule')->set('node',$no),
));
}
public function action_summary() {
$do = ORM::factory('domain');
foreach ($do->find_all() as $domain)
Block::add(array(
'title'=>_('Node Information by Domain'),
'body'=>View::factory('nodes/summary')->set('do',$domain)
));
}
}
?>

View File

@@ -31,6 +31,14 @@ class Controller_Tree extends Controller_lnApp_Tree {
'attr_href'=>URL::Site('/node'),
));
array_push($data,array(
'id'=>'node_summary',
'name'=>'Node Summary',
'state'=>'none',
'attr_id'=>'1',
'attr_href'=>URL::Site('/node/summary'),
));
array_push($data,array(
'id'=>'activity',
'name'=>'Server Activity Gantt',

View File

@@ -173,7 +173,7 @@ class Database_TSM extends Database {
}
SystemMessage::TSM_Error($stdout,$sql);
return FALSE;
Request::current()->redirect('welcome');
}
if (isset($benchmark))

View File

@@ -25,6 +25,6 @@ class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
'body'=>sprintf(_('The page [%s] you requested was not found?'),Request::detect_uri()),
));
Request::factory()->redirect('/welcome');
Request::factory()->redirect('welcome');
}
}

View File

@@ -0,0 +1,87 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Domain
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_DOMAIN extends ORMTSM {
protected $_table_name = 'DOMAINS';
protected $_primary_key = 'DOMAIN_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'DOMAIN_NAME'=>'ASC',
);
protected $_has_many = array(
'NODE'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
);
// Pools used by a domain.
private $pools = array();
// Work out all the storage pools used by a domain.
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
public function getStoragePools($dtype) {
return isset($this->pools[$dtype]) ? $this->pools[$dtype] : $this->_getpools($dtype);
}
private function _getpools($dtype) {
$this->pools[$dtype] = array();
foreach ($this->NODE->find_all() as $no)
foreach ($no->getStoragePools($dtype) as $ptype => $stgpools)
foreach ($stgpools as $spo)
if (! isset($this->pools[$dtype][$ptype]) OR ! in_array($spo,$this->pools[$dtype][$ptype]))
$this->pools[$dtype][$ptype][] = $spo;
return $this->pools[$dtype];
}
// Return the storage pools used for a domain by backup type
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStoragePoolsType($dtype,$ptype) {
if (! isset($this->pools[$dtype]))
$this->_getpools($dtype);
return isset($this->pools[$dtype][$ptype]) ? $this->pools[$dtype][$ptype] : array();
}
// $dtype is BACKUP or ARCHIVE
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeVols($dtype,$ptype,$spo='') {
$result = array();
foreach ($this->NODE->find_all() as $no)
$result = array_merge($result,$no->getStorageModeVols($dtype,$ptype,$spo));
return $result;
}
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeFiles($dtype,$ptype,$spo='') {
$count = 0;
foreach ($this->NODE->find_all() as $no)
$count += $no->getStorageModeFiles($dtype,$ptype,$spo);
return $count;
}
// $dtype is BACKUP or ARCHIVE
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeData($dtype,$ptype,$spo='') {
$count = 0;
foreach ($this->NODE->find_all() as $no)
$count += $no->getStorageModeData($dtype,$ptype,$spo);
return $count;
}
}
?>

View File

@@ -32,6 +32,7 @@ class Model_FILESPACE extends ORMTSM {
return $this->CAPACITY * ($this->PCT_UTIL/100);
}
// $dtype must be Bkup or Arch
public function storagepools($dtype) {
$pool = array();
@@ -40,10 +41,9 @@ class Model_FILESPACE extends ORMTSM {
->where('TYPE','=',$dtype)
->group_by('STGPOOL_NAME')
->order_by('STGPOOL_NAME')
->find_all() as $oo) {
->find_all() as $oo)
array_push($pool,$oo->STGPOOL);
}
return $pool;
}

View File

@@ -116,24 +116,30 @@ class Model_NODE extends ORMTSM {
}
// Work out all the storage pools used by a node.
// $dtype is BACKUP or ARCHIVE
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
public function getStoragePools($dtype) {
return isset($this->pools[$dtype]) ? $this->pools[$dtype] : $this->_getpools($dtype);
}
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
private function _getpools($dtype) {
$this->pools[$dtype] = array();
foreach ($this->FILESPACE->find_all() as $fso)
foreach ($fso->storagepools($dtype) as $po)
if (! isset($this->pools[$dtype][$po->POOLTYPE]) OR ! in_array($po->STGPOOL_NAME,$this->pools[$dtype][$po->POOLTYPE]))
$this->pools[$dtype][$po->POOLTYPE][] = $po;
if (! isset($this->pools[$dtype][$po->POOLTYPE][$po->STGPOOL_NAME]))
$this->pools[$dtype][$po->POOLTYPE][$po->STGPOOL_NAME] = $po;
return $this->pools[$dtype];
}
public function getAllStoragePoolsType($ptype) {
return array_merge($this->getStoragePoolsType('Bkup',$ptype),$this->getStoragePoolsType('Arch',$ptype));
$result = array();
foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype)
$result = array_merge($result,$this->getStoragePoolsType($btype,$ptype));
return $result;
}
// Return the storage pools used for a backup type
@@ -146,42 +152,73 @@ class Model_NODE extends ORMTSM {
return isset($this->pools[$dtype][$ptype]) ? $this->pools[$dtype][$ptype] : array();
}
// @todo This routine should be cached.
public function getStorageTypeVols($type,$spo='') {
$count = array();
// $dtype is BACKUP or ARCHIVE
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeVols($dtype,$ptype,$spo='') {
$result = array();
foreach ($this->VOLUMEUSAGE->find_all() as $vo)
if ((! $spo OR $vo->STGPOOL_NAME == $spo) AND $vo->STGPOOL->POOLTYPE == $type)
if (! in_array($vo->VOLUME_NAME,$count))
array_push($count,$vo->VOLUME_NAME);
foreach ($this->VOLUMEUSAGE->where('COPY_TYPE','=',$dtype)->find_all() as $vo)
if ((! $spo OR $vo->STGPOOL_NAME == $spo) AND $vo->STGPOOL->POOLTYPE == $ptype)
if (! isset($result[$vo->VOLUME_NAME]))
$result[$vo->VOLUME_NAME] = $vo;
return count($count);
return $result;
}
// @todo This routine should be cached.
public function getStorageTypeFiles($type,$spo='') {
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageTypeVols($ptype,$spo='') {
$result = array();
foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype)
$result = array_merge($result,$this->getStorageModeVols($ctype,$ptype,$spo));
return $result;
}
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeFiles($dtype,$ptype,$spo='') {
$count = 0;
foreach ($this->FILESPACE->find_all() as $fo)
foreach ($fo->OCCUPANCY->find_all() as $oa)
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $type)
foreach ($fo->OCCUPANCY->where('TYPE','=',$dtype)->find_all() as $oa)
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $ptype)
$count += $oa->NUM_FILES;
return $count;
}
// @todo This routine should be cached.
public function getStorageTypeData($type,$spo='') {
public function getStorageTypeFiles($ptype,$spo='') {
$count = 0;
foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype)
$count += $this->getStorageModeFiles($btype,$ptype,$spo);
return $count;
}
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeData($dtype,$ptype,$spo='') {
$count = 0;
foreach ($this->FILESPACE->find_all() as $fo)
foreach ($fo->OCCUPANCY->find_all() as $oa)
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $type)
foreach ($fo->OCCUPANCY->where('TYPE','=',$dtype)->find_all() as $oa)
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $ptype)
$count += $oa->LOGICAL_MB;
return $count;
}
public function getStorageTypeData($ptype,$spo='') {
$count = 0;
foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype)
$count += $this->getStorageModeData($btype,$ptype,$spo);
return $count;
}
// Return the volumes that this node uses
// $dtype is BACKUP or ARCHIVE
public function volumes($dtype) {