From 8814447096f6e3ccff296cc10927a622584849d8 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 8 Apr 2011 15:34:04 +1000 Subject: [PATCH] Updates to node display --- application/classes/database/tsm.php | 12 +++++- application/classes/database/tsm/result.php | 2 +- .../classes/model/auth/userdefault.php | 2 + application/classes/model/filespace.php | 4 +- application/classes/model/node.php | 19 +++++--- application/classes/orm.php | 43 ------------------- application/classes/ormtsm.php | 4 +- application/config/config.php | 1 + application/views/nodes/detail.php | 2 +- application/views/nodes/detail_filesystem.php | 38 ++++++++-------- 10 files changed, 53 insertions(+), 74 deletions(-) delete mode 100644 application/classes/orm.php diff --git a/application/classes/database/tsm.php b/application/classes/database/tsm.php index 7de495c..303015a 100644 --- a/application/classes/database/tsm.php +++ b/application/classes/database/tsm.php @@ -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; } diff --git a/application/classes/database/tsm/result.php b/application/classes/database/tsm/result.php index 60b6add..910cb69 100644 --- a/application/classes/database/tsm/result.php +++ b/application/classes/database/tsm/result.php @@ -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 { diff --git a/application/classes/model/auth/userdefault.php b/application/classes/model/auth/userdefault.php index 8257921..723aa74 100644 --- a/application/classes/model/auth/userdefault.php +++ b/application/classes/model/auth/userdefault.php @@ -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( diff --git a/application/classes/model/filespace.php b/application/classes/model/filespace.php index dddf619..7ee2c5d 100644 --- a/application/classes/model/filespace.php +++ b/application/classes/model/filespace.php @@ -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) { diff --git a/application/classes/model/node.php b/application/classes/model/node.php index 8a0c3d5..3a71108 100644 --- a/application/classes/model/node.php +++ b/application/classes/model/node.php @@ -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. diff --git a/application/classes/orm.php b/application/classes/orm.php deleted file mode 100644 index 6c64393..0000000 --- a/application/classes/orm.php +++ /dev/null @@ -1,43 +0,0 @@ -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); - } -} -?> diff --git a/application/classes/ormtsm.php b/application/classes/ormtsm.php index c6a7a1e..63a5ec6 100644 --- a/application/classes/ormtsm.php +++ b/application/classes/ormtsm.php @@ -15,6 +15,8 @@ abstract class ORMTSM extends ORM { protected $_disable_wild_select = TRUE; // Suppress ORMs inclusion of . 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])) diff --git a/application/config/config.php b/application/config/config.php index 33e5e58..e6d2ab8 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -16,6 +16,7 @@ return array( 'stanza' => '', 'client_errorlogname' => '/tmp/pta-tsm-errorlog.log', 'date_format' => 'd-m-Y', + 'tsmpooltypes' => array('PRIMARY','ACTIVEDATA','COPY'), 'email_admin_only'=> array( 'method'=>array('wurley@users.sf.net'=>'Deon George'), ), diff --git a/application/views/nodes/detail.php b/application/views/nodes/detail.php index 9391d7b..d07f5ed 100644 --- a/application/views/nodes/detail.php +++ b/application/views/nodes/detail.php @@ -47,7 +47,7 @@ - + diff --git a/application/views/nodes/detail_filesystem.php b/application/views/nodes/detail_filesystem.php index daf2d03..b862e22 100644 --- a/application/views/nodes/detail_filesystem.php +++ b/application/views/nodes/detail_filesystem.php @@ -1,11 +1,11 @@
Last Backup Performance InformationLast Session Performance Information
 
- storagepools('BACKUP')) { ?> - - storagepools('ARCHIVE')) { ?> -
+ storagepools('Bkup')) { ?> @@ -14,65 +14,65 @@ getStoragePools('BACKUP',$type))) + if (count($pools = $node->getStoragePools('Bkup',$type))) foreach ($pools as $pool_name) { ?> - FILESPACE->find_all() as $fso) { ?> - + FILESPACE->find_all() as $fso) { ?> + getStoragePools('BACKUP',$type))) + if (count($pools = $node->getStoragePools('Bkup',$type))) foreach ($pools as $pool_name) { ?> - + + + +
Backup Information
 
Last Date Utilisation
display('FILESPACE_NAME'); ?> display('BACKUP_END'); ?> utilsation(),2); ?> pool_logical_util($pool_name),2); ?> (pool_numvols($pool_name); ?>)pool_logical_util($pool_name),2); ?> (pool_numvols($pool_name); ?>)
There is NO Backup Data for this Node.
 
- + + storagepools('Arch')) { ?> - - getStoragePools('ARCHIVE',$type))) + if (count($pools = $node->getStoragePools('Arch',$type))) foreach ($pools as $pool_name) { ?> - FILESPACE->find_all() as $fso) { ?> - + FILESPACE->find_all() as $fso) { ?> + - - getStoragePools('ARCHIVE',$type))) + if (count($pools = $node->getStoragePools('Arch',$type))) foreach ($pools as $pool_name) { ?> - + + + +
Backup InformationArchive Information
 
File SpaceUtilisationLast Date
display('FILESPACE_NAME'); ?>utilsation(),2); ?>display('BACKUP_END'); ?> pool_logical_util($pool_name),2); ?> (pool_numvols($pool_name); ?>)pool_logical_util($pool_name),2); ?> (pool_numvols($pool_name); ?>)
There is NO Archive Data for this Node.