Updated Domain and Node views

This commit is contained in:
Deon George
2011-06-01 00:51:15 +10:00
parent ae2c1440ed
commit d7822a03e8
12 changed files with 426 additions and 184 deletions

View File

@@ -0,0 +1,78 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides information on TSM Nodes.
*
* @package PTA
* @subpackage Domains
* @category Controllers
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Controller_DOMAIN extends Controller_TemplateDefault {
/**
* Default Index for Controller
*/
public function action_index() {
$do = ORM::factory('domain');
$output = '';
$output .= sprintf(_('This server has <b>%s</b> domains.'),$do->count_all());
$output .= '<br/>';
$output .= '<br/>';
$select = array();
$select[NULL] = '';
foreach ($do->find_all() as $domain)
$select[$domain->DOMAIN_NAME] = $domain->DOMAIN_NAME;
$output .= Form::open('/domain/detail',array('id'=>'domain_detail'));
$output .= sprintf('%s: %s',_('Choose a domain to view'),Form::select('domain_name',$select,NULL,array('id'=>'domain_name')));
$output .= Form::submit('form_submit',_('Go'));
$output .= Form::close();
Script::add(array(
'type'=>'stdin',
'data'=>'
$(document).ready(function () {$("#domain_name").change(function () {
$("#domain_name").trigger("submit");
});});'
));
Block::add(array(
'title'=>_('TSM Domains'),
'body'=>$output,
));
}
public function action_detail($domain_name=NULL) {
if (is_null($domain_name) AND (empty($_POST['domain_name']) OR ! $domain_name = $_POST['domain_name'])) {
SystemMessage::add(array(
'title'=>_('DOMAIN_NAME is required'),
'type'=>'error',
'body'=>_('The domain name is required.'),
));
Request::current()->redirect('domain');
}
$do = ORM::factory('domain',$domain_name);
if (! $do->loaded()) {
SystemMessage::add(array(
'title'=>_('Unknown DOMAIN_NAME'),
'type'=>'error',
'body'=>sprintf(_('The domain [%s] does not exist?.'),$domain_name),
));
Request::current()->redirect('domain');
}
Block::add(array(
'title'=>sprintf(_('Node Information for Domain %s'),$do->DOMAIN_NAME),
'body'=>View::factory('domain/detail')->set('do',$do)
));
}
}
?>

View File

@@ -29,7 +29,7 @@ class Controller_NODE extends Controller_TemplateDefault {
$select[$node->NODE_NAME] = $node->NODE_NAME;
$output .= Form::open('/node/detail',array('id'=>'node_detail'));
$output .= sprintf('%s: %s',_('Choose a new to view'),Form::select('node_name',$select,NULL,array('id'=>'node_name')));
$output .= sprintf('%s: %s',_('Choose a node to view'),Form::select('node_name',$select,NULL,array('id'=>'node_name')));
$output .= Form::submit('form_submit',_('Go'));
$output .= Form::close();
@@ -48,10 +48,26 @@ $(document).ready(function () {$("#node_name").change(function () {
}
public function action_detail($node_name=NULL) {
if (is_null($node_name) AND (empty($_POST['node_name']) OR ! $node_name = $_POST['node_name']))
throw new Kohana_Exception('Missing NODE_NAME');
if (is_null($node_name) AND (empty($_POST['node_name']) OR ! $node_name = $_POST['node_name'])) {
SystemMessage::add(array(
'title'=>_('NODE_NAME is required'),
'type'=>'error',
'body'=>_('The node name is required.'),
));
Request::current()->redirect('node');
}
$no = ORM::factory('node',$node_name);
if (! $no->loaded()) {
SystemMessage::add(array(
'title'=>_('Unknown NODE_NAME'),
'type'=>'error',
'body'=>sprintf(_('The node [%s] does not exist?.'),$node_name),
));
Request::current()->redirect('node');
}
Block::add(array(
'title'=>sprintf('%s %s',_('Detailed Node Information for'),$no->NODE_NAME),
@@ -73,15 +89,5 @@ $(document).ready(function () {$("#node_name").change(function () {
'body'=>View::factory('nodes/detail_schedule')->set('node',$no),
));
}
public function action_summary() {
$do = ORM::factory('domain');
foreach ($do->find_all() as $domain)
Block::add(array(
'title'=>_('Node Information by Domain'),
'body'=>View::factory('nodes/summary')->set('do',$domain)
));
}
}
?>

View File

@@ -23,20 +23,20 @@ class Controller_Tree extends Controller_lnApp_Tree {
*/
public function action_json($id=null,array $data=array()) {
// @todo Our menu options
array_push($data,array(
'id'=>'domain',
'name'=>'Domain Info',
'state'=>'none',
'attr_id'=>'1',
'attr_href'=>URL::Site('domain'),
));
array_push($data,array(
'id'=>'node',
'name'=>'Node Info',
'state'=>'none',
'attr_id'=>'1',
'attr_href'=>URL::Site('/node'),
));
array_push($data,array(
'id'=>'node_summary',
'name'=>'Node Summary',
'state'=>'none',
'attr_id'=>'1',
'attr_href'=>URL::Site('/node/summary'),
'attr_href'=>URL::Site('node'),
));
array_push($data,array(
@@ -44,7 +44,7 @@ class Controller_Tree extends Controller_lnApp_Tree {
'name'=>'Server Activity Gantt',
'state'=>'none',
'attr_id'=>'1',
'attr_href'=>URL::Site('/server/gantt'),
'attr_href'=>URL::Site('server/gantt'),
));
return parent::action_json($id,$data);

View File

@@ -17,7 +17,9 @@ class Model_DOMAIN extends ORMTSM {
);
protected $_has_many = array(
'MGMTCLASS'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
'NODE'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
'SCHEDULE_CLIENT'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME')
);
// Pools used by a domain.
@@ -83,5 +85,17 @@ class Model_DOMAIN extends ORMTSM {
return $count;
}
// $dtype is BACKUP or ARCHIVE
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeNodes($dtype,$ptype,$spo='') {
$result = array();
foreach ($this->NODE->find_all() as $no)
if ($no->getStorageModeData($dtype,$ptype,$spo))
array_push($result,$no);
return $result;
}
}
?>

View File

@@ -16,6 +16,9 @@ class Model_NODE extends ORMTSM {
'NODE_NAME'=>'ASC',
);
protected $_has_one = array(
'DOMAIN'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
);
protected $_has_many = array(
'FILESPACE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
'VOLUMEUSAGE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
@@ -60,7 +63,14 @@ class Model_NODE extends ORMTSM {
private $pools = array();
public function tsmclientversion() {
return sprintf('%s.%s.%s.%s',$this->CLIENT_VERSION,$this->CLIENT_RELEASE,$this->CLIENT_LEVEL,$this->CLIENT_SUBLEVEL);
if ($this->CLIENT_VERSION)
return sprintf('%s.%s.%s.%s',$this->CLIENT_VERSION,$this->CLIENT_RELEASE,$this->CLIENT_LEVEL,$this->CLIENT_SUBLEVEL);
else
return '';
}
public function platform() {
return sprintf('%s %s',$this->PLATFORM_NAME,$this->CLIENT_OS_LEVEL ? '('.$this->CLIENT_OS_LEVEL.')' : '');
}
// @todo This needs to return the global configuration.
@@ -133,6 +143,12 @@ class Model_NODE extends ORMTSM {
return $this->pools[$dtype];
}
// Test to see if a node has any data of type
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
public function hasData($dtype) {
return $this->getStoragePools($dtype) ? TRUE : FALSE;
}
public function getAllStoragePoolsType($ptype) {
$result = array();
@@ -188,6 +204,7 @@ class Model_NODE extends ORMTSM {
return $count;
}
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageTypeFiles($ptype,$spo='') {
$count = 0;
@@ -210,6 +227,7 @@ class Model_NODE extends ORMTSM {
return $count;
}
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageTypeData($ptype,$spo='') {
$count = 0;

View File

@@ -16,10 +16,18 @@ class Model_SCHEDULE_CLIENT extends ORMTSM {
'SCHEDULE_NAME'=>'ASC',
);
protected $_has_many = array(
'ASSOCIATION'=>array('foreign_key'=>'SCHEDULE_NAME','far_key'=>'SCHEDULE_NAME'),
);
protected $_display_filters = array(
'STARTTIME'=>array(
array('ORMTSM::date',array(':value','h:m')),
),
);
public function getNodes() {
return $this->ASSOCIATION->find_all();
}
}
?>

View File

@@ -41,5 +41,13 @@ class Model_VOLUME extends ORMTSM {
public function getNodesOnVol($dtype) {
return $this->VOLUMEUSAGE->select('NODE_NAME')->distinct(TRUE)->where('COPY_TYPE','=',$dtype)->find_all()->count();
}
public function isScratch() {
return $this->SCRATCH === 'YES' ? TRUE : FALSE;
}
public function location() {
return $this->display('LOCATION');
}
}
?>