WIP sofar
This commit is contained in:
parent
939d0a43d6
commit
6d858a982a
@ -83,8 +83,9 @@ class Database_TSM extends Database {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Create a connection and force it to be a new link
|
// Create a connection and force it to be a new link
|
||||||
$this->_connection = sprintf('%s -id=%s -password=%s -displ=list -dataonly=YES %s %s',
|
$this->_connection = sprintf('%s %s -id=%s -password=%s -displ=list -dataonly=YES %s %s',
|
||||||
Kohana::config('config.client'),
|
Kohana::config('config.client'),
|
||||||
|
Kohana::config('config.stanza') ? '-server='.Kohana::config('config.stanza') : '',
|
||||||
$username,
|
$username,
|
||||||
$password,
|
$password,
|
||||||
Kohana::config('config.client_errorlogname') ? sprintf('-errorlogname=%s',Kohana::config('config.client_errorlogname')) : '',
|
Kohana::config('config.client_errorlogname') ? sprintf('-errorlogname=%s',Kohana::config('config.client_errorlogname')) : '',
|
||||||
|
@ -59,9 +59,6 @@ class Database_TSM_Result extends Database_Result {
|
|||||||
if ($this->_current_row !== $this->_internal_row AND ! $this->seek($this->_current_row))
|
if ($this->_current_row !== $this->_internal_row AND ! $this->seek($this->_current_row))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// Increment internal row for optimization assuming rows are fetched in order
|
|
||||||
$this->_internal_row++;
|
|
||||||
|
|
||||||
if ($this->_as_object === TRUE)
|
if ($this->_as_object === TRUE)
|
||||||
{
|
{
|
||||||
// Return an stdClass
|
// Return an stdClass
|
||||||
@ -72,14 +69,24 @@ class Database_TSM_Result extends Database_Result {
|
|||||||
// Return an object of given class name
|
// Return an object of given class name
|
||||||
$o = new $this->_as_object;
|
$o = new $this->_as_object;
|
||||||
|
|
||||||
return $o->_load_values($this->_rows[$this->_current_row++]);
|
return $o->_load_values($this->_rows[$this->_current_row]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Return an array of the row
|
// Return an array of the row
|
||||||
return $this->_rows[$this->_current_row++];
|
return $this->_rows[$this->_current_row];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a row value from the query
|
||||||
|
*
|
||||||
|
* TSM returns all columns in upper case
|
||||||
|
*/
|
||||||
|
public function get($name, $default = NULL) {
|
||||||
|
$name = strtoupper($name);
|
||||||
|
|
||||||
|
return parent::get($name,$default);
|
||||||
|
}
|
||||||
} // End Database_TSM_Result
|
} // End Database_TSM_Result
|
||||||
?>
|
?>
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class Model_Auth_UserDefault extends Model_Auth_User {
|
class Model_Auth_UserDefault extends Model_Auth_User {
|
||||||
protected $_table_names_plural = false;
|
protected $_table_names_plural = FALSE;
|
||||||
|
protected $_disable_wild_select = TRUE;
|
||||||
|
|
||||||
// Validation rules
|
// Validation rules
|
||||||
protected $_rules = array(
|
protected $_rules = array(
|
||||||
|
90
application/classes/model/node.php
Normal file
90
application/classes/model/node.php
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<?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 ORMTSM {
|
||||||
|
protected $_table_name = 'NODES';
|
||||||
|
protected $_primary_key = 'NODE_NAME';
|
||||||
|
|
||||||
|
protected $_formats = array(
|
||||||
|
'REG_TIME'=>array('ORMTSM::date'=>array('d-M-Y')),
|
||||||
|
'PWSET_TIME'=>array('ORMTSM::date'=>array('d-M-Y')),
|
||||||
|
'LASTACC_TIME'=>array('ORMTSM::date'=>array('d-M-Y')),
|
||||||
|
'LASTSESS_SENT'=>array('number_format'=>array(0)),
|
||||||
|
'LASTSESS_RECVD'=>array('number_format'=>array(0)),
|
||||||
|
'LASTSESS_DURATION'=>array('number_format'=>array(2)),
|
||||||
|
'LASTSESS_IDLEWAIT'=>array('number_format'=>array(2)),
|
||||||
|
'LASTSESS_COMMWAIT'=>array('number_format'=>array(2)),
|
||||||
|
'LASTSESS_MEDIAWAIT'=>array('number_format'=>array(2)),
|
||||||
|
);
|
||||||
|
|
||||||
|
protected $_sorting = array(
|
||||||
|
'NODE_NAME'=>'ASC',
|
||||||
|
);
|
||||||
|
|
||||||
|
public function tsmclientversion() {
|
||||||
|
return sprintf('%s.%s.%s.%s',$this->CLIENT_VERSION,$this->CLIENT_RELEASE,$this->CLIENT_LEVEL,$this->CLIENT_SUBLEVEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @todo This needs to return the global configuration.
|
||||||
|
public function passexp() {
|
||||||
|
if ($this->PASSEXP)
|
||||||
|
return 'TBA';
|
||||||
|
else
|
||||||
|
return _('No Set');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function lasttransferpercent() {
|
||||||
|
return number_format(100-($this->LASTSESS_IDLEWAIT+$this->LASTSESS_COMMWAIT+$this->LASTSESS_MEDIAWAIT),2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function lasttransfertime() {
|
||||||
|
return number_format($this->LASTSESS_DURATION*($this->lasttransferpercent()/100),2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function lastsendperformance() {
|
||||||
|
if ($this->lasttransfertime())
|
||||||
|
return number_format($this->LASTSESS_SENT/$this->lasttransfertime()/1024/1024,2);
|
||||||
|
else
|
||||||
|
return _('N/A');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function lastreceiveperformance() {
|
||||||
|
if ($this->lasttransfertime())
|
||||||
|
return number_format($this->LASTSESS_RECVD/$this->lasttransfertime()/1024/1024,2);
|
||||||
|
else
|
||||||
|
return _('N/A');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function lastsendaggperformance() {
|
||||||
|
return number_format($this->LASTSESS_SENT/$this->LASTSESS_DURATION/1024/1024,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function lastreceiveaggperformance() {
|
||||||
|
return number_format($this->LASTSESS_RECVD/$this->LASTSESS_DURATION/1024/1024,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @todo This should return the system setting (cloptset), if the node setting is not configured.
|
||||||
|
public function txngroupmax() {
|
||||||
|
return $this->display('TXNGROUPMAX');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -17,8 +17,12 @@ class ORM extends Kohana_ORM {
|
|||||||
public function find($id = NULL) {
|
public function find($id = NULL) {
|
||||||
// Since TSM doesnt support LIMIT, we'll use find_all() but return the first record
|
// Since TSM doesnt support LIMIT, we'll use find_all() but return the first record
|
||||||
foreach ($this->find_all() as $object) {
|
foreach ($this->find_all() as $object) {
|
||||||
|
// In TSM Primary Keys are in upper case
|
||||||
|
if (is_null($id) OR $object->{$object->_primary_key} == strtoupper($id))
|
||||||
$this->_load_values($object->_object);
|
$this->_load_values($object->_object);
|
||||||
|
|
||||||
|
// If we have found our item return
|
||||||
|
if ($this->_loaded)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
88
application/classes/ormtsm.php
Normal file
88
application/classes/ormtsm.php
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class extends Kohana's [ORM] class to create defaults for TSM.
|
||||||
|
*
|
||||||
|
* @package TSM
|
||||||
|
* @subpackage Core
|
||||||
|
* @category ORM
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 phpTSMadmin Development Team
|
||||||
|
* @license http://dev.osbill.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class ORMTSM extends ORM {
|
||||||
|
// Suppress ORMs inclusion of <table_name>.*
|
||||||
|
protected $_disable_wild_select = TRUE;
|
||||||
|
|
||||||
|
// Enable the formating of columns
|
||||||
|
protected $_object_formated = array();
|
||||||
|
protected $_formated = FALSE;
|
||||||
|
protected $_formats = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format fields for display purposes
|
||||||
|
*
|
||||||
|
* @param string column name
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
protected function _format() {
|
||||||
|
$format = Validate::factory($this->_object);
|
||||||
|
|
||||||
|
foreach ($this->_formats as $column => $formats)
|
||||||
|
$format->filters($column,$formats);
|
||||||
|
|
||||||
|
if ($format->check())
|
||||||
|
foreach ($format as $column => $value)
|
||||||
|
$this->_object_formated[$column] = $value;
|
||||||
|
|
||||||
|
$this->_formated = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a formated columns, as per the model definition
|
||||||
|
*/
|
||||||
|
public function display($column) {
|
||||||
|
// Trigger a load of the record.
|
||||||
|
$value = $this->__get($column);
|
||||||
|
|
||||||
|
// If some of our fields need to be formated for display purposes.
|
||||||
|
if ($this->_loaded AND ! $this->_formated AND $this->_formats)
|
||||||
|
$this->_format();
|
||||||
|
|
||||||
|
if (isset($this->_object_formated[$column]))
|
||||||
|
return $this->_object_formated[$column];
|
||||||
|
else
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function date($date,$format) {
|
||||||
|
return date($format,strtotime($date));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will enhance the [Validate::filter], since it always passes
|
||||||
|
* the value as the first argument and sometimes functions need that to not
|
||||||
|
* be the first argument.
|
||||||
|
*
|
||||||
|
* Currently this implements:
|
||||||
|
* [date()][date-ref]
|
||||||
|
*
|
||||||
|
* [date-ref]: http://www.php.net/date
|
||||||
|
*
|
||||||
|
* This function will throw an exception if called without a function
|
||||||
|
* defined.
|
||||||
|
*
|
||||||
|
* @param mixed $val Value to be processed
|
||||||
|
* @param string $func Name of function to call
|
||||||
|
* @param string $arg Other arguments for the function
|
||||||
|
*/
|
||||||
|
final public static function _filters($val,$func,$arg) {
|
||||||
|
switch ($func) {
|
||||||
|
case 'date':
|
||||||
|
return date($arg,$val);
|
||||||
|
default:
|
||||||
|
throw new Exception(sprintf(_('Unknown function: %s (%s,%s)'),$func,$arg,$val));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -13,6 +13,7 @@
|
|||||||
return array(
|
return array(
|
||||||
'cache_type' => 'file',
|
'cache_type' => 'file',
|
||||||
'client' => '/opt/tivoli/tsm/client/ba/bin/dsmadmc',
|
'client' => '/opt/tivoli/tsm/client/ba/bin/dsmadmc',
|
||||||
|
'stanza' => '',
|
||||||
'client_errorlogname' => '/tmp/pta-tsm-errorlog.log',
|
'client_errorlogname' => '/tmp/pta-tsm-errorlog.log',
|
||||||
'date_format' => 'd-m-Y',
|
'date_format' => 'd-m-Y',
|
||||||
'email_admin_only'=> array(
|
'email_admin_only'=> array(
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* Default Template CSS */
|
/* Default Template CSS */
|
||||||
|
|
||||||
|
table.box-full { border: 1px solid #AAAACC; margin-right: auto; width: 100%; }
|
||||||
table.box-left { border: 1px solid #AAAACC; margin-right: auto; }
|
table.box-left { border: 1px solid #AAAACC; margin-right: auto; }
|
||||||
table.box-center { border: 1px solid #AAAACC; margin-left: auto; margin-right: auto; }
|
table.box-center { border: 1px solid #AAAACC; margin-left: auto; margin-right: auto; }
|
||||||
tr.head { font-weight: bold; }
|
tr.head { font-weight: bold; }
|
||||||
|
Reference in New Issue
Block a user