Updates to node display

This commit is contained in:
Deon George
2011-04-08 15:34:04 +10:00
parent d053493eeb
commit 8814447096
10 changed files with 53 additions and 74 deletions

View File

@@ -94,7 +94,6 @@ class Database_TSM extends Database {
$result = $this->query(Database::SELECT,'SELECT server_name,platform,version,release,level,sublevel FROM status');
//echo Kohana::debug($result);die();
if ($result)
return TSM::instance()->set($username,$password,$result);
else
@@ -163,10 +162,15 @@ class Database_TSM extends Database {
}
}
private function clear() {
$this->_query_msg_codes = array();
}
public function query($type, $sql, $as_object = FALSE, array $params = NULL)
{
// Make sure the database is connected
$this->_connection or $this->connect();
$this->clear();
if ( ! empty($this->_config['profiling']))
{
@@ -174,6 +178,10 @@ class Database_TSM extends Database {
$benchmark = Profiler::start("Database ({$this->_instance})", $sql);
}
// We need to escape any back slashes, since the exec will transpose them
// @todo Is there a better way of doing this?
$sql = str_replace('\\','\\\\',$sql);
// Execute the query
$stderr = exec($this->_connection.'"'.$sql.'"',$stdout,$rc);
@@ -187,7 +195,7 @@ class Database_TSM extends Database {
// If we got a no data code
if (array_intersect($this->_query_msg_codes,$this->nodata_codes)) {
$result = array(0);
$result = array();
$rc = 0;
}

View File

@@ -73,7 +73,7 @@ class Database_TSM_Result extends Database_Result {
// Return an object of given class name
$o = new $this->_as_object;
return $o->_load_values($this->_rows[$this->_current_row]);
return $o->values($this->_rows[$this->_current_row]);
}
else
{

View File

@@ -11,6 +11,8 @@
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;
// Validation rules
protected $_rules = array(

View File

@@ -32,9 +32,9 @@ class Model_FILESPACE extends ORMTSM {
public function storagepools($dtype) {
$pool = array();
foreach ($this->VOLUMEUSAGE
foreach ($this->OCCUPANCY
->select('STGPOOL_NAME')
->where('COPY_TYPE','=',$dtype)
->where('TYPE','=',$dtype)
->group_by('STGPOOL_NAME')
->order_by('STGPOOL_NAME')
->find_all() as $vo) {

View File

@@ -52,29 +52,38 @@ class Model_NODE extends ORMTSM {
}
public function lasttransfertime() {
return $this->LASTSESS_DURATION*($this->lasttransferpercent()/100);
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 _('N/A');
return 0;
}
public function lastreceiveperformance() {
if ($this->lasttransfertime())
return $this->LASTSESS_RECVD/$this->lasttransfertime()/1024/1024;
else
return _('N/A');
return 0;
}
public function lastsendaggperformance() {
return $this->LASTSESS_SENT/$this->LASTSESS_DURATION/1024/1024;
if ((real)$this->LASTSESS_DURATION)
return $this->LASTSESS_SENT/$this->LASTSESS_DURATION/1024/1024;
else
return 0;
}
public function lastreceiveaggperformance() {
return $this->LASTSESS_RECVD/$this->LASTSESS_DURATION/1024/1024;
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.

View File

@@ -1,43 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class overrides the Kohana ORM for some TSM specific calls.
*
* @package PTA
* @subpackage ORM
* @category Overrides
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class ORM extends Kohana_ORM {
/**
* Override Kohana's FIND to remove the LIMIT
*/
public function find($id = NULL) {
// Since TSM doesnt support LIMIT, we'll use find_all() but return the first record
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);
// If we have found our item return
if ($this->_loaded)
return $object;
}
}
/**
* We need to call our own _load_values() to support find() and TSM::result()
*
* (Since _load_values is protected, we need to make it public here,
* so that it can be called in TSM::result().)
*
* @see TSM::result
* @see ORM::find
*/
public function _load_values(array $values) {
return parent::_load_values($values);
}
}
?>

View File

@@ -15,6 +15,8 @@ abstract class ORMTSM extends ORM {
protected $_disable_wild_select = TRUE;
// Suppress ORMs inclusion of <table_name>. to column joins
protected $_disable_join_table_name = TRUE;
// Suppress ORMs use of limit
protected $_disable_limit = TRUE;
// Enable the formating of columns
protected $_object_formated = array();
@@ -48,7 +50,7 @@ abstract class ORMTSM extends ORM {
$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)
if ($value AND ! $this->_formated AND $this->_formats)
$this->_format();
if (isset($this->_object_formated[$column]))