This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/application/classes/model/domain.php
2012-10-15 14:13:06 +11:00

112 lines
3.2 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(
'MGMTCLASS'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
'NODE'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
'SCHEDULE_CLIENT'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME')
);
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')
),
),
);
// 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;
}
// $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;
}
}
?>