More library display enhancements
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
/**
|
||||
*
|
||||
* @package PTA
|
||||
* @subpackage Volume
|
||||
* @subpackage Device Classes
|
||||
* @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
|
||||
* @note 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';
|
||||
@@ -17,5 +17,9 @@ class Model_DEVCLASSES extends ORMTSM {
|
||||
'DEVTYPE'=>'ASC',
|
||||
'DEVCLASS_NAME'=>'ASC',
|
||||
);
|
||||
|
||||
protected $_has_many = array(
|
||||
'STGPOOL'=>array('foreign_key'=>'DEVCLASS','far_key'=>'DEVCLASS_NAME'),
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
@@ -16,10 +16,119 @@ class Model_LIBRARY extends ORMTSM {
|
||||
'LIBRARY_NAME'=>'ASC',
|
||||
);
|
||||
|
||||
// Store our show slots data
|
||||
private $slots;
|
||||
private $storagepools = array();
|
||||
|
||||
protected $_has_one = array(
|
||||
);
|
||||
protected $_has_many = array(
|
||||
'DRIVE'=>array('foreign_key'=>'LIBRARY_NAME','far_key'=>'LIBRARY_NAME'),
|
||||
'PATH'=>array('foreign_key'=>'DESTINATION_NAME','far_key'=>'LIBRARY_NAME'),
|
||||
'DEVCLASSES'=>array('foreign_key'=>'LIBRARY_NAME','far_key'=>'LIBRARY_NAME'),
|
||||
);
|
||||
|
||||
public function slots() {
|
||||
return $this->slots ? $this->slots : $this->slots = DB::query(Database::SHOW,'SHOW SLOTS '.$this)->execute();
|
||||
}
|
||||
|
||||
// Return a list of scratch volumes
|
||||
public function scratch() {
|
||||
$return = array();
|
||||
|
||||
foreach ($this->slots() as $slot)
|
||||
if ($slot->status == 'Allocated' AND $slot->LIBVOLUME->usage() == 'scratch')
|
||||
array_push($return,$slot->LIBVOLUME->VOLUME);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
// Return a list of volumes that are readonly
|
||||
public function readonly() {
|
||||
$return = array();
|
||||
|
||||
foreach ($this->slots() as $slot)
|
||||
if ($slot->LIBVOLUME->VOLUME->ACCESS == 'READONLY')
|
||||
array_push($return,$slot->LIBVOLUME->VOLUME);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
// Return the number of slots that are empty.
|
||||
public function numemptyslot() {
|
||||
return $this->slots->Slots-$this->slots->Changers-count($this->slots);
|
||||
}
|
||||
|
||||
// Return the slots that are used, but not checked in.
|
||||
public function notcheckedin() {
|
||||
$return = array();
|
||||
|
||||
foreach ($this->slots() as $slot)
|
||||
if ($slot->status == 'Full')
|
||||
array_push($return,$slot);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
// Return the device classes that use this library.
|
||||
public function devclasses() {
|
||||
return $this->DEVCLASSES->where('LIBRARY_NAME','=',$this)->find_all();
|
||||
}
|
||||
|
||||
// Return a list of storage pools that potentially use this library.
|
||||
public function storagepools() {
|
||||
if (! $this->storagepools)
|
||||
foreach ($this->devclasses() as $dco)
|
||||
foreach ($dco->STGPOOL->find_all() as $spo)
|
||||
array_push($this->storagepools,$spo);
|
||||
|
||||
return $this->storagepools;
|
||||
}
|
||||
|
||||
public function storagepoolstype($type) {
|
||||
$result = array();
|
||||
|
||||
foreach ($this->storagepools() as $spo)
|
||||
if ($spo->POOLTYPE == $type)
|
||||
array_push($result,$spo);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Return a list of volumes
|
||||
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
|
||||
// @param $inout IN|OUT of the library
|
||||
// @param $status volume status FULL|FILLING|PENDING|EMPTY
|
||||
// @note This is an intensive method that needs caching.
|
||||
public function volstype($type,$inout,$status) {
|
||||
static $CACHE = array();
|
||||
$ainout = array('in','out');
|
||||
$astatus = array('FULL','FILLING','PENDING','EMPTY');
|
||||
|
||||
if (! isset($CACHE[__METHOD__][$type]))
|
||||
foreach ($this->storagepoolstype($type) as $spo)
|
||||
foreach ($ainout as $cinout)
|
||||
foreach ($astatus as $cstatus) {
|
||||
if (! isset($CACHE[__METHOD__][$spo->POOLTYPE][$cinout][$cstatus]))
|
||||
$CACHE[__METHOD__][$spo->POOLTYPE][$cinout][$cstatus] = array();
|
||||
|
||||
$CACHE[__METHOD__][$spo->POOLTYPE][$cinout][$cstatus] =
|
||||
array_merge($CACHE[__METHOD__][$spo->POOLTYPE][$cinout][$cstatus],$spo->libvolstype($cinout,$cstatus));
|
||||
}
|
||||
|
||||
return isset($CACHE[__METHOD__][$type][$inout][$status]) ? $CACHE[__METHOD__][$type][$inout][$status] : array();
|
||||
}
|
||||
|
||||
public function volsnotinlib() {
|
||||
$result = array();
|
||||
|
||||
foreach ($this->storagepools() as $spo)
|
||||
foreach ($spo->VOLUME->find_all() as $vo)
|
||||
if ($vo->MEDIA->STATUS != 'MOUNTABLEINLIB')
|
||||
array_push($result,$vo);
|
||||
|
||||
Sort::masort($result,'VOLUME_NAME');
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
class Model_LIBVOLUME extends ORMTSM {
|
||||
protected $_table_name = 'LIBVOLUMES';
|
||||
protected $_primary_key = 'VOLUME_NAME';
|
||||
protected $_primary_key = 'HOME_ELEMENT';
|
||||
protected $_sorting = array(
|
||||
'VOLUME_NAME'=>'ASC',
|
||||
);
|
||||
@@ -32,16 +32,19 @@ class Model_LIBVOLUME extends ORMTSM {
|
||||
case 'data':
|
||||
return strtolower($this->LAST_USE);
|
||||
|
||||
default: return 'unknown';
|
||||
default: return ($this->VOLUME->STATUS == 'EMPTY') ? 'empty' : 'unknown';
|
||||
}
|
||||
default: return 'notcheckedin';
|
||||
}
|
||||
}
|
||||
|
||||
public function volusage() {
|
||||
switch ($this->usage()) {
|
||||
case 'scratch': return _('Scratch');
|
||||
case 'data':
|
||||
case 'empty': return $this->VOLUME->STGPOOL_NAME;
|
||||
case 'dbbackup': return $this->VOLHISTORY->lastuse()->TYPE;
|
||||
case 'data': return $this->VOLUME->STGPOOL_NAME;
|
||||
case 'notcheckedin': return _('Not Checked In');
|
||||
case 'scratch': return _('Scratch');
|
||||
|
||||
default: return _('Unknown');
|
||||
}
|
||||
@@ -51,27 +54,26 @@ class Model_LIBVOLUME extends ORMTSM {
|
||||
switch ($this->usage()) {
|
||||
case 'data': return sprintf('%s/%s',$this->VOLUME->display('STATUS'),$this->VOLUME->display('ACCESS'));
|
||||
case 'dbbackup': return $this->VOLHISTORY->lastuse()->backupid();
|
||||
case 'empty': return _('Empty');
|
||||
|
||||
default: return '';
|
||||
}
|
||||
}
|
||||
|
||||
public function access() {
|
||||
switch ($this->usage()) {
|
||||
case 'data':
|
||||
case 'dbbackup':
|
||||
return sprintf('%s/%s',$this->display('STATUS'),$this->display('OWNER'));
|
||||
|
||||
default: return '';
|
||||
}
|
||||
if ($this->usage() == 'scratch')
|
||||
return '';
|
||||
elseif ($this->STATUS)
|
||||
return sprintf('%s/%s',$this->display('STATUS'),$this->display('OWNER'));
|
||||
else
|
||||
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');
|
||||
case 'empty': return $this->VOLUME->display('LAST_WRITE_DATE');
|
||||
case 'dbbackup': return $this->VOLHISTORY->lastuse()->display('DATE_TIME');
|
||||
|
||||
default: return '';
|
||||
}
|
||||
|
24
application/classes/model/media.php
Normal file
24
application/classes/model/media.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
*
|
||||
* @package PTA
|
||||
* @subpackage Media
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 phpTSMadmin Development Team
|
||||
* @license http://phptsmadmin.sf.net/license.html
|
||||
*/
|
||||
class Model_MEDIA extends ORMTSM {
|
||||
protected $_table_name = 'MEDIA';
|
||||
protected $_primary_key = 'VOLUME_NAME';
|
||||
protected $_sorting = array(
|
||||
'VOLUME_NAME'=>'ASC',
|
||||
);
|
||||
|
||||
protected $_has_one = array(
|
||||
);
|
||||
protected $_has_many = array(
|
||||
);
|
||||
}
|
||||
?>
|
@@ -22,5 +22,23 @@ class Model_STGPOOL extends ORMTSM {
|
||||
protected $_has_many = array(
|
||||
'VOLUME'=>array('foreign_key'=>'STGPOOL_NAME','far_key'=>'STGPOOL_NAME'),
|
||||
);
|
||||
|
||||
// Return a list of volumes
|
||||
// @param $inout IN|OUT of the library
|
||||
// @param $status volume status FULL|FILLING|PENDING|EMPTY
|
||||
public function libvolstype($inout,$status) {
|
||||
$inout = strtolower($inout);
|
||||
$status = strtoupper($status);
|
||||
$result = array();
|
||||
|
||||
if (! isset($result[$inout]))
|
||||
foreach ($this->VOLUME->find_all() as $vo) {
|
||||
$state = ($vo->MEDIA->STATE == 'MOUNTABLEINLIB') ? 'in' : 'out';
|
||||
|
||||
$result[$state][$vo->STATUS][] = $vo;
|
||||
}
|
||||
|
||||
return isset($result[$inout][$status]) ? $result[$inout][$status] : array();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -17,6 +17,9 @@ class Model_VOLUME extends ORMTSM {
|
||||
'STGPOOL_NAME'=>'ASC',
|
||||
);
|
||||
|
||||
protected $_has_one = array(
|
||||
'MEDIA'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
|
||||
);
|
||||
protected $_has_many = array(
|
||||
'VOLUMEUSAGE'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
|
||||
);
|
||||
|
Reference in New Issue
Block a user