Added Node Summary
This commit is contained in:
87
application/classes/model/domain.php
Normal file
87
application/classes/model/domain.php
Normal 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;
|
||||
}
|
||||
}
|
||||
?>
|
@@ -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;
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user