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/NODE.php

831 lines
24 KiB
PHP
Raw Normal View History

2011-04-05 23:12:31 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Nodes
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_NODE extends ORM_TSM {
2011-04-05 23:12:31 +00:00
protected $_table_name = 'NODES';
protected $_primary_key = 'NODE_NAME';
protected $_sorting = array(
'NODE_NAME'=>'ASC',
2011-04-07 05:03:05 +00:00
);
2011-04-05 23:12:31 +00:00
2011-05-31 14:51:15 +00:00
protected $_has_one = array(
'DOMAIN'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
);
protected $_has_many = array(
2012-12-07 05:12:58 +00:00
'ACTLOG'=>array('foreign_key'=>'NODENAME','far_key'=>'NODE_NAME'),
'FILESPACE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
'VOLUMEUSAGE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
'ASSOCIATION'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
'MGMTCLASS'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
'CLIENTOPT'=>array('foreign_key'=>'OPTIONSET_NAME','far_key'=>'OPTION_SET'),
'SUMMARY'=>array('foreign_key'=>'ENTITY','far_key'=>'NODE_NAME'),
'EVENT'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
2011-08-31 21:36:33 +00:00
'OCC'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
);
protected $_tsm = array(
'db2'=>array(
'_primary_key'=>'NODENAME',
'_sorting'=>array(
'NODENAME'=>'ASC',
),
'_has_one'=>array(
'DOMAIN'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAINNAME'),
),
'_has_many'=>array(
'FILESPACE'=>array('foreign_key'=>'NODEID','far_key'=>'NODEID'),
'VOLUMEUSAGE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODENAME'),
'ASSOCIATION'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODENAME'),
'MGMTCLASS'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
'CLIENTOPT'=>array('foreign_key'=>'OPTIONSET_NAME','far_key'=>'OPTIONSET'),
'SUMMARY'=>array('foreign_key'=>'ENTITY','far_key'=>'NODENAME'),
'EVENT'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODENAME'),
'OCC'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODENAME'),
),
'translate'=>array(
'NODE_NAME'=>'NODENAME',
'CLIENT_VERSION'=>'CLNTVERSION',
'CLIENT_RELEASE'=>'CLNTRELEASE',
'CLIENT_LEVEL'=>'CLNTLEVEL',
'CLIENT_SUBLEVEL'=>'CLNTSUBLEVEL',
'PLATFORM_NAME'=>'OSNAME',
'CLIENT_OS_LEVEL'=>'CLNTOSLEVEL',
'LASTACC_TIME'=>'LACDATE',
'REG_TIME'=>'REGDATE',
'PWSET_TIME'=>'PWSETDATE',
'LASTSESS_SENT'=>'SESSSENT',
'LASTSESS_RECVD'=>'SESSRECVD',
'LASTSESS_DURATION'=>'SESSDURATION',
'LASTSESS_IDLEWAIT'=>'SESSIDLEWAIT',
'LASTSESS_COMMWAIT'=>'SESSCOMMWAIT',
'LASTSESS_MEDIAWAIT'=>'SESSMEDIAWAIT',
'TCP_ADDRESS'=>NULL,
'EMAIL_ADDRESS'=>NULL,
'REG_ADMIN'=>'REGISTRAR',
'PASSEXP'=>NULL,
'INVALID_PW_COUNT'=>'INVPWCOUNT',
'LOCKED'=>'LOCKSTATE',
'DOMAIN_NAME'=>'DOMAINNAME',
'OPTION_SET'=>'OPTIONSET',
'COLLOCGROUP_NAME'=>NULL,
'COMPRESSION'=>'COMPRESS',
'ARCHDELETE'=>'ARCHDEL',
'BACKDELETE'=>'BACKDEL',
'KEEP_MP'=>NULL,
'MAX_MP_ALLOWED'=>'MAXNUMMP',
),
),
2011-04-05 23:12:31 +00:00
);
protected $_display_filters = array(
'REG_TIME'=>array(
array('ORM_TSM::date',array(':value','d-M-Y')),
),
'PWSET_TIME'=>array(
array('ORM_TSM::date',array(':value','d-M-Y')),
),
'LASTACC_TIME'=>array(
array('ORM_TSM::date',array(':value','d-M-Y')),
),
'LASTSESS_SENT'=>array(
array('number_format',array(':value',0)),
),
'LASTSESS_RECVD'=>array(
array('number_format',array(':value',0)),
),
'LASTSESS_DURATION'=>array(
array('number_format',array(':value',2)),
),
'LASTSESS_IDLEWAIT'=>array(
array('number_format',array(':value',2)),
),
'LASTSESS_COMMWAIT'=>array(
array('number_format',array(':value',2)),
),
'LASTSESS_MEDIAWAIT'=>array(
array('number_format',array(':value',2)),
),
2011-04-05 23:12:31 +00:00
);
2012-12-12 04:00:03 +00:00
/**
* Get all the ACTIVITIY LOG for this NODE
*/
private function _actlog() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
2012-12-12 04:19:17 +00:00
// We cant load all records here, like we do with the others, there is too much data!
$result = $this->ACTLOG->find_all();
2012-12-12 04:00:03 +00:00
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
2012-12-07 06:06:57 +00:00
/**
* Get all the ACTIVITY SUMMARY for this NODE
*/
private function _actsum() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
// In the interest of performance, we load all the records and get PHP to process it.
// Our ORM caching we reduce the hit on TSM.
2012-12-11 11:56:33 +00:00
foreach (ORM::factory('ACTSUM')->find_all() as $o)
2012-12-07 06:06:57 +00:00
if ($o->ENTITY == $this->NODE_NAME)
array_push($result,$o);
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Get all the FILESPACES for this NODE
*/
private function _filespaces() {
$result = array();
2011-04-07 05:03:05 +00:00
// In the interest of performance, we load all the records and get PHP to process it.
// Our ORM caching we reduce the hit on TSM.
foreach (ORM::factory('FILESPACE')->find_all() as $o)
if ($o->NODE_NAME == $this->NODE_NAME)
array_push($result,$o);
return $result;
}
/**
* Get all the OCCUPANCY for this NODE
*/
private function _occupancy() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
// In the interest of performance, we load all the records and get PHP to process it.
// Our ORM caching we reduce the hit on TSM.
foreach (ORM::factory('OCC')->find_all() as $o)
if ($o->NODE_NAME == $this->NODE_NAME)
array_push($result,$o);
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Get all the VOLUMES for this NODE
*/
private function _volumeusage() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
// In the interest of performance, we load all the records and get PHP to process it.
// Our ORM caching we reduce the hit on TSM.
foreach (ORM::factory('VOLUMEUSAGE')->find_all() as $o)
if ($o->NODE_NAME == $this->NODE_NAME)
array_push($result,$o);
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the version of the TSM client
*/
public function version() {
2011-05-31 14:51:15 +00:00
if ($this->CLIENT_VERSION)
return sprintf('%s.%s.%s.%s',$this->CLIENT_VERSION,$this->CLIENT_RELEASE,$this->CLIENT_LEVEL,$this->CLIENT_SUBLEVEL);
else
return '';
}
/**
* Return the OS version for the TSM client
*/
2011-05-31 14:51:15 +00:00
public function platform() {
return sprintf('%s %s',$this->PLATFORM_NAME,$this->CLIENT_OS_LEVEL ? '('.$this->CLIENT_OS_LEVEL.')' : '');
2011-04-05 23:12:31 +00:00
}
// @todo This needs to return the global configuration.
public function passexp() {
if ($this->PASSEXP)
return 'TBA';
else
return _('No Set');
}
// @todo This needs to be validated as a correct calculation
2011-04-05 23:12:31 +00:00
public function lasttransferpercent() {
$x = 100-($this->LASTSESS_IDLEWAIT+$this->LASTSESS_COMMWAIT+$this->LASTSESS_MEDIAWAIT);
return $x < 0 ? 0 : $x;
2011-04-05 23:12:31 +00:00
}
// @todo This needs to be validated as a correct calculation
2011-04-05 23:12:31 +00:00
public function lasttransfertime() {
2011-04-08 05:34:04 +00:00
if ($this->LASTSESS_DURATION)
return $this->LASTSESS_DURATION*($this->lasttransferpercent()/100);
else
return 0;
2011-04-05 23:12:31 +00:00
}
// @todo This needs to be validated as a correct calculation
2011-04-05 23:12:31 +00:00
public function lastsendperformance() {
if ($this->lasttransfertime())
2011-04-07 05:03:05 +00:00
return $this->LASTSESS_SENT/$this->lasttransfertime()/1024/1024;
2011-04-05 23:12:31 +00:00
else
2011-04-08 05:34:04 +00:00
return 0;
2011-04-05 23:12:31 +00:00
}
// @todo This needs to be validated as a correct calculation
2011-04-05 23:12:31 +00:00
public function lastreceiveperformance() {
if ($this->lasttransfertime())
2011-04-07 05:03:05 +00:00
return $this->LASTSESS_RECVD/$this->lasttransfertime()/1024/1024;
2011-04-05 23:12:31 +00:00
else
2011-04-08 05:34:04 +00:00
return 0;
2011-04-05 23:12:31 +00:00
}
/**
* The last sent aggregate performance
*/
2011-04-05 23:12:31 +00:00
public function lastsendaggperformance() {
2011-04-08 05:34:04 +00:00
if ((real)$this->LASTSESS_DURATION)
return $this->LASTSESS_SENT/$this->LASTSESS_DURATION/1024/1024;
else
return 0;
2011-04-05 23:12:31 +00:00
}
/**
* The last receive aggregate performance
*/
2011-04-05 23:12:31 +00:00
public function lastreceiveaggperformance() {
2011-04-08 05:34:04 +00:00
if ((real)$this->LASTSESS_DURATION)
return $this->LASTSESS_RECVD/$this->LASTSESS_DURATION/1024/1024;
else
return 0;
2011-04-05 23:12:31 +00:00
}
// @todo This should return the system setting (cloptset), if the node setting is not configured.
public function txngroupmax() {
return $this->TXNGROUPMAX;
2011-04-05 23:12:31 +00:00
}
// Test to see if a node has any data of type
// @param $type is BACKUP/ARCHIVE/SPACE MANAGED
public function hasData($type) {
2012-12-06 05:19:30 +00:00
return $this->vols_byctype($type) ? TRUE : FALSE;
2011-04-07 05:03:05 +00:00
}
2012-12-07 05:12:58 +00:00
public function activity() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
2012-12-12 04:00:03 +00:00
$result = $this->ACTLOG->ExcludeBA()->find_all();
2012-12-07 05:12:58 +00:00
// @todo Cache time should be configurble
2012-12-07 06:06:57 +00:00
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
2012-12-12 04:00:03 +00:00
/**
* Get all the ACTIVITY LOG information for a SESSION
* @param $sid Session ID
* @param $start Session Start Time (to illiminate any duplication session data)
*/
public function actlog_session($sid,$start) {
$result = array();
foreach ($this->_actlog() as $alo)
if ($alo->SESSION == $sid AND $alo->start() >= $start)
array_push($result,$alo);
return $result;
}
2012-12-07 06:06:57 +00:00
/**
* Return the ACTIVITY of this NODE
* @param $type is Bkup/Arch/SpMg
*/
public function act_bybtype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s',__METHOD__,$this->NODE_NAME,$type);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
foreach ($this->_actsum() as $aso)
if ($aso->ACTIVITY == $this->datatypemap($type))
array_push($result,$aso);
2012-12-11 11:56:33 +00:00
Sort::MASort($result,'SCHEDULE_NAME,START_TIME');
2012-12-07 06:06:57 +00:00
// @todo Cache time should be configurble
2012-12-07 05:12:58 +00:00
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
2012-12-11 11:56:33 +00:00
/**
2012-12-12 04:00:03 +00:00
* Return the Schedules used for all activites of type
2012-12-11 11:56:33 +00:00
* @param $type is Bkup/Arch/SpMg
*/
public function act_schedules($type) {
$result = array();
foreach ($this->act_bybtype($type) as $ao)
if (! in_array($ao->SCHEDULE_NAME,$result))
array_push($result,$ao->SCHEDULE_NAME);
return $result;
}
/**
* Return the BACKUP TYPES used by this NODE
* ie: Bkup/Arch/SpMg
*/
public function btypes() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
2011-04-07 05:03:05 +00:00
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
2012-12-07 05:12:58 +00:00
$result = array();
2011-04-07 05:03:05 +00:00
foreach ($this->_occupancy() as $oo)
if (! in_array($oo->TYPE,$result))
array_push($result,$oo->TYPE);
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
2011-05-31 14:51:15 +00:00
}
/**
* Return the total of a field for this NODE has by backup TYPE
* @param $field the field to check
* @param $data the value of that field to match
* @param $metric is metric of the storpage pool, eg: NUM_FILES
*/
private function _data_int($field,$data,$metric) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$field,$data,$metric);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = 0;
foreach ($this->_occupancy() as $oo)
if ($oo->{$field} == $data)
$result += $oo->{$metric};
2011-05-30 09:27:08 +00:00
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
2011-05-30 09:27:08 +00:00
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
2011-05-30 09:27:08 +00:00
return $result;
2011-05-29 01:41:36 +00:00
}
/**
* Return the data that this NODE has in a STORAGE POOL by backup TYPE
* @param $pool is STORAGE POOL NAME
* @param $metric is metric of the storpage pool, eg: NUM_FILES
* @param $type is Bkup/Arch/SpMg
*/
private function _data_bypoolbybtype($pool,$metric,$type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$pool,$metric,$type);
$c = Kohana::$config->load('config')->cache;
2011-04-07 05:03:05 +00:00
if (is_null($result = Cache::instance($c)->get($k))) {
$result = 0;
foreach ($this->_occupancy() as $oo)
if ($oo->STGPOOL_NAME == $pool AND $oo->TYPE == $type)
$result += $oo->{$metric};
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
2011-04-07 05:03:05 +00:00
}
/**
* Return the FILES that this NODE has by backup TYPE
* @param $type is Bkup/Arch/SpMg
*/
public function file_bybtype($type) {
Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__));
return $this->_data_int('TYPE',$type,'NUM_FILES');
}
/**
* Return the FILES that this NODE has in a STORAGE POOL
* @param $pool is STORAGE POOL NAME
*/
public function file_bypool($pool) {
Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__));
return $this->_data_int('STGPOOL_NAME',$pool,'NUM_FILES');
}
public function file_bypoolbybtype($pool,$type) {
Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__));
return $this->_data_bypoolbybtype($pool,'NUM_FILES',$type);
}
2011-05-30 09:27:08 +00:00
/**
* Return the FILES that this NODE has in a STORAGE POOL TYPE
* @param $type is ACTIVEDATA/PRIMARY/COPY
*/
public function file_byptype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$result = 0;
foreach ($this->stgpools_byptype($type) as $spo)
$result += $this->file_bypool($spo);
2011-05-30 09:27:08 +00:00
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
2011-05-30 09:27:08 +00:00
return $result;
}
2012-12-13 04:46:25 +00:00
public function file_active() {
return $this->file_byptype('ACTIVE') == 0 ? 'Unknown' : (int)$this->file_byptype('ACTIVE')/(int)$this->file_byptype('PRIMARY');
}
public function file_mediaprotection() {
return (int)$this->file_byptype('COPY')/(int)$this->file_byptype('PRIMARY');
}
public function fs() {
return $this->_filespaces();
}
2012-12-13 04:46:25 +00:00
public function fs_capacity() {
$result = 0;
foreach ($this->_filespaces() as $fso)
$result += $fso->CAPACITY;
return (int)$result;
}
public function fs_data() {
$result = 0;
foreach ($this->_filespaces() as $fso)
$result += $fso->utilsation();
return (int)$result;
}
public function fs_logical() {
$result = 0;
foreach ($this->_filespaces() as $fso)
$result += $fso->data_logical();
return (int)$result;
}
public function fs_utilisation() {
return round($this->fs_data()/$this->fs_capacity()*100,2);
}
2012-12-12 10:39:00 +00:00
/**
* Return a Graph of the BA Client Sessions
* @param $type is Bkup/Arch/SpMg
* @see [node/ajaxjson_basessions]
*/
public function graph_basessions($type='Bkup',$schedule='') {
$chart = 'ComboChart';
$google = GoogleChart::factory($chart)
->div(sprintf('bas_%s_%s',$type,$schedule))
->dataurl(URL::site(sprintf('node/ajaxjson_basessions/%s?c=%s&s=%s&t=%s',$this->NODE_NAME,$chart,$schedule,$type)));
return (string)$google;
}
2012-12-11 11:56:33 +00:00
/**
* Return a Graph of the Schedule Backup Activity
* @param $type is Bkup/Arch/SpMg
2012-12-12 10:39:00 +00:00
* @see [node/ajaxjson_schedules]
2012-12-11 11:56:33 +00:00
*/
2012-12-12 10:39:00 +00:00
public function graph_schedules($type='Bkup',$schedule='') {
2012-12-11 11:56:33 +00:00
$chart = 'ComboChart';
$google = GoogleChart::factory($chart)
2012-12-12 10:39:00 +00:00
->div(sprintf('sch_%s_%s',$type,$schedule))
->dataurl(URL::site(sprintf('node/ajaxjson_schedules/%s?c=%s&s=%s&t=%s',$this->NODE_NAME,$chart,$schedule,$type)));
2012-12-11 11:56:33 +00:00
return (string)$google;
}
/**
* Return the LOGICAL_MB that this NODE has by backup TYPE
* @param $type is Bkup/Arch/SpMg
*/
public function logmb_bybtype($type) {
Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__));
return $this->_data_int('TYPE',$type,'LOGICAL_MB');
}
/**
* Return the LOGICAL_MB that this NODE has in a STORAGE POOL
* @param $pool is STORAGE POOL NAME
*/
public function logmb_bypool($pool) {
Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__));
return $this->_data_int('STGPOOL_NAME',$pool,'LOGICAL_MB');
}
public function logmb_bypoolbybtype($pool,$type) {
Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__));
return $this->_data_bypoolbybtype($pool,'LOGICAL_MB',$type);
}
2011-05-29 01:41:36 +00:00
/**
* Return the FILES that this NODE has in a STORAGE POOL TYPE
* @param $type is ACTIVEDATA/PRIMARY/COPY
*/
public function logmb_byptype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$result = 0;
foreach ($this->stgpools_byptype($type) as $spo)
$result += $this->logmb_bypool($spo);
2011-05-29 01:41:36 +00:00
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
2011-05-30 09:27:08 +00:00
return $result;
2011-05-29 01:41:36 +00:00
}
public function occupancy() {
return $this->_occupancy();
}
/**
* Return the STORAGE POOLS this NODE has data in
*/
public function stgpools() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$x = $result = array();
2012-12-06 05:19:30 +00:00
foreach ($this->_occupancy() as $oo)
if (! in_array($oo->STGPOOL_NAME,$x)) {
array_push($result,$oo->STGPOOL);
array_push($x,$oo->STGPOOL_NAME);
}
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the STORAGE POOL TYPES used by this NODE
* ie: ACTIVE/PRIMARY/COPY
* @todo This should be sorted by PRIMARY/ACTIVE/COPY
*/
public function stgpooltypes() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
2011-05-30 09:27:08 +00:00
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
2011-05-30 09:27:08 +00:00
foreach ($this->stgpools() as $spo)
if (! in_array($spo->POOLTYPE,$result))
array_push($result,$spo->POOLTYPE);
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
2011-05-30 09:27:08 +00:00
}
/**
* Return the STORAGE POOLS that this NODE uses by BACKUP TYPE
2012-12-06 05:19:30 +00:00
* @param $type is Bkup/Arch/SpMg
*/
public function stgpools_bybtype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s',__METHOD__,$this->NODE_NAME,$type);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$x = $result = array();
foreach ($this->_occupancy() as $oo)
if ($oo->TYPE == $type AND ! in_array($oo->STGPOOL_NAME,$x)) {
array_push($result,$oo->STGPOOL);
array_push($x,$oo->STGPOOL_NAME);
}
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the STORAGE POOLS that this NODE uses by BACKUP TYPE
* @param $type is ACTIVEDATA/PRIMARY/COPY
*/
public function stgpools_byptype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s',__METHOD__,$this->NODE_NAME,$type);
$c = Kohana::$config->load('config')->cache;
2011-05-30 09:27:08 +00:00
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
foreach ($this->stgpools() as $spo)
if ($spo->POOLTYPE == $type)
array_push($result,$spo);
2011-05-30 09:27:08 +00:00
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
2011-05-30 09:27:08 +00:00
}
public function vols_bybtype($type) {
return $this->vols_byctype($this->datatypemap($type));
}
private function _vols_metric($metric,$data) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$metric,$data);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$x = $result = array();
foreach ($this->_volumeusage() as $vuo)
if ($vuo->{$metric} == $data AND ! in_array($vuo->VOLUME_NAME,$x)) {
array_push($result,$vuo->VOLUME);
array_push($x,$vuo->VOLUME_NAME);
}
Sort::MASort($result,'VOLUME_NAME');
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the VOLUMES that this NODE uses by BACKUP TYPE
* @param $type is BACKUP/ARCHIVE/SPACE MANAGED
*/
public function vols_byctype($type) {
return $this->_vols_metric('COPY_TYPE',$type);
}
/**
* Return the VOLUMES that this NODE uses
* @param $pool is STORAGE POOL NAME
*/
public function vols_bypool($pool) {
return $this->_vols_metric('STGPOOL_NAME',$pool);
}
/**
* Return the VOLUMES that this NODE has in a STORAGE POOL TYPE
* @param $type is ACTIVEDATA/PRIMARY/COPY
*/
public function vols_byptype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$result = array();
foreach ($this->stgpools_byptype($type) as $spo)
$result = array_merge($result,$this->vols_bypool($spo));
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the VOLUMES that this NODE uses by POOL and BACKUP TYPE
* @param $pool is STORAGE POOL NAME
* @param $type is Bkup/Arch/SpMg
*/
public function vols_bypoolbybtype($pool,$type) {
return $this->vols_bypoolbyctype($pool,$this->datatypemap($type));
}
2011-04-05 23:12:31 +00:00
/**
* Return the VOLUMES that this NODE uses by POOL and BACKUP TYPE
* @param $pool is STORAGE POOL NAME
* @param $type is BACKUP/ARCHIVE/SPACE MANAGED
2011-04-05 23:12:31 +00:00
*/
2012-12-06 05:19:30 +00:00
public function vols_bypoolbyctype($pool,$type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$pool,$type);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
foreach ($this->_volumeusage() as $vuo)
if ($vuo->STGPOOL_NAME == $pool AND $vuo->COPY_TYPE == $type AND ! in_array($vuo->VOLUME_NAME,$result))
array_push($result,$vuo->VOLUME);
Sort::MASort($result,'VOLUME_NAME');
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
2011-04-05 23:12:31 +00:00
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
2011-04-05 23:12:31 +00:00
}
public function volumeusage() {
return $this->_volumeusage();
}
2011-04-05 23:12:31 +00:00
}
?>