Fixes for KH 3.3 - to do with case file names

This commit is contained in:
Deon George
2012-11-27 12:26:56 +11:00
parent fc2ffd7bad
commit ea1346447f
88 changed files with 21 additions and 20 deletions

View File

@@ -0,0 +1,19 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Activity Log
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_ACTLOG extends TSM_ORM {
protected $_table_name = 'ACTLOG';
protected $_primary_key = 'DATE_TIME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'DATE_TIME'=>'ASC',
);
}
?>

View File

@@ -0,0 +1,17 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* TSM Administrator Model
*
* @package lnApp
* @subpackage Auth
* @category Models
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_ADMIN extends Model_Auth_UserDefault {
protected $_table_name = 'ADMINS';
protected $_primary_key = 'ADMIN_NAME';
}
?>

View File

@@ -0,0 +1,24 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Client Schedule Associations
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_ASSOCIATION extends TSM_ORM {
protected $_table_name = 'ASSOCIATIONS';
protected $_primary_key = 'DOMAIN_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'SCHEDULE_NAME'=>'ASC',
'NODE_NAME'=>'ASC',
);
protected $_has_one = array(
'SCHEDULE_CLIENT'=>array('foreign_key'=>'SCHEDULE_NAME','far_key'=>'SCHEDULE_NAME'),
);
}
?>

View File

@@ -0,0 +1,24 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* @package PTA
* @subpackage Auth
* @category Models
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Auth_UserDefault extends Model_Auth_User {
protected $_table_names_plural = FALSE;
protected $_disable_wild_select = TRUE;
protected $_disable_join_table_name = TRUE;
protected $_disable_limit = TRUE;
protected function _initialize() {
// Set out DB connection configuration.
$this->_db_group = Kohana::$config->load('config')->client_type;
parent::_initialize();
}
}
?>

View File

@@ -0,0 +1,21 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Volume
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_CLIENTOPT extends TSM_ORM {
protected $_table_name = 'CLIENTOPTS';
protected $_primary_key = 'OPTIONSET_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'OPTIONSET_NAME'=>'ASC',
'OPTION_NAME'=>'ASC',
'SEQNUMBER'=>'ASC',
);
}
?>

View File

@@ -0,0 +1,21 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Archive Copy Groups
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_COPYGROUP_AR extends TSM_ORM {
protected $_table_name = 'AR_COPYGROUPS';
protected $_primary_key = 'DOMAIN_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'DOMAIN_NAME'=>'ASC',
'SET_NAME'=>'ASC',
'CLASS_NAME'=>'ASC',
);
}
?>

View File

@@ -0,0 +1,21 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Backup Copy Groups
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_COPYGROUP_BU extends TSM_ORM {
protected $_table_name = 'BU_COPYGROUPS';
protected $_primary_key = 'DOMAIN_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'DOMAIN_NAME'=>'ASC',
'SET_NAME'=>'ASC',
'CLASS_NAME'=>'ASC',
);
}
?>

View File

@@ -0,0 +1,25 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Device Classes
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
* @note This is model is using the plural name, as storage pools have an attribute with the singular name
*/
class Model_DEVCLASSES extends TSM_ORM {
protected $_table_name = 'DEVCLASSES';
protected $_primary_key = 'DEVCLASS_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'DEVTYPE'=>'ASC',
'DEVCLASS_NAME'=>'ASC',
);
protected $_has_many = array(
'STGPOOL'=>array('foreign_key'=>'DEVCLASS','far_key'=>'DEVCLASS_NAME'),
);
}
?>

View File

@@ -0,0 +1,111 @@
<?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 TSM_ORM {
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;
}
}
?>

View File

@@ -0,0 +1,25 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Drive
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_DRIVE extends TSM_ORM {
protected $_table_name = 'DRIVES';
protected $_primary_key = 'DRIVE_NAME';
protected $_sorting = array(
'DRIVE_NAME'=>'ASC',
);
protected $_has_one = array(
);
protected $_has_many = array(
'PATH'=>array('foreign_key'=>array('LIBRARY_NAME'=>'LIBRARY_NAME','DRIVE_NAME'=>'DESTINATION_NAME')),
);
}
?>

View File

@@ -0,0 +1,32 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Event
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_EVENT extends TSM_ORM {
protected $_table_name = 'EVENTS';
protected $_primary_key = 'NODE_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'SCHEDULED_START'=>'ASC',
'NODE_NAME'=>'ASC',
);
protected $_display_filters = array(
'SCHEDULED_START'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
),
'ACTUAL_START'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
),
'COMPLETED'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
),
);
}
?>

View File

@@ -0,0 +1,88 @@
<?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 TSM_ORM {
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_one = array(
'NODE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
);
protected $_has_many = array(
);
protected $_tsm = array(
'db2'=>array(
'_primary_key'=>'FSNAME',
'_sorting'=>array(
'NODEID'=>'ASC',
'FSNAME'=>'ASC',
),
'_has_one'=>array(
'NODE'=>array('foreign_key'=>'NODEID','far_key'=>'NODEID'),
),
'translate'=>array(
'FILESPACE_NAME'=>'FSNAME',
'BACKUP_END'=>'BACKSTART',
'PCT_UTIL'=>NULL,
),
),
);
protected $_display_filters = array(
'BACKUP_END'=>array(
array('TSM_ORM::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->NODE->OCC
->select('STGPOOL_NAME')
->where('TYPE','=',$dtype)
->and_where('FILESPACE_NAME','=',$this->FILESPACE_NAME)
->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->NODE->OCC
->where('STGPOOL_NAME','=',$pool)
->and_where('TYPE','=',$btype)
->and_where('FILESPACE_NAME','=',$this->FILESPACE_NAME)
->find()->LOGICAL_MB;
}
public function pool_numvols($pool,$ctype) {
return $this->NODE->VOLUMEUSAGE
->where('STGPOOL_NAME','=',$pool)
->and_where('COPY_TYPE','=',$ctype)
->and_where('FILESPACE_NAME','=',$this->FILESPACE_NAME)
->find_all()->count();
}
}
?>

View File

@@ -0,0 +1,188 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Library
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_LIBRARY extends TSM_ORM {
protected $_table_name = 'LIBRARIES';
protected $_primary_key = 'LIBRARY_NAME';
protected $_sorting = array(
'LIBRARY_NAME'=>'ASC',
);
// Store our show slots data
private $slots;
private $storagepools = array();
protected $_has_one = array(
);
protected $_has_many = array(
'DRIVE'=>array('foreign_key'=>'LIBRARY_NAME','far_key'=>'LIBRARY_NAME'),
'PATH'=>array('foreign_key'=>'DESTINATION_NAME','far_key'=>'LIBRARY_NAME'),
'DEVCLASSES'=>array('foreign_key'=>'LIBRARY_NAME','far_key'=>'LIBRARY_NAME'),
);
public function slots() {
return $this->slots ? $this->slots : $this->slots = DB::query(Database::SHOW,'SHOW SLOTS '.$this)->execute(Kohana::$config->load('config')->client_type);
}
// Return a list of scratch volumes
public function scratchvol() {
$return = array();
foreach ($this->slots() as $slot)
if ($slot->status == 'Allocated' AND $slot->LIBVOLUME->usage() == 'scratch')
array_push($return,$slot->LIBVOLUME->VOLUME);
return $return;
}
// Return a list of volumes that are readonly
public function readonlyvol() {
$return = array();
foreach ($this->slots() as $slot)
if ($slot->LIBVOLUME->VOLUME->ACCESS == 'READONLY')
array_push($return,$slot->LIBVOLUME->VOLUME);
return $return;
}
// Return the number of slots that are empty.
public function numemptyslot() {
return $this->slots->Slots-$this->slots->Changers-count($this->slots);
}
// Return the slots that are used, but not checked in.
public function notcheckedinvol() {
$return = array();
foreach ($this->slots() as $slot)
if ($slot->status == 'Full')
array_push($return,$slot);
return $return;
}
// Return the device classes that use this library.
public function devclasses() {
return $this->DEVCLASSES->where('LIBRARY_NAME','=',$this)->find_all();
}
// Return a list of storage pools that potentially use this library.
public function storagepools() {
if (! $this->storagepools)
foreach ($this->devclasses() as $dco)
foreach ($dco->STGPOOL->find_all() as $spo)
array_push($this->storagepools,$spo);
return $this->storagepools;
}
public function storagepoolstype($type) {
$result = array();
foreach ($this->storagepools() as $spo)
if ($spo->POOLTYPE == $type)
array_push($result,$spo);
return $result;
}
/**
* Return a list of volumes
*
* @param $ptype is pool type (PRIMARY,ACTIVE,COPY)
* @param $inout IN|OUT of the library
* @param $status volume status FULL|FILLING|PENDING|EMPTY
* @note This is an intensive method that needs caching.
*/
public function volstype($ptype,$inout,$status) {
static $CACHE = array();
$ainout = array('IN','OUT');
if (! isset($CACHE[__METHOD__][$ptype]))
foreach ($this->storagepoolstype($ptype) as $spo)
foreach ($ainout as $cinout)
foreach (Kohana::$config->load('config')->tsmvolstatus as $cstatus) {
if (! isset($CACHE[__METHOD__][$spo->POOLTYPE][$cinout][$cstatus]))
$CACHE[__METHOD__][$spo->POOLTYPE][$cinout][$cstatus] = array();
$CACHE[__METHOD__][$spo->POOLTYPE][$cinout][$cstatus] =
array_merge($CACHE[__METHOD__][$spo->POOLTYPE][$cinout][$cstatus],$spo->libvolstype($cinout,$cstatus));
}
return isset($CACHE[__METHOD__][$ptype][$inout][$status]) ? $CACHE[__METHOD__][$ptype][$inout][$status] : array();
}
/**
* Return a list of DB volumes
*
* @param $inout IN|OUT of the library
* @note This is an intensive method that needs caching.
*/
public function dbvolsloc($inout) {
static $CACHE = array();
if (! isset($CACHE[__METHOD__]))
foreach (ORM::factory('VOLHISTORY')->where('TYPE','IN',Kohana::$config->load('config')->tsmdbtypes)->find_all() as $vho)
$CACHE[__METHOD__][$vho->LIBVOLUME->LIBRARY_NAME ? 'IN' : 'OUT'][] = $vho;
return isset($CACHE[__METHOD__][$inout]) ? $CACHE[__METHOD__][$inout] : array();
}
// Return a list of DB volumes by type
// @param $inout IN|OUT of the library
// @param $dtype is DB vole type (BACKUPFULL,BACKUPINCR,DBSNAPSHOT)
public function dbvolstype($inout,$dtype) {
$result = array();
foreach ($this->dbvolsloc($inout) as $vho)
if ($vho->TYPE ==$dtype)
array_push($result,$vho);
return $result;
}
public function volsnotinlib() {
$result = array();
foreach ($this->storagepools() as $spo)
foreach ($spo->VOLUME->find_all() as $vo)
if (! $vo->MEDIA->inlib())
array_push($result,$vo);
Sort::masort($result,'VOLUME_NAME');
return $result;
}
// Volumes that are stale
public function stalevol() {
$result = array();
foreach ($this->storagepools() as $spo)
foreach ($spo->VOLUME->find_all() as $vo)
if ($vo->recycle())
array_push($result,$vo);
Sort::masort($result,'VOLUME_NAME');
return $result;
}
public function removablelibvol() {
$result = array();
foreach ($this->slots() as $slot)
if ($slot->LIBVOLUME->removable())
array_push($result,$slot->LIBVOLUME);
return $result;
}
}
?>

View File

@@ -0,0 +1,90 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Library Volumes
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_LIBVOLUME extends TSM_ORM {
protected $_table_name = 'LIBVOLUMES';
protected $_primary_key = 'HOME_ELEMENT';
protected $_sorting = array(
'VOLUME_NAME'=>'ASC',
);
protected $_has_one = array(
'VOLUME'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
);
protected $_has_many = array(
'VOLHISTORY'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
);
public function usage() {
switch (strtolower($this->STATUS)) {
case 'scratch': return strtolower($this->STATUS);
case 'private':
if ($this->VOLUME->STATUS == 'EMPTY')
return 'empty';
switch (strtolower($this->LAST_USE)) {
case 'dbbackup':
case 'data':
return strtolower($this->LAST_USE);
default: return 'unkown';
}
default: return 'notcheckedin';
}
}
public function volusage() {
switch ($this->usage()) {
case 'data':
case 'empty': return $this->VOLUME->STGPOOL_NAME;
case 'dbbackup': return $this->VOLHISTORY->lastuse()->TYPE;
case 'notcheckedin': return _('Not Checked In');
case 'scratch': return _('Scratch');
default: return _('Unknown');
}
}
public function status() {
switch ($this->usage()) {
case 'data': return sprintf('%s/%s',$this->VOLUME->display('STATUS'),$this->VOLUME->display('ACCESS'));
case 'dbbackup': return $this->VOLHISTORY->lastuse()->backupid();
case 'empty': return _('Empty');
default: return '';
}
}
public function access() {
if ($this->usage() == 'scratch')
return '';
elseif ($this->STATUS)
return sprintf('%s/%s',$this->display('STATUS'),$this->display('OWNER'));
else
return '';
}
public function lastwrite() {
switch ($this->usage()) {
case 'data':
case 'empty': return $this->VOLUME->display('LAST_WRITE_DATE');
case 'dbbackup': return $this->VOLHISTORY->lastuse()->display('DATE_TIME');
default: return '';
}
}
public function removable() {
return ($this->usage() == 'dbbackup' OR (! in_array($this->usage(),array('empty','scratch')) AND $this->VOLUME->STGPOOL->POOLTYPE != 'PRIMARY')) ? TRUE : FALSE;
}
}
?>

View File

@@ -0,0 +1,28 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Media
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_MEDIA extends TSM_ORM {
protected $_table_name = 'MEDIA';
protected $_primary_key = 'VOLUME_NAME';
protected $_sorting = array(
'VOLUME_NAME'=>'ASC',
);
protected $_has_one = array(
);
protected $_has_many = array(
);
public function inlib() {
return in_array($this->STATE,array('MOUNTABLEINLIB','Mountable in library'));
}
}
?>

View File

@@ -0,0 +1,26 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Management Class
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_MGMTCLASS extends TSM_ORM {
protected $_table_name = 'MGMTCLASSES';
protected $_primary_key = 'DOMAIN_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'DEFAULTMC'=>'DESC',
'DOMAIN_NAME'=>'ASC',
'CLASS_NAME'=>'ASC',
);
protected $_has_one = array(
'COPYGROUP_BU'=>array('foreign_key'=>array('DOMAIN_NAME'=>'DOMAIN_NAME','SET_NAME'=>'SET_NAME','CLASS_NAME'=>'CLASS_NAME')),
'COPYGROUP_AR'=>array('foreign_key'=>array('DOMAIN_NAME'=>'DOMAIN_NAME','SET_NAME'=>'SET_NAME','CLASS_NAME'=>'CLASS_NAME')),
);
}
?>

View File

@@ -0,0 +1,319 @@
<?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 TSM_ORM {
protected $_table_name = 'NODES';
protected $_primary_key = 'NODE_NAME';
protected $_sorting = array(
'NODE_NAME'=>'ASC',
);
protected $_has_one = array(
'DOMAIN'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
);
protected $_has_many = array(
'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'),
'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',
),
),
);
protected $_display_filters = array(
'REG_TIME'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
),
'PWSET_TIME'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
),
'LASTACC_TIME'=>array(
array('TSM_ORM::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)),
),
);
// Pools used by a node.
private $pools = array();
public function tsmclientversion() {
if ($this->CLIENT_VERSION)
return sprintf('%s.%s.%s.%s',$this->CLIENT_VERSION,$this->CLIENT_RELEASE,$this->CLIENT_LEVEL,$this->CLIENT_SUBLEVEL);
else
return '';
}
public function platform() {
return sprintf('%s %s',$this->PLATFORM_NAME,$this->CLIENT_OS_LEVEL ? '('.$this->CLIENT_OS_LEVEL.')' : '');
}
// @todo This needs to return the global configuration.
public function passexp() {
if ($this->PASSEXP)
return 'TBA';
else
return _('No Set');
}
public function lasttransferpercent() {
return 100-($this->LASTSESS_IDLEWAIT+$this->LASTSESS_COMMWAIT+$this->LASTSESS_MEDIAWAIT);
}
public function lasttransfertime() {
if ($this->LASTSESS_DURATION)
return $this->LASTSESS_DURATION*($this->lasttransferpercent()/100);
else
return 0;
}
public function lastsendperformance() {
if ($this->lasttransfertime())
return $this->LASTSESS_SENT/$this->lasttransfertime()/1024/1024;
else
return 0;
}
public function lastreceiveperformance() {
if ($this->lasttransfertime())
return $this->LASTSESS_RECVD/$this->lasttransfertime()/1024/1024;
else
return 0;
}
public function lastsendaggperformance() {
if ((real)$this->LASTSESS_DURATION)
return $this->LASTSESS_SENT/$this->LASTSESS_DURATION/1024/1024;
else
return 0;
}
public function lastreceiveaggperformance() {
if ((real)$this->LASTSESS_DURATION)
return $this->LASTSESS_RECVD/$this->LASTSESS_DURATION/1024/1024;
else
return 0;
}
// @todo This should return the system setting (cloptset), if the node setting is not configured.
public function txngroupmax() {
return $this->TXNGROUPMAX;
}
// Work out all the storage pools used by a node.
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
public function getStoragePools($dtype) {
return isset($this->pools[$dtype]) ? $this->pools[$dtype] : $this->_getpools($dtype);
}
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
private function _getpools($dtype) {
$this->pools[$dtype] = array();
foreach ($this->FILESPACE->find_all() as $fso)
foreach ($fso->storagepools($dtype) as $po)
if (! isset($this->pools[$dtype][$po->POOLTYPE][$po->STGPOOL_NAME]))
$this->pools[$dtype][$po->POOLTYPE][$po->STGPOOL_NAME] = $po;
return $this->pools[$dtype];
}
// Test to see if a node has any data of type
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
public function hasData($dtype) {
return $this->getStoragePools($dtype) ? TRUE : FALSE;
}
public function getAllStoragePoolsType($ptype) {
$result = array();
foreach (Kohana::$config->load('config')->tsmdatatypes as $btype => $ctype)
$result = array_merge($result,$this->getStoragePoolsType($btype,$ptype));
return $result;
}
// Return the storage pools used for a 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->VOLUMEUSAGE->where('COPY_TYPE','=',$dtype)->find_all() as $vo)
if ((! $spo OR $vo->STGPOOL_NAME == $spo) AND $vo->STGPOOL->POOLTYPE == $ptype)
if (! isset($result[$vo->VOLUME_NAME]))
$result[$vo->VOLUME_NAME] = $vo;
return $result;
}
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageTypeVols($ptype,$spo='') {
$result = array();
foreach (Kohana::$config->load('config')->tsmdatatypes as $btype => $ctype)
$result = array_merge($result,$this->getStorageModeVols($ctype,$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->OCC->where('TYPE','=',$dtype)->find_all() as $oa)
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $ptype)
$count += $oa->NUM_FILES;
return $count;
}
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageTypeFiles($ptype,$spo='') {
$count = 0;
foreach (Kohana::$config->load('config')->tsmdatatypes as $btype => $ctype)
$count += $this->getStorageModeFiles($btype,$ptype,$spo);
return $count;
}
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeData($dtype,$ptype,$spo='') {
$count = 0;
foreach ($this->OCC->where('TYPE','=',$dtype)->find_all() as $oa)
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $ptype)
$count += $oa->LOGICAL_MB;
return $count;
}
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageTypeData($ptype,$spo='') {
$count = 0;
foreach (Kohana::$config->load('config')->tsmdatatypes as $btype => $ctype)
$count += $this->getStorageModeData($btype,$ptype,$spo);
return $count;
}
// Return the volumes that this node uses
// $dtype is BACKUP or ARCHIVE
public function volumes($dtype) {
$volumes = array();
$v = array();
foreach ($this->VOLUMEUSAGE->where('COPY_TYPE','=',$dtype)->order_by('STGPOOL_NAME,FILESPACE_NAME')->find_all() as $vol)
if (! in_array($vol->VOLUME->VOLUME_NAME,$v)) {
$volumes[$vol->STGPOOL_NAME][] = $vol->VOLUME;
array_push($v,$vol->VOLUME->VOLUME_NAME);
}
return $volumes;
}
/**
* Get all the nodes by OS
*/
public function byos() {
$a = $this->select('count(*) AS node_name,platform_name')
->group_by('platform_name')
->order_by('platform_name');
return $a->find_all();
}
}
?>

View File

@@ -0,0 +1,26 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Occupancy
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
* @node This has been renamed to OCC from OCCUPANCY, as DB2/FILESPACES has an OCCUPANCY column
*/
class Model_OCC extends TSM_ORM {
protected $_table_name = 'OCCUPANCY';
protected $_primary_key = 'NODE_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'NODE_NAME'=>'ASC',
'FILESPACE_NAME'=>'ASC',
'STGPOOL_NAME'=>'ASC',
);
protected $_has_one = array(
'STGPOOL'=>array('foreign_key'=>'STGPOOL_NAME','far_key'=>'STGPOOL_NAME'),
);
}
?>

View File

@@ -0,0 +1,24 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Drive Paths
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_PATH extends TSM_ORM {
protected $_table_name = 'PATHS';
protected $_primary_key = 'DEVICE';
protected $_sorting = array(
'DESTINATION_NAME'=>'ASC',
);
protected $_has_one = array(
);
protected $_has_many = array(
);
}
?>

View File

@@ -0,0 +1,33 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Client Schedule Associations
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_SCHEDULE_CLIENT extends TSM_ORM {
protected $_table_name = 'CLIENT_SCHEDULES';
protected $_primary_key = 'SCHEDULE_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'SCHEDULE_NAME'=>'ASC',
);
protected $_has_many = array(
'ASSOCIATION'=>array('foreign_key'=>'SCHEDULE_NAME','far_key'=>'SCHEDULE_NAME'),
);
protected $_display_filters = array(
'STARTTIME'=>array(
array('TSM_ORM::date',array(':value','h:m')),
),
);
public function getNodes() {
return $this->ASSOCIATION->find_all();
}
}
?>

View File

@@ -0,0 +1,44 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Storage Pools
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_STGPOOL extends TSM_ORM {
protected $_table_name = 'STGPOOLS';
protected $_primary_key = 'STGPOOL_NAME';
protected $_sorting = array(
'STGPOOL_NAME'=>'ASC',
);
protected $_has_one = array(
'DEVCLASSES'=>array('foreign_key'=>'DEVCLASS_NAME','far_key'=>'DEVCLASS'),
);
protected $_has_many = array(
'VOLUME'=>array('foreign_key'=>'STGPOOL_NAME','far_key'=>'STGPOOL_NAME'),
);
// Return a list of volumes
// @param $inout IN|OUT of the library
// @param $status volume status FULL|FILLING|PENDING|EMPTY
public function libvolstype($inout,$status) {
$inout = strtolower($inout);
$status = strtoupper($status);
$result = array();
if (! isset($result[$inout]))
foreach ($this->VOLUME->find_all() as $vo) {
$state = $vo->MEDIA->inlib() ? 'in' : 'out';
$result[$state][$vo->STATUS][] = $vo;
}
return isset($result[$inout][$status]) ? $result[$inout][$status] : array();
}
}
?>

View File

@@ -0,0 +1,30 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Summary
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_SUMMARY extends TSM_ORM {
protected $_table_name = 'SUMMARY';
protected $_primary_key = 'ACTIVITY'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'START_TIME'=>'ASC',
'ENTITY'=>'ASC',
'ACTIVITY'=>'ASC',
);
protected $_display_filters = array(
'START_TIME'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
),
'END_TIME'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
),
);
}
?>

View File

@@ -0,0 +1,42 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Volume History
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_VOLHISTORY extends TSM_ORM {
protected $_table_name = 'VOLHISTORY';
protected $_primary_key = 'VOLUME_NAME';
protected $_sorting = array(
'DATE_TIME'=>'ASC',
);
protected $_has_one = array(
'LIBVOLUME'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
'VOLUME'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
);
protected $_has_many = array(
);
protected $_display_filters = array(
'DATE_TIME'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
),
);
public function lastuse() {
// We'll find the last record
foreach ($this->order_by('DATE_TIME DESC')->find_all() as $r)
return $r;
}
public function backupid() {
return sprintf('%s.%s.%s',$this->BACKUP_SERIES,$this->BACKUP_OPERATION,$this->VOLUME_SEQ);
}
}
?>

View File

@@ -0,0 +1,69 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Volume
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_VOLUME extends TSM_ORM {
protected $_table_name = 'VOLUMES';
protected $_primary_key = 'VOLUME_NAME';
protected $_sorting = array(
'VOLUME_NAME'=>'ASC',
'STGPOOL_NAME'=>'ASC',
);
protected $_has_one = array(
'MEDIA'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
'STGPOOL'=>array('foreign_key'=>'STGPOOL_NAME','far_key'=>'STGPOOL_NAME'),
);
protected $_has_many = array(
'VOLUMEUSAGE'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
);
protected $_display_filters = array(
'LAST_READ_DATE'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
),
'LAST_WRITE_DATE'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
),
);
// Show the number of filespaces on a volume
// $dtype is BACKUP or ARCHIVE
public function getFSOnVol($dtype) {
return $this->VOLUMEUSAGE->where('COPY_TYPE','=',$dtype)->find_all()->count();
}
// Show the number of nodes on a volume
// $dtype is BACKUP or ARCHIVE
public function getNodesOnVol($dtype) {
return $this->VOLUMEUSAGE->select('NODE_NAME')->distinct(TRUE)->where('COPY_TYPE','=',$dtype)->find_all()->count();
}
public function isScratch() {
return $this->SCRATCH === 'YES' ? TRUE : FALSE;
}
public function location() {
return $this->display('LOCATION');
}
// Age of a volume, based on last read/write access.
public function age() {
if ((! $this->LAST_READ_DATE AND ! $this->LAST_WRITE_DATE) OR $this->STATUS == 'EMPTY')
return 0;
else
return (int)((time()-(strtotime(strtotime($this->LAST_READ_DATE) > strtotime($this->LAST_WRITE_DATE) ? $this->LAST_WRITE_DATE : $this->LAST_READ_DATE)))/86400);
}
public function recycle() {
return Kohana::$config->load('config')->tsmtapeage < $this->age() ? TRUE : FALSE;
}
}
?>

View File

@@ -0,0 +1,26 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Volume Usage
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_VOLUMEUSAGE extends TSM_ORM {
protected $_table_name = 'VOLUMEUSAGE';
protected $_primary_key = 'NODE_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'NODE_NAME'=>'ASC',
# 'FILESPACE_NAME'=>'ASC', // @todo Disabled, as we were getting some SQL errors, when the query returned no records
# 'VOLUME_NAME'=>'ASC',
);
protected $_has_one = array(
'STGPOOL'=>array('foreign_key'=>'STGPOOL_NAME','far_key'=>'STGPOOL_NAME'),
'VOLUME'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
);
}
?>