diff --git a/application/classes/controller/library.php b/application/classes/controller/library.php
new file mode 100644
index 0000000..8d81f2e
--- /dev/null
+++ b/application/classes/controller/library.php
@@ -0,0 +1,73 @@
+%s libraries.'),$lo->count_all());
+ $output .= '
';
+ $output .= '
';
+
+ $select = array();
+ $select[NULL] = '';
+
+ foreach ($lo->find_all() as $library)
+ $select[$library->LIBRARY_NAME] = $library->LIBRARY_NAME;
+
+ $output .= Form::open('/library/detail',array('id'=>'library_detail'));
+ $output .= sprintf('%s: %s',_('Choose a storage pool to view'),Form::select('library_name',$select,NULL,array('id'=>'library_name')));
+ $output .= Form::submit('form_submit',_('Go'));
+ $output .= Form::close();
+
+ Block::add(array(
+ 'title'=>_('TSM Libraries'),
+ 'body'=>$output,
+ ));
+ }
+
+ public function action_detail($library=NULL) {
+ if (is_null($library) AND (empty($_POST['library_name']) OR ! $library = $_POST['library_name'])) {
+ SystemMessage::add(array(
+ 'title'=>_('LIBRARY_NAME is required'),
+ 'type'=>'error',
+ 'body'=>_('The library pool name is required.'),
+ ));
+
+ Request::current()->redirect('library');
+ }
+
+ $lo = ORM::factory('library',$library);
+ if (! $lo->loaded()) {
+ SystemMessage::add(array(
+ 'title'=>_('Unknown LIBRARY_NAME'),
+ 'type'=>'error',
+ 'body'=>sprintf(_('The library pool [%s] does not exist?.'),$library),
+ ));
+
+ Request::current()->redirect('library');
+ }
+
+ $slots = DB::query(Database::SHOW,'SHOW SLOTS '.$lo)->execute();
+ Block::add(array(
+ 'title'=>sprintf(_('Library Information for %s'),$lo->LIBRARY_NAME),
+ 'body'=>View::factory('library/detail')
+ ->set('lo',$lo)
+ ->set('slots',$slots)
+ ));
+ }
+}
+?>
diff --git a/application/classes/controller/tree.php b/application/classes/controller/tree.php
index ede3e1a..82c80ff 100644
--- a/application/classes/controller/tree.php
+++ b/application/classes/controller/tree.php
@@ -31,6 +31,14 @@ class Controller_Tree extends Controller_lnApp_Tree {
'attr_href'=>URL::Site('domain'),
));
+ array_push($data,array(
+ 'id'=>'library',
+ 'name'=>'Library Info',
+ 'state'=>'none',
+ 'attr_id'=>'1',
+ 'attr_href'=>URL::Site('library'),
+ ));
+
array_push($data,array(
'id'=>'node',
'name'=>'Node Info',
diff --git a/application/classes/database.php b/application/classes/database.php
new file mode 100644
index 0000000..b4bda30
--- /dev/null
+++ b/application/classes/database.php
@@ -0,0 +1,17 @@
+
diff --git a/application/classes/database/result.php b/application/classes/database/result.php
new file mode 100644
index 0000000..6960197
--- /dev/null
+++ b/application/classes/database/result.php
@@ -0,0 +1,63 @@
+offsetExists($offset)) {
+ // Set the current row to the offset
+ $this->_current_row = $this->_internal_row = $offset;
+
+ return TRUE;
+
+ } else {
+ return FALSE;
+ }
+ }
+
+ public function current() {
+ if ($this->_current_row !== $this->_internal_row AND ! $this->seek($this->_current_row))
+ return FALSE;
+
+ // Return an stdClass
+ if ($this->_as_object === TRUE) {
+ return $this;
+
+ } elseif (is_string($this->_as_object)) {
+ // Return an object of given class name
+ $o = new $this->_as_object;
+
+ return $o->load_object($this->_rows[$this->_current_row]);
+
+ // Return an array of the row
+ } else {
+ 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);
+ }
+}
+?>
diff --git a/application/classes/database/tsm.php b/application/classes/database/tsm.php
index 569cc64..83136a5 100644
--- a/application/classes/database/tsm.php
+++ b/application/classes/database/tsm.php
@@ -187,6 +187,8 @@ class Database_TSM extends Database {
return new Database_TSM_Result($result, $sql, $as_object, $params);
elseif ($type === Database::INSERT)
throw new Kohana_Exception('Database INSERTS are not supported');
+ elseif ($type === Database::SHOW)
+ return new Database_TSM_Show($result, $sql, $as_object, $params);
}
public function list_tables($like = NULL) {
diff --git a/application/classes/database/tsm/result.php b/application/classes/database/tsm/result.php
index 1f6bb8a..2d06764 100644
--- a/application/classes/database/tsm/result.php
+++ b/application/classes/database/tsm/result.php
@@ -11,12 +11,7 @@
* @license http://phptsmadmin.sf.net/license.html
*/
class Database_TSM_Result extends Database_Result {
-
- protected $_internal_row = 0;
- private $_rows;
-
- public function __construct($result, $sql, $as_object = FALSE, array $params = NULL)
- {
+ public function __construct($result, $sql, $as_object = FALSE, array $params = NULL) {
parent::__construct($result, $sql, $as_object, $params);
$start = FALSE;
@@ -37,60 +32,5 @@ class Database_TSM_Result extends Database_Result {
$this->_total_rows = $this->_internal_row;
$this->_internal_row = 0;
}
-
- public function __destruct()
- {
- return;
- }
-
- public function seek($offset)
- {
- if ($this->offsetExists($offset))
- {
- // Set the current row to the offset
- $this->_current_row = $this->_internal_row = $offset;
-
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
-
- public function current()
- {
- if ($this->_current_row !== $this->_internal_row AND ! $this->seek($this->_current_row))
- return FALSE;
-
- if ($this->_as_object === TRUE)
- {
- // Return an stdClass
- return $this;
- }
- elseif (is_string($this->_as_object))
- {
- // Return an object of given class name
- $o = new $this->_as_object;
-
- return $o->load_object($this->_rows[$this->_current_row]);
- }
- else
- {
- // Return an array of the 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
+}
?>
diff --git a/application/classes/database/tsm/show.php b/application/classes/database/tsm/show.php
new file mode 100644
index 0000000..cecaae1
--- /dev/null
+++ b/application/classes/database/tsm/show.php
@@ -0,0 +1,61 @@
+_internal_row++;
+
+ $slot = array();
+ foreach ((preg_split('/,\s*/',$line,-1)) as $slotkey => $val)
+ if (preg_match('/^element number\s+/',$val))
+ $slot['element'] = preg_replace('/^element number\s+/','',$val);
+ elseif (preg_match('/^Slot\s+/',$val))
+ $slot['slot'] = preg_replace('/^Slot\s+/','',$val);
+ elseif (preg_match('/^status\s+/',$val))
+ $slot['status'] = preg_replace('/^status\s+/','',$val);
+ elseif (preg_match('/^barcode value ',$val))
+ $slot['barcodelabel'] = preg_replace('/^barcode value <(.*)>/',"$1",$val);
+ elseif (preg_match('/^barcode\s+/',$val))
+ $slot['barcode'] = preg_replace('/^barcode /','',$val);
+
+ $slot['library'] = preg_replace('/^show slots /','',$sql);
+ $this->_rows[$this->_internal_row] = new Slot($slot);
+ $start = TRUE;
+
+ } elseif (preg_match('/busy.$/',$line)) {
+ SystemMessage::add(array(
+ 'title'=>_('Library is Busy'),
+ 'type'=>'info',
+ 'body'=>_('The library appears busy at the moment.'),
+ ));
+
+ return;
+ }
+ }
+
+ $this->_total_rows = $this->_internal_row;
+ $this->_internal_row = 0;
+ }
+}
+?>
diff --git a/application/classes/html.php b/application/classes/html.php
new file mode 100644
index 0000000..8cad46f
--- /dev/null
+++ b/application/classes/html.php
@@ -0,0 +1,4 @@
+
diff --git a/application/classes/lnapp/html.php b/application/classes/lnapp/html.php
new file mode 100644
index 0000000..7c43317
--- /dev/null
+++ b/application/classes/lnapp/html.php
@@ -0,0 +1,21 @@
+
diff --git a/application/classes/model/library.php b/application/classes/model/library.php
new file mode 100644
index 0000000..740b698
--- /dev/null
+++ b/application/classes/model/library.php
@@ -0,0 +1,24 @@
+'ASC',
+ );
+
+ protected $_has_one = array(
+ );
+ protected $_has_many = array(
+ );
+}
+?>
diff --git a/application/classes/model/libvolume.php b/application/classes/model/libvolume.php
new file mode 100644
index 0000000..012331a
--- /dev/null
+++ b/application/classes/model/libvolume.php
@@ -0,0 +1,81 @@
+'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':
+ switch (strtolower($this->LAST_USE)) {
+ case 'dbbackup':
+ case 'data':
+ return strtolower($this->LAST_USE);
+
+ default: return 'unknown';
+ }
+ }
+ }
+
+ public function volusage() {
+ switch ($this->usage()) {
+ case 'scratch': return _('Scratch');
+ case 'dbbackup': return $this->VOLHISTORY->lastuse()->TYPE;
+ case 'data': return $this->VOLUME->STGPOOL_NAME;
+
+ 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();
+
+ default: return '';
+ }
+ }
+
+ public function access() {
+ switch ($this->usage()) {
+ case 'data':
+ case 'dbbackup':
+ return sprintf('%s/%s',$this->display('STATUS'),$this->display('OWNER'));
+
+ default: return '';
+ }
+ }
+
+ public function lastwrite() {
+ switch ($this->usage()) {
+ case 'data':
+ return $this->VOLUME->display('LAST_WRITE_DATE');
+ case 'dbbackup':
+ return $this->VOLHISTORY->lastuse()->display('DATE_TIME');
+
+ default: return '';
+ }
+ }
+
+}
+?>
diff --git a/application/classes/model/volhistory.php b/application/classes/model/volhistory.php
new file mode 100644
index 0000000..72d1925
--- /dev/null
+++ b/application/classes/model/volhistory.php
@@ -0,0 +1,41 @@
+'ASC',
+ );
+
+ protected $_has_one = array(
+ 'VOLUME'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
+ );
+ protected $_has_many = array(
+ );
+
+ protected $_display_filters = array(
+ 'DATE_TIME'=>array(
+ array('ORMTSM::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);
+ }
+}
+?>
diff --git a/application/classes/orm.php b/application/classes/orm.php
index 86c9f13..476eef6 100644
--- a/application/classes/orm.php
+++ b/application/classes/orm.php
@@ -63,7 +63,7 @@ class ORM extends Kohana_ORM {
if (isset($this->_object_formated[$column]))
return $this->_object_formated[$column];
else
- return strlen((string)$value) ? $value : ' ';
+ return HTML::nbsp($value);
}
}
?>
diff --git a/application/classes/slot.php b/application/classes/slot.php
new file mode 100644
index 0000000..8b6fc9c
--- /dev/null
+++ b/application/classes/slot.php
@@ -0,0 +1,38 @@
+'barcodelabel',
+ 'LIBVOLUME'=>'barcodelabel',
+ );
+
+ public function __construct(array $slot) {
+ $this->data = $slot;
+ }
+
+ public function __get($key) {
+ if (isset($this->data[$key]))
+ return $this->data[$key];
+ // @todo Volume names may not be unique if there is more than 1 library.
+ elseif (isset($this->objects[$key]))
+ return ORM::factory($key,$this->__get($this->objects[$key]));
+ else
+ throw new Kohana_Exception('Undefined property :class:::property',array(':class'=>get_class($this),':property'=>$key));
+ }
+
+ public function __toString() {
+ return $this->slot;
+ }
+}
+?>
diff --git a/application/config/database.php b/application/config/database.php
index cc82154..15d8d87 100644
--- a/application/config/database.php
+++ b/application/config/database.php
@@ -47,20 +47,26 @@ return array
'DOMAINS' => 1200,
'EVENTS' => 1200,
'FILESPACES' => 1200,
+ 'LIBRARIES' => 1200,
+ 'LIBVOLUMES' => 1200,
'MGMTCLASSES' => 1200,
'NODES' => 1200,
'OCCUPANCY' => 1200,
'SCHEMA' => 604800,
'STGPOOLS' => 1200,
'SUMMARY' => 180,
+ 'VOLHISTORY' => 1200,
'VOLUMES' => 1200,
'VOLUMEUSAGE' => 1200,
),
'cachepreload' => array(
'DEVCLASSES' => 1200,
'DOMAINS' => 1200,
+ 'LIBVOLUMES' => 1200,
+ 'LIBRARIES' => 1200,
'NODES' => 1200,
'STGPOOLS' => 1200,
+ 'VOLHISTORY' => 1200,
'VOLUMES' => 1200,
),
'profiling' => TRUE,
diff --git a/application/views/library/detail.php b/application/views/library/detail.php
new file mode 100644
index 0000000..61c22c3
--- /dev/null
+++ b/application/views/library/detail.php
@@ -0,0 +1,76 @@
+
+
+
+
+
+ Information for this Library |
+
+
+ |
+
+
+ Name |
+ display('LIBRARY_NAME'); ?> |
+
+ Serial Number |
+ display('LIBRARY_SERIAL'); ?> |
+
+
+ Type |
+ display('LIBRARY_TYPE'); ?> |
+
+
+ Shared |
+ display('SHARED'); ?> |
+
+
+ LAN Free |
+ display('LANFREE'); ?> |
+
+
+ Auto Label |
+ display('AUTOLABEL'); ?> |
+
+
+ |
+
+
+ |
+
+
+
+
+
+ Volumes in this Library |
+
+
+ |
+
+
+ Slot |
+ Barcode |
+ Usage |
+ Status/Access |
+ Library Access |
+ Utilisation |
+ Reclaim |
+ Last Read |
+ Last Write |
+
+
+
+ |
+ barcodelabel; ?> |
+ LIBVOLUME->volusage(); ?> |
+ LIBVOLUME->status()); ?> |
+ LIBVOLUME->access()); ?> |
+ LIBVOLUME->VOLUME->display('PCT_UTILIZED'); ?> |
+ LIBVOLUME->VOLUME->display('PCT_RECLAIM'); ?> |
+ LIBVOLUME->VOLUME->display('LAST_READ_DATE'); ?> |
+ LIBVOLUME->lastwrite()); ?> |
+
+
+
+ |
+
+
diff --git a/application/views/node/detail_schedule.php b/application/views/node/detail_schedule.php
index c5ff57a..3ad8b66 100644
--- a/application/views/node/detail_schedule.php
+++ b/application/views/node/detail_schedule.php
@@ -79,10 +79,10 @@
EVENT->find_all() as $eo) { ?>
display('SCHEDULED_START'); ?> |
- ACTUAL_START ? $eo->display('ACTUAL_START') : ' '; ?> |
+ display('ACTUAL_START')); ?> |
display('SCHEDULE_NAME'); ?> |
display('STATUS'); ?> |
- COMPLETED ? $eo->display('COMPLETED') : ' '; ?> |
+ display('COMPLETED')); ?> |
RESULT,$eo->display('REASON')); ?> |