Additional info for node display

This commit is contained in:
Deon George 2011-05-29 11:41:36 +10:00
parent 21b013e3ba
commit fe549c1c05
3 changed files with 35 additions and 7 deletions

View File

@ -132,8 +132,12 @@ class Model_NODE extends ORMTSM {
return $this->pools[$dtype]; return $this->pools[$dtype];
} }
public function getAllStoragePoolsType($ptype) {
return array_merge($this->getStoragePoolsType('Bkup',$ptype),$this->getStoragePoolsType('Arch',$ptype));
}
// Return the storage pools used for a backup type // Return the storage pools used for a backup type
// $dtype is BACKUP or ARCHIVE // $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
// $ptype is pool type (PRIMARY,ACTIVE,COPY) // $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStoragePoolsType($dtype,$ptype) { public function getStoragePoolsType($dtype,$ptype) {
if (! isset($this->pools[$dtype])) if (! isset($this->pools[$dtype]))
@ -143,24 +147,36 @@ class Model_NODE extends ORMTSM {
} }
// @todo This routine should be cached. // @todo This routine should be cached.
public function getStorageTypeFiles($type) { public function getStorageTypeVols($type,$spo='') {
$count = array();
foreach ($this->VOLUMEUSAGE->find_all() as $vo)
if ((! $spo OR $vo->STGPOOL_NAME == $spo) AND $vo->STGPOOL->POOLTYPE == $type)
if (! in_array($vo->VOLUME_NAME,$count))
array_push($count,$vo->VOLUME_NAME);
return count($count);
}
// @todo This routine should be cached.
public function getStorageTypeFiles($type,$spo='') {
$count = 0; $count = 0;
foreach ($this->FILESPACE->find_all() as $fo) foreach ($this->FILESPACE->find_all() as $fo)
foreach ($fo->OCCUPANCY->find_all() as $oa) foreach ($fo->OCCUPANCY->find_all() as $oa)
if ($oa->STGPOOL->POOLTYPE == $type) if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $type)
$count += $oa->NUM_FILES; $count += $oa->NUM_FILES;
return $count; return $count;
} }
// @todo This routine should be cached. // @todo This routine should be cached.
public function getStorageTypeData($type) { public function getStorageTypeData($type,$spo='') {
$count = 0; $count = 0;
foreach ($this->FILESPACE->find_all() as $fo) foreach ($this->FILESPACE->find_all() as $fo)
foreach ($fo->OCCUPANCY->find_all() as $oa) foreach ($fo->OCCUPANCY->find_all() as $oa)
if ($oa->STGPOOL->POOLTYPE == $type) if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $type)
$count += $oa->LOGICAL_MB; $count += $oa->LOGICAL_MB;
return $count; return $count;

View File

@ -19,6 +19,7 @@ class Model_VOLUMEUSAGE extends ORMTSM {
); );
protected $_has_one = array( protected $_has_one = array(
'STGPOOL'=>array('foreign_key'=>'STGPOOL_NAME','far_key'=>'STGPOOL_NAME'),
'VOLUME'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'), 'VOLUME'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
); );
} }

View File

@ -45,16 +45,27 @@
<td class="spacer">&nbsp;</td> <td class="spacer">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td>Storage Type</td> <td colspan="2">Storage Type</td>
<td class="right">Vols</td>
<td class="right">Files</td> <td class="right">Files</td>
<td class="right">MB</td> <td class="right">MB</td>
</tr> </tr>
<?php $i=0; foreach (Kohana::config('config.tsmpooltypes') as $type) { ?> <?php $i=0; foreach (Kohana::config('config.tsmpooltypes') as $type) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>"> <tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td class="data"><?php echo $type; ?></td> <td class="data" colspan="2"><?php echo $type; ?></td>
<td class="data-right"><?php echo $node->getStorageTypeVols($type); ?></td>
<td class="data-right"><?php echo $node->getStorageTypeFiles($type); ?></td> <td class="data-right"><?php echo $node->getStorageTypeFiles($type); ?></td>
<td class="data-right"><?php echo $node->getStorageTypeData($type); ?></td> <td class="data-right"><?php echo $node->getStorageTypeData($type); ?></td>
</tr> </tr>
<?php foreach ($node->getAllStoragePoolsType($type) as $spo) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td>&nbsp;</td>
<td><?php echo $spo; ?></td>
<td class="right"><?php echo $node->getStorageTypeVols($type,$spo); ?></td>
<td class="right"><?php echo $node->getStorageTypeFiles($type,$spo); ?></td>
<td class="right"><?php echo $node->getStorageTypeData($type,$spo); ?></td>
</tr>
<?php } ?>
<?php } ?> <?php } ?>
</table> </table>
</td> </td>