2011-05-30 09:27:08 +00:00
|
|
|
<?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
|
|
|
|
*/
|
2012-11-26 05:57:18 +00:00
|
|
|
class Model_DOMAIN extends TSM_ORM {
|
2011-05-30 09:27:08 +00:00
|
|
|
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(
|
2011-05-31 14:51:15 +00:00
|
|
|
'MGMTCLASS'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
|
2011-05-30 09:27:08 +00:00
|
|
|
'NODE'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
|
2011-05-31 14:51:15 +00:00
|
|
|
'SCHEDULE_CLIENT'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME')
|
2011-05-30 09:27:08 +00:00
|
|
|
);
|
|
|
|
|
2011-08-31 21:36:33 +00:00
|
|
|
protected $_tsm = array(
|
|
|
|
'db2'=>array(
|
|
|
|
'_has_many'=>array(
|
|
|
|
'MGMTCLASS'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
|
|
|
|
'NODE'=>array('foreign_key'=>'DOMAINNAME','far_key'=>'DOMAIN_NAME'),
|
|
|
|
'SCHEDULE_CLIENT'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME')
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2011-05-30 09:27:08 +00:00
|
|
|
// 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;
|
|
|
|
}
|
2011-05-31 14:51:15 +00:00
|
|
|
|
|
|
|
// $dtype is BACKUP or ARCHIVE
|
|
|
|
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
|
|
|
|
public function getStorageModeNodes($dtype,$ptype,$spo='') {
|
|
|
|
$result = array();
|
|
|
|
|
|
|
|
foreach ($this->NODE->find_all() as $no)
|
|
|
|
if ($no->getStorageModeData($dtype,$ptype,$spo))
|
|
|
|
array_push($result,$no);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
2011-05-30 09:27:08 +00:00
|
|
|
}
|
|
|
|
?>
|