88 lines
2.5 KiB
PHP
88 lines
2.5 KiB
PHP
<?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;
|
|
}
|
|
}
|
|
?>
|