Added volumes for a node

Added schedules
Added management classes for a node
Added clientopts to nodes
Added schedule and event information
This commit is contained in:
Deon George
2011-05-24 01:04:40 +10:00
parent a244d693b5
commit 58ddb97d87
24 changed files with 650 additions and 171 deletions

View File

@@ -73,6 +73,22 @@ $(document).ready(function () {$("#node_name").change(function () {
'body'=>$output,
));
$output = View::factory('nodes/detail_volumes')
->set('node',$no);
Block::add(array(
'title'=>_('Sequential Volume Usage Information'),
'body'=>$output,
));
$output = View::factory('nodes/detail_schedule')
->set('node',$no);
Block::add(array(
'title'=>_('Schedule Information'),
'body'=>$output,
));
$this->template->content = Block::factory();
}
}

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 ORMTSM {
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

@@ -13,82 +13,5 @@ class Model_Auth_UserDefault extends Model_Auth_User {
protected $_disable_wild_select = TRUE;
protected $_disable_join_table_name = TRUE;
protected $_disable_limit = TRUE;
// Validation rules
protected $_rules = array(
'admin_name' => array(
'not_empty' => NULL,
'min_length' => array(4),
'max_length' => array(8),
),
'password' => array(
'not_empty' => NULL,
'min_length' => array(5),
'max_length' => array(16),
),
'password_confirm' => array(
'matches_ifset' => array('password'),
),
);
// Columns to ignore
protected $_ignored_columns = array('password_confirm');
// Field labels
protected $_labels = array(
'admin_name' => 'username',
'email' => 'email address',
'password' => 'password',
'password_confirm' => 'password confirmation',
);
/**
* Validates login information from an array, and optionally redirects
* after a successful login.
*
* @param array values to check
* @param string URI or URL to redirect to
* @return boolean
*/
public function login(array & $array, $redirect = FALSE) {
$fieldname = 'admin_name'; // @todo This should be defined in a config or database driver file
$array = Validate::factory($array)
->label('username', $this->_labels[$fieldname])
->label('password', $this->_labels['password'])
->filter(TRUE, 'trim')
->filter('username','strtoupper')
->rules('username', $this->_rules[$fieldname])
->rules('password', $this->_rules['password']);
// Get the remember login option
$remember = isset($array['remember']);
// Login starts out invalid
$status = FALSE;
if ($array->check())
{
// Attempt to load the user
$this->where($fieldname, '=', $array['username'])->find();
if ($this->loaded() AND Auth::instance()->login($this, $array['password'], $remember))
{
if (is_string($redirect))
{
// Redirect after a successful login
Request::instance()->redirect($redirect);
}
// Login is successful
$status = TRUE;
}
else
{
$array->error('admin_name', 'invalid');
}
}
return $status;
}
}
?>

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 ORMTSM {
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 ORMTSM {
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 ORMTSM {
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,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
* @node This is model is using the plural name, as storage pools have an attribute with the singular name
*/
class Model_DEVCLASSES extends ORMTSM {
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',
);
}
?>

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 ORMTSM {
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('ORMTSM::date',array(':value','d-M H:i')),
),
'ACTUAL_START'=>array(
array('ORMTSM::date',array(':value','d-M H:i')),
),
'COMPLETED'=>array(
array('ORMTSM::date',array(':value','d-M H:i')),
),
);
}
?>

View File

@@ -11,18 +11,21 @@
*/
class Model_FILESPACE extends ORMTSM {
protected $_table_name = 'FILESPACES';
protected $_primary_key = 'FILESPACE_NAME';
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_many = array(
'VOLUMEUSAGE'=>array('foreign_key'=>array('NODE_NAME','FILESPACE_NAME'),'far_key'=>'FILESPACE_NAME'),
'OCCUPANCY'=>array('foreign_key'=>array('NODE_NAME','FILESPACE_NAME'),'far_key'=>'FILESPACE_NAME'),
);
protected $_formats = array(
'BACKUP_END'=>array('ORMTSM::date'=>array('d-M-Y')),
);
protected $_sorting = array(
'NODE_NAME'=>'ASC',
protected $_display_filters = array(
'BACKUP_END'=>array(
array('ORMTSM::date',array(':value','d-M-Y')),
),
);
public function utilsation() {
@@ -37,20 +40,20 @@ class Model_FILESPACE extends ORMTSM {
->where('TYPE','=',$dtype)
->group_by('STGPOOL_NAME')
->order_by('STGPOOL_NAME')
->find_all() as $vo) {
->find_all() as $oo) {
array_push($pool,$vo->STGPOOL_NAME);
array_push($pool,$oo->STGPOOL);
}
return $pool;
}
public function pool_logical_util($pool) {
return $this->OCCUPANCY->where('STGPOOL_NAME','=',$pool)->find()->LOGICAL_MB;
public function pool_logical_util($pool,$btype) {
return $this->OCCUPANCY->where('STGPOOL_NAME','=',$pool)->where('TYPE','=',$btype)->find()->LOGICAL_MB;
}
public function pool_numvols($pool) {
return $this->VOLUMEUSAGE->where('STGPOOL_NAME','=',$pool)->find_all()->count();
public function pool_numvols($pool,$ctype) {
return $this->VOLUMEUSAGE->where('STGPOOL_NAME','=',$pool)->where('COPY_TYPE','=',$ctype)->find_all()->count();
}
}
?>

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 ORMTSM {
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','SET_NAME','CLASS_NAME')),
'COPYGROUP_AR'=>array('foreign_key'=>array('DOMAIN_NAME','SET_NAME','CLASS_NAME')),
);
}
?>

View File

@@ -12,44 +12,50 @@
class Model_NODE extends ORMTSM {
protected $_table_name = 'NODES';
protected $_primary_key = 'NODE_NAME';
protected $_has_many = array(
'FILESPACE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'FILESPACE_NAME'),
);
protected $_display_filters = array(
'REG_TIME'=>array(
array('ORMTSM::date',array(':value','d-M-Y')),
),
'PWSET_TIME'=>array(
array('ORMTSM::date',array(':value','d-M-Y')),
),
'LASTACC_TIME'=>array(
array('ORMTSM::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)),
),
);
protected $_sorting = array(
'NODE_NAME'=>'ASC',
);
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'),
);
protected $_display_filters = array(
'REG_TIME'=>array(
array('ORMTSM::date',array(':value','d-M-Y')),
),
'PWSET_TIME'=>array(
array('ORMTSM::date',array(':value','d-M-Y')),
),
'LASTACC_TIME'=>array(
array('ORMTSM::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();
@@ -106,39 +112,72 @@ class Model_NODE extends ORMTSM {
// @todo This should return the system setting (cloptset), if the node setting is not configured.
public function txngroupmax() {
return $this->display('TXNGROUPMAX');
return $this->TXNGROUPMAX;
}
// Work out all the storage pools used by a node.
// $dtype is BACKUP or ARCHIVE
public function storagepools($dtype) {
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->FILESPACE->find_all() as $fso) {
foreach ($fso->storagepools($dtype) as $pool_name) {
$po = ORM::Factory('stgpool',$pool_name);
if (! isset($this->pools[$dtype][$po->POOLTYPE]) OR ! in_array($pool_name,$this->pools[$dtype][$po->POOLTYPE]))
$this->pools[$dtype][$po->POOLTYPE][] = $pool_name;
}
}
foreach ($this->FILESPACE->find_all() as $fso)
foreach ($fso->storagepools($dtype) as $po)
if (! isset($this->pools[$dtype][$po->POOLTYPE]) OR ! in_array($po->STGPOOL_NAME,$this->pools[$dtype][$po->POOLTYPE]))
$this->pools[$dtype][$po->POOLTYPE][] = $po;
return $this->pools[$dtype];
}
// Return the storage pools used for a backup type
// $dtype is BACKUP or ARCHIVE
public function getStoragePools($dtype,$ptype) {
// $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();
}
// @todo This routine should be cached.
public function getStorageTypeFiles($type) {
$count = 0;
foreach ($this->FILESPACE->find_all() as $fo)
foreach ($fo->OCCUPANCY->find_all() as $oa)
if ($oa->STGPOOL->POOLTYPE == $type)
$count += $oa->NUM_FILES;
return $count;
}
// @todo This routine should be cached.
public function getStorageTypeData($type) {
$count = 0;
foreach ($this->FILESPACE->find_all() as $fo)
foreach ($fo->OCCUPANCY->find_all() as $oa)
if ($oa->STGPOOL->POOLTYPE == $type)
$count += $oa->LOGICAL_MB;
return $count;
}
// Return the volumes that this node uses
// $dtype is BACKUP or ARCHIVE
// @todo Cache this data
public function volumes($dtype) {
$volumes = array();
foreach ($this->VOLUMEUSAGE->where('COPY_TYPE','=',$dtype)->order_by('STGPOOL_NAME,FILESPACE_NAME')->find_all() as $vol)
$volumes[$vol->STGPOOL_NAME][] = $vol->VOLUME;
return $volumes;
}
/**
* Get all the nodes by OS
*/

View File

@@ -11,17 +11,15 @@
*/
class Model_OCCUPANCY extends ORMTSM {
protected $_table_name = 'OCCUPANCY';
protected $_primary_key = 'FILESPACE_NAME';
protected $_has_many = array(
);
protected $_formats = array(
);
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,25 @@
<?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 ORMTSM {
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 $_display_filters = array(
'STARTTIME'=>array(
array('ORMTSM::date',array(':value','h:m')),
),
);
}
?>

View File

@@ -12,14 +12,12 @@
class Model_STGPOOL extends ORMTSM {
protected $_table_name = 'STGPOOLS';
protected $_primary_key = 'STGPOOL_NAME';
protected $_has_many = array(
);
protected $_formats = array(
);
protected $_sorting = array(
'STGPOOL_NAME'=>'ASC',
);
protected $_has_one = array(
'DEVCLASSES'=>array('foreign_key'=>'DEVCLASS_NAME','far_key'=>'DEVCLASS'),
);
}
?>

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 ORMTSM {
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('ORMTSM::date',array(':value','d-M H:i')),
),
'END_TIME'=>array(
array('ORMTSM::date',array(':value','d-M H:i')),
),
);
}
?>

View File

@@ -0,0 +1,39 @@
<?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 ORMTSM {
protected $_table_name = 'VOLUMES';
protected $_primary_key = 'VOLUME_NAME';
protected $_sorting = array(
'VOLUME_NAME'=>'ASC',
'STGPOOL_NAME'=>'ASC',
);
protected $_has_many = array(
'VOLUMEUSAGE'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
);
protected $_display_filters = array(
'LAST_READ_DATE'=>array(
array('ORMTSM::date',array(':value','d-M-Y')),
),
'LAST_WRITE_DATE'=>array(
array('ORMTSM::date',array(':value','d-M-Y')),
),
);
// Show the number of nodes on a volume
// $dtype is BACKUP or ARCHIVE
public function getNodesOnVol($dtype) {
return $this->VOLUMEUSAGE->where('COPY_TYPE','=',$dtype)->find_all()->count();
}
}
?>

View File

@@ -11,17 +11,15 @@
*/
class Model_VOLUMEUSAGE extends ORMTSM {
protected $_table_name = 'VOLUMEUSAGE';
protected $_primary_key = 'FILESPACE_NAME';
protected $_has_many = array(
);
protected $_formats = array(
);
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',
'VOLUME_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(
'VOLUME'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
);
}
?>

View File

@@ -63,7 +63,7 @@ class ORM extends Kohana_ORM {
if (isset($this->_object_formated[$column]))
return $this->_object_formated[$column];
else
return $value;
return $value ? $value : '&nbsp;';
}
}
?>

View File

@@ -29,7 +29,7 @@ class ORMTSM extends ORM {
}
public static function date($date,$format) {
return date($format,strtotime($date));
return $date ? date($format,strtotime($date)) : '';
}
}
?>