60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
/**
|
|
*
|
|
* @package PTA
|
|
* @subpackage File Spaces
|
|
* @category Models
|
|
* @author Deon George
|
|
* @copyright (c) 2010 phpTSMadmin Development Team
|
|
* @license http://phptsmadmin.sf.net/license.html
|
|
*/
|
|
class Model_FILESPACE extends ORMTSM {
|
|
protected $_table_name = 'FILESPACES';
|
|
protected $_primary_key = 'FILESPACE_NAME'; // We need a primary key to detect that the object is loaded.
|
|
protected $_sorting = array(
|
|
'NODE_NAME'=>'ASC',
|
|
'FILESPACE_NAME'=>'ASC',
|
|
);
|
|
|
|
protected $_has_many = array(
|
|
'VOLUMEUSAGE'=>array('foreign_key'=>array('NODE_NAME','FILESPACE_NAME'),'far_key'=>'FILESPACE_NAME'),
|
|
'OCCUPANCY'=>array('foreign_key'=>array('NODE_NAME','FILESPACE_NAME'),'far_key'=>'FILESPACE_NAME'),
|
|
);
|
|
|
|
protected $_display_filters = array(
|
|
'BACKUP_END'=>array(
|
|
array('ORMTSM::date',array(':value','d-M-Y')),
|
|
),
|
|
);
|
|
|
|
public function utilsation() {
|
|
return $this->CAPACITY * ($this->PCT_UTIL/100);
|
|
}
|
|
|
|
// $dtype must be Bkup or Arch
|
|
public function storagepools($dtype) {
|
|
$pool = array();
|
|
|
|
foreach ($this->OCCUPANCY
|
|
->select('STGPOOL_NAME')
|
|
->where('TYPE','=',$dtype)
|
|
->group_by('STGPOOL_NAME')
|
|
->order_by('STGPOOL_NAME')
|
|
->find_all() as $oo)
|
|
|
|
array_push($pool,$oo->STGPOOL);
|
|
|
|
return $pool;
|
|
}
|
|
|
|
public function pool_logical_util($pool,$btype) {
|
|
return $this->OCCUPANCY->where('STGPOOL_NAME','=',$pool)->where('TYPE','=',$btype)->find()->LOGICAL_MB;
|
|
}
|
|
|
|
public function pool_numvols($pool,$ctype) {
|
|
return $this->VOLUMEUSAGE->where('STGPOOL_NAME','=',$pool)->where('COPY_TYPE','=',$ctype)->find_all()->count();
|
|
}
|
|
}
|
|
?>
|